Skip to content

Commit 314cd28

Browse files
authored
Run Rust CI only if rust directory is modified (#1529)
Avoid running CI checks unnecessarily. Need to validate if this causes any issue with "required check". Hopefully not, as this is a pattern used in other OTel repos too. Later to be expanded to Go also.
1 parent 99113cf commit 314cd28

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/rust-ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,25 @@ concurrency:
2020
cancel-in-progress: true
2121

2222
jobs:
23+
check-changes:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
rust: ${{ steps.filter.outputs.rust }}
27+
steps:
28+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
29+
with:
30+
submodules: true
31+
- uses: dorny/paths-filter@v2
32+
id: filter
33+
with:
34+
filters: |
35+
rust:
36+
- 'rust/**'
37+
- '.github/workflows/rust-ci.yml'
38+
2339
test_and_coverage:
40+
needs: check-changes
41+
if: needs.check-changes.outputs.rust == 'true'
2442
strategy:
2543
fail-fast: false
2644
matrix:
@@ -56,6 +74,8 @@ jobs:
5674
fail_ci_if_error: true
5775

5876
fmt:
77+
needs: check-changes
78+
if: needs.check-changes.outputs.rust == 'true'
5979
strategy:
6080
fail-fast: false
6181
matrix:
@@ -80,6 +100,8 @@ jobs:
80100
working-directory: ./rust/${{ matrix.folder }}
81101

82102
clippy:
103+
needs: check-changes
104+
if: needs.check-changes.outputs.rust == 'true'
83105
strategy:
84106
fail-fast: false
85107
matrix:
@@ -105,6 +127,8 @@ jobs:
105127
working-directory: ./rust/${{ matrix.folder }}
106128

107129
deny:
130+
needs: check-changes
131+
if: needs.check-changes.outputs.rust == 'true'
108132
strategy:
109133
fail-fast: false
110134
matrix:
@@ -149,6 +173,8 @@ jobs:
149173
manifest-path: ./rust/${{ matrix.folder }}/Cargo.toml
150174

151175
docs:
176+
needs: check-changes
177+
if: needs.check-changes.outputs.rust == 'true'
152178
strategy:
153179
fail-fast: false
154180
matrix:
@@ -172,6 +198,8 @@ jobs:
172198
working-directory: ./rust/${{ matrix.folder }}
173199

174200
structure_check:
201+
needs: check-changes
202+
if: needs.check-changes.outputs.rust == 'true'
175203
strategy:
176204
fail-fast: false
177205
matrix:

0 commit comments

Comments
 (0)