Skip to content

Commit 4860366

Browse files
authored
ci: add conditional-required-check for skipped matrix jobs (#12884)
This adds a new final job to GitHub actions workflows that conditionally skip tests using `jobs.if`. The new `required` job looks to see if any of the jobs within that workflow marked as `needs` have failed. If any have failed, then this test is marked as failed. Otherwise, it is marked as succeeded. We can make this new `conditional-required-check` a required check for merging PRs. Towards #12702
1 parent f562667 commit 4860366

7 files changed

Lines changed: 83 additions & 31 deletions

.github/workflows/ci.yaml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ jobs:
246246
JOB_TYPE: test
247247
JOB_NAME: units-8-runtime-${{matrix.java}}
248248
working-directory: ${{matrix.package}}
249+
required:
250+
needs: [ changes, split-units ]
251+
name: conditional-required-check
252+
if: ${{ always() }} # Always run even if any "needs" jobs fail
253+
runs-on: ubuntu-22.04
254+
steps:
255+
- name: Fail if any previous failure
256+
if: ${{ needs.changes.outputs.packages != '[]' && contains(needs.*.result, 'failure') }}
257+
run: exit 1
258+
- name: Success otherwise
259+
run: echo "Success!"
249260
windows:
250261
runs-on: windows-latest
251262
steps:
@@ -332,30 +343,3 @@ jobs:
332343
env:
333344
library_generation_image_tag: 2.68.0
334345
workspace_name: /workspace
335-
336-
# TODO: Uncomment the needed Github Actions
337-
# dependencies:
338-
# runs-on: ubuntu-latest
339-
# strategy:
340-
# matrix:
341-
# java: [8, 11, 17]
342-
# steps:
343-
# - uses: actions/checkout@v3
344-
# - uses: actions/setup-java@v3
345-
# with:
346-
# distribution: zulu
347-
# java-version: ${{matrix.java}}
348-
# - run: java -version
349-
# - run: .kokoro/dependencies.sh
350-
# clirr:
351-
# runs-on: ubuntu-latest
352-
# steps:
353-
# - uses: actions/checkout@v3
354-
# - uses: actions/setup-java@v3
355-
# with:
356-
# distribution: zulu
357-
# java-version: 8
358-
# - run: java -version
359-
# - run: .kokoro/build.sh
360-
# env:
361-
# JOB_TYPE: clirr

.github/workflows/google-auth-library-java-ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
filters: |
3535
library:
3636
- 'google-auth-library-java/**'
37+
- '.github/workflows/google-auth-library-java-ci.yaml'
3738
units-logging:
3839
needs: filter
3940
if: ${{ needs.filter.outputs.library == 'true' }}
@@ -54,3 +55,14 @@ jobs:
5455
BUILD_SUBDIR: google-auth-library-java
5556
JOB_TYPE: test
5657
SUREFIRE_JVM_OPT: "-P '!slf4j2x,slf4j2x-test'"
58+
required:
59+
needs: [ units-logging ]
60+
name: conditional-required-check
61+
if: ${{ always() }} # Always run even if any "needs" jobs fail
62+
runs-on: ubuntu-22.04
63+
steps:
64+
- name: Fail if any previous failure
65+
if: ${{ contains(needs.*.result, 'failure') }}
66+
run: exit 1
67+
- name: Success otherwise
68+
run: echo "Success!"

.github/workflows/hermetic-build-scripts-ci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,14 @@ jobs:
9797
# exclude generated golden files
9898
# exclude owlbot until further refaction
9999
black --check hermetic_build --exclude "(library_generation/tests/resources/goldens)"
100+
required:
101+
needs: [ library-generation-unit-tests, library-generation-lint-shell, library-generation-lint-python ]
102+
name: conditional-required-check
103+
if: ${{ always() }} # Always run even if any "needs" jobs fail
104+
runs-on: ubuntu-22.04
105+
steps:
106+
- name: Fail if any previous failure
107+
if: ${{ contains(needs.*.result, 'failure') }}
108+
run: exit 1
109+
- name: Success otherwise
110+
run: echo "Success!"

.github/workflows/java-spanner-jdbc-ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
filters: |
3535
library:
3636
- 'java-spanner-jdbc/**'
37+
- '.github/workflows/java-spanner-jdbc-ci.yaml'
3738
units:
3839
needs: filter
3940
if: ${{ needs.filter.outputs.library == 'true' }}
@@ -141,3 +142,14 @@ jobs:
141142
JOB_TYPE: lint
142143
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
143144
BASE_SHA: ${{ github.event.pull_request.base.sha }}
145+
required:
146+
needs: [ units, units-java8, windows, dependencies, javadoc, lint ]
147+
name: conditional-required-check
148+
if: ${{ always() }} # Always run even if any "needs" jobs fail
149+
runs-on: ubuntu-22.04
150+
steps:
151+
- name: Fail if any previous failure
152+
if: ${{ contains(needs.*.result, 'failure') }}
153+
run: exit 1
154+
- name: Success otherwise
155+
run: echo "Success!"

.github/workflows/java-storage-nio-ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
filters: |
3535
library:
3636
- 'java-storage-nio/**'
37+
- '.github/workflows/java-storage-nio-ci.yaml'
3738
units:
3839
needs: filter
3940
if: ${{ needs.filter.outputs.library == 'true' }}
@@ -141,3 +142,14 @@ jobs:
141142
JOB_TYPE: lint
142143
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
143144
BASE_SHA: ${{ github.event.pull_request.base.sha }}
145+
required:
146+
needs: [ units, units-java8, windows, dependencies, javadoc, lint ]
147+
name: conditional-required-check
148+
if: ${{ always() }} # Always run even if any "needs" jobs fail
149+
runs-on: ubuntu-22.04
150+
steps:
151+
- name: Fail if any previous failure
152+
if: ${{ contains(needs.*.result, 'failure') }}
153+
run: exit 1
154+
- name: Success otherwise
155+
run: echo "Success!"

.github/workflows/sdk-platform-java-downstream.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
library:
2525
- 'sdk-platform-java/**'
2626
- .kokoro/downstream-compatibility.sh
27+
- .github/workflows/sdk-platform-java-downstream.yaml
2728
downstream-compatibility:
2829
needs: filter
2930
if: ${{ needs.filter.outputs.library == 'true' }}
@@ -71,3 +72,14 @@ jobs:
7172
sudo apt-get -y install libxml2-utils
7273
- name: Perform downstream compatibility testing
7374
run: .kokoro/downstream-compatibility-spring.sh
75+
required:
76+
needs: [ downstream-compatibility, downstream-compatibility-spring-generator ]
77+
name: conditional-required-check
78+
if: ${{ always() }} # Always run even if any "needs" jobs fail
79+
runs-on: ubuntu-22.04
80+
steps:
81+
- name: Fail if any previous failure
82+
if: ${{ contains(needs.*.result, 'failure') }}
83+
run: exit 1
84+
- name: Success otherwise
85+
run: echo "Success!"

.github/workflows/sdk-platform-java-downstream_unmanaged_dependency_check.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ on:
33
branches:
44
- main
55
pull_request:
6-
paths:
7-
- .github/workflows/sdk-platform-java-downstream_unmanaged_dependency_check.yaml
8-
- sdk-platform-java/java-shared-dependencies/**
96

107
name: sdk-platform-java Downstream Unmanaged Dependency Check
118
env:
@@ -22,7 +19,8 @@ jobs:
2219
with:
2320
filters: |
2421
library:
25-
- 'sdk-platform-java/**'
22+
- 'sdk-platform-java/java-shared-dependencies/**'
23+
- '.github/workflows/sdk-platform-java-downstream_unmanaged_dependency_check.yaml'
2624
validate:
2725
needs: filter
2826
if: ${{ needs.filter.outputs.library == 'true' }}
@@ -96,3 +94,14 @@ jobs:
9694
exit 1
9795
fi
9896
echo "Unmanaged dependency check passed"
97+
required:
98+
needs: [ validate ]
99+
name: conditional-required-check
100+
if: ${{ always() }} # Always run even if any "needs" jobs fail
101+
runs-on: ubuntu-22.04
102+
steps:
103+
- name: Fail if any previous failure
104+
if: ${{ contains(needs.*.result, 'failure') }}
105+
run: exit 1
106+
- name: Success otherwise
107+
run: echo "Success!"

0 commit comments

Comments
 (0)