Skip to content

Commit 164ee22

Browse files
authored
chore(ci): ci to skip when changes are limited to workflow config files (#13299)
Changes to ci.yaml to skip tests when only other .github/workflow files are changed. This should not affect existing filtering behavior for split repo tests, but skips tests like enforcer, lint, unit for other workflow file changes. They are not skipped for changes in ci.yaml and .kokoro files.
1 parent a577934 commit 164ee22

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,22 @@ jobs:
2929
outputs:
3030
src: ${{ steps.filter.outputs.src }}
3131
ci: ${{ steps.filter.outputs.ci }}
32+
# runnable is true if there are changes outside the .github/workflows directory OR if ci.yaml itself (or kokoro scripts) is modified.
33+
runnable: ${{ fromJSON(steps.filter.outputs.all_count) > fromJSON(steps.filter.outputs.workflows_count) || fromJSON(steps.filter.outputs.ci_count) > 0 }}
3234
steps:
33-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v6
36+
# Use this action, rather than a file filter so that we can make this
37+
# mandatory.
38+
# See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#example-including-branches
39+
# for more details.
3440
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
3541
id: filter
3642
with:
3743
filters: |
44+
all:
45+
- '**'
46+
workflows:
47+
- '.github/workflows/**'
3848
src:
3949
- '!(google-auth-library-java|grpc-gcp-java|java-bigquery|java-bigquery-jdbc|java-bigquerystorage|java-bigtable|java-datastore|java-firestore|java-logging|java-logging-logback|java-pubsub|java-spanner|java-storage)/**/*.java'
4050
- '!(google-auth-library-java|grpc-gcp-java|java-bigquery|java-bigquery-jdbc|java-bigquerystorage|java-bigtable|java-datastore|java-firestore|java-logging|java-logging-logback|java-pubsub|java-spanner|java-storage)/**/pom.xml'
@@ -46,6 +56,7 @@ jobs:
4656
units:
4757
runs-on: ubuntu-latest
4858
needs: bulk-filter
59+
if: ${{ needs.bulk-filter.outputs.runnable == 'true' }}
4960
strategy:
5061
fail-fast: false
5162
matrix:
@@ -73,6 +84,7 @@ jobs:
7384
units-8-runtime:
7485
runs-on: ubuntu-latest
7586
needs: bulk-filter
87+
if: ${{ needs.bulk-filter.outputs.runnable == 'true' }}
7688
name: "units (8)"
7789
steps:
7890
- name: Get current week within the year
@@ -106,13 +118,15 @@ jobs:
106118
JOB_NAME: units-8-runtime-${{matrix.java}}
107119
# detect which libraries have changed
108120
changes:
121+
needs: bulk-filter
122+
if: ${{ needs.bulk-filter.outputs.runnable == 'true' }}
109123
runs-on: ubuntu-latest
110124
permissions:
111125
pull-requests: read
112126
outputs:
113127
packages: ${{ steps.filter.outputs.changes }}
114128
steps:
115-
- uses: actions/checkout@v4
129+
- uses: actions/checkout@v6
116130
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
117131
id: filter
118132
with:
@@ -302,7 +316,7 @@ jobs:
302316
env:
303317
BUILD_SUBDIR: ${{matrix.package}}
304318
required:
305-
needs: [ changes, split-units, split-clirr, split-dependencies ]
319+
needs: [ bulk-filter, changes, split-units, split-clirr, split-dependencies ]
306320
name: conditional-required-check
307321
if: ${{ always() }} # Always run even if any "needs" jobs fail
308322
runs-on: ubuntu-22.04
@@ -313,6 +327,8 @@ jobs:
313327
- name: Success otherwise
314328
run: echo "Success!"
315329
windows:
330+
needs: bulk-filter
331+
if: ${{ needs.bulk-filter.outputs.runnable == 'true' }}
316332
runs-on: windows-latest
317333
steps:
318334
- name: Support longpaths
@@ -329,6 +345,8 @@ jobs:
329345
JOB_TYPE: test
330346
JOB_NAME: windows-units
331347
lint:
348+
needs: bulk-filter
349+
if: ${{ needs.bulk-filter.outputs.runnable == 'true' }}
332350
runs-on: ubuntu-latest
333351
steps:
334352
- uses: actions/checkout@v4
@@ -345,6 +363,8 @@ jobs:
345363
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
346364
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
347365
enforcer:
366+
needs: bulk-filter
367+
if: ${{ needs.bulk-filter.outputs.runnable == 'true' }}
348368
runs-on: ubuntu-latest
349369
steps:
350370
- name: Get current week within the year
@@ -364,6 +384,8 @@ jobs:
364384
- run: java -version
365385
- run: mvn -B -ntp enforcer:enforce@enforce -T 1C
366386
gapic-libraries-bom:
387+
needs: bulk-filter
388+
if: ${{ needs.bulk-filter.outputs.runnable == 'true' }}
367389
runs-on: ubuntu-latest
368390
steps:
369391
- uses: actions/checkout@v4
@@ -381,6 +403,8 @@ jobs:
381403
with:
382404
bom-path: gapic-libraries-bom/pom.xml
383405
generation-config-check:
406+
needs: bulk-filter
407+
if: ${{ needs.bulk-filter.outputs.runnable == 'true' }}
384408
runs-on: ubuntu-latest
385409
steps:
386410
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)