Skip to content

Commit b0cd84d

Browse files
author
David Cavazos
committed
add pull_request and workflow_run jobs
1 parent fd6ec65 commit b0cd84d

File tree

4 files changed

+290
-2
lines changed

4 files changed

+290
-2
lines changed

.github/workflows/custard-ci-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: custard CI (dev)
15+
name: Custard CI (dev)
1616
on:
1717
push:
1818
branches:

.github/workflows/custard-ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: custard CI
15+
name: Custard CI
1616
on:
1717
push:
1818
branches:
@@ -25,6 +25,7 @@ on:
2525
env:
2626
GO_VERSION: ^1.22.0
2727

28+
# TODO: remove all jobs except region-tags (should be tested by custard-run workflows)
2829
jobs:
2930
affected:
3031
name: Finding affected tests
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Custard run (dev)
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
workflow_run:
22+
workflows:
23+
- Custard CI # .github/workflows/custard-ci.yaml
24+
types:
25+
- in_progress
26+
workflow_dispatch:
27+
inputs:
28+
run-all:
29+
description: Run all tests
30+
type: boolean
31+
default: false
32+
paths:
33+
description: Comma separated packages to test
34+
type: string
35+
ref:
36+
description: Branch, tag, or commit SHA to run tests on
37+
type: string
38+
default: main
39+
# schedule:
40+
# # https://crontab.guru/#0_12_*_*_0
41+
# - cron: 0 12 * * 0 # At 12:00 on Sunday
42+
43+
jobs:
44+
affected:
45+
uses: GoogleCloudPlatform/cloud-samples-tools/.github/workflows/[email protected]
46+
permissions:
47+
statuses: write
48+
with:
49+
head-sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
50+
config-file: .github/config/nodejs-dev.jsonc
51+
paths: ${{ (inputs.run-all && '.') || inputs.paths || '' }}
52+
create-check-if: ${{ !!github.event.workflow_run }}
53+
54+
test:
55+
needs: affected
56+
runs-on: ubuntu-latest
57+
timeout-minutes: 120 # 2 hours hard limit
58+
permissions:
59+
statuses: write
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
path: ${{ needs.affected.outputs.paths }}
64+
continue-on-error: true
65+
env:
66+
GOOGLE_SAMPLES_PROJECT: long-door-651
67+
GOOGLE_SERVICE_ACCOUNT: [email protected]
68+
steps:
69+
- name: Check queued
70+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
71+
id: queued
72+
with:
73+
sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
74+
name: Custard CI / ${{ github.job }} (${{ matrix.path }})
75+
job-name: ${{ github.job }} (${{ matrix.path }})
76+
if: ${{ !!github.event.workflow_run }}
77+
- name: Setup Custard
78+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
79+
with:
80+
path: ${{ matrix.path }}
81+
ci-setup: ${{ toJson(fromJson(needs.affected.outputs.ci-setups)[matrix.path]) }}
82+
project-id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
83+
workload-identity-provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
84+
service-account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
85+
- name: Check in_progress
86+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
87+
id: in_progress
88+
with:
89+
check: ${{ steps.queued.outputs.check }}
90+
status: in_progress
91+
- name: Run tests for ${{ matrix.path }}
92+
run: |
93+
timeout ${{ fromJson(needs.affected.outputs.ci-setups)[matrix.path].timeout-minutes }}m \
94+
make test dir=${{ matrix.path }}
95+
- name: Check success
96+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
97+
with:
98+
check: ${{ steps.in_progress.outputs.check }}
99+
status: success
100+
- name: Check failure
101+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
102+
if: failure()
103+
with:
104+
check: ${{ steps.in_progress.outputs.check }}
105+
status: failure
106+
# - name: Upload test results for FlakyBot workflow
107+
# if: github.event.action == 'schedule' && always() # always() submits logs even if tests fail
108+
# uses: actions/upload-artifact@v4
109+
# with:
110+
# name: test-results
111+
# path: ${{ matrix.path }}/${{ github.run_id }}_sponge_log.xml
112+
# retention-days: 1
113+
114+
done:
115+
needs: [affected, test]
116+
runs-on: ubuntu-latest
117+
permissions:
118+
statuses: write
119+
steps:
120+
- name: Check success
121+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
122+
with:
123+
check: ${{ needs.affected.outputs.check }}
124+
status: success

.github/workflows/custard-run.yaml

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Custard run
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
workflow_run:
22+
workflows:
23+
- Custard CI # .github/workflows/custard-ci.yaml
24+
types:
25+
- in_progress
26+
workflow_dispatch:
27+
inputs:
28+
run-all:
29+
description: Run all tests
30+
type: boolean
31+
default: false
32+
paths:
33+
description: Comma separated packages to test
34+
type: string
35+
ref:
36+
description: Branch, tag, or commit SHA to run tests on
37+
type: string
38+
default: main
39+
# schedule:
40+
# # https://crontab.guru/#0_12_*_*_0
41+
# - cron: 0 12 * * 0 # At 12:00 on Sunday
42+
43+
jobs:
44+
affected:
45+
uses: GoogleCloudPlatform/cloud-samples-tools/.github/workflows/[email protected]
46+
permissions:
47+
statuses: write
48+
with:
49+
head-sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
50+
config-file: .github/config/nodejs.jsonc
51+
paths: ${{ (inputs.run-all && '.') || inputs.paths || '' }}
52+
create-check-if: ${{ !!github.event.workflow_run }}
53+
54+
lint:
55+
needs: affected
56+
runs-on: ubuntu-latest
57+
permissions:
58+
statuses: write
59+
timeout-minutes: 5
60+
steps:
61+
- name: Check in_progress
62+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
63+
id: in_progress
64+
with:
65+
sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
66+
status: in_progress
67+
name: Custard CI / ${{ github.job }}
68+
if: ${{ !!github.event.workflow_run }}
69+
- name: Checkout
70+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
71+
- name: Setup Node
72+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
73+
with:
74+
node-version: 20
75+
- run: npm install
76+
- name: npx gtx lint (${{ needs.affected.outputs.num-paths }} packages)
77+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
78+
with:
79+
command: npx gts lint
80+
paths: ${{ needs.affected.outputs.paths }}
81+
- name: Check success
82+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
83+
with:
84+
check: ${{ steps.in_progress.outputs.check }}
85+
status: success
86+
- name: Check failure
87+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
88+
if: failure()
89+
with:
90+
check: ${{ steps.in_progress.outputs.check }}
91+
status: failure
92+
93+
test:
94+
needs: affected
95+
runs-on: ubuntu-latest
96+
timeout-minutes: 120 # 2 hours hard limit
97+
permissions:
98+
statuses: write
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
path: ${{ needs.affected.outputs.paths }}
103+
continue-on-error: true
104+
env:
105+
GOOGLE_SAMPLES_PROJECT: long-door-651
106+
GOOGLE_SERVICE_ACCOUNT: [email protected]
107+
steps:
108+
- name: Check queued
109+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
110+
id: queued
111+
with:
112+
sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
113+
name: Custard CI / ${{ github.job }} (${{ matrix.path }})
114+
job-name: ${{ github.job }} (${{ matrix.path }})
115+
if: ${{ !!github.event.workflow_run }}
116+
- name: Setup Custard
117+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
118+
with:
119+
path: ${{ matrix.path }}
120+
ci-setup: ${{ toJson(fromJson(needs.affected.outputs.ci-setups)[matrix.path]) }}
121+
project-id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
122+
workload-identity-provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
123+
service-account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
124+
- name: Check in_progress
125+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
126+
id: in_progress
127+
with:
128+
check: ${{ steps.queued.outputs.check }}
129+
status: in_progress
130+
- name: Run tests for ${{ matrix.path }}
131+
run: |
132+
timeout ${{ fromJson(needs.affected.outputs.ci-setups)[matrix.path].timeout-minutes }}m \
133+
make test dir=${{ matrix.path }}
134+
- name: Check success
135+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
136+
with:
137+
check: ${{ steps.in_progress.outputs.check }}
138+
status: success
139+
- name: Check failure
140+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
141+
if: failure()
142+
with:
143+
check: ${{ steps.in_progress.outputs.check }}
144+
status: failure
145+
# - name: Upload test results for FlakyBot workflow
146+
# if: github.event.action == 'schedule' && always() # always() submits logs even if tests fail
147+
# uses: actions/upload-artifact@v4
148+
# with:
149+
# name: test-results
150+
# path: ${{ matrix.path }}/${{ github.run_id }}_sponge_log.xml
151+
# retention-days: 1
152+
153+
done:
154+
needs: [affected, lint, test]
155+
runs-on: ubuntu-latest
156+
permissions:
157+
statuses: write
158+
steps:
159+
- name: Check success
160+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/[email protected]
161+
with:
162+
check: ${{ needs.affected.outputs.check }}
163+
status: success

0 commit comments

Comments
 (0)