forked from GoogleCloudPlatform/nodejs-docs-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (177 loc) · 7.22 KB
/
custard-run.yaml
File metadata and controls
186 lines (177 loc) · 7.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Custard run
on:
# Run tests when a pull request is created or updated.
# This allows to run tests from forked repos (after reviewer's approval).
workflow_run:
workflows:
- Custard CI # .github/workflows/custard-ci.yaml
types:
- in_progress
# Run tests again as validation when a PR merge into main.
push:
branches:
- main
# To do manual runs through the Actions UI.
workflow_dispatch:
inputs:
run-all:
description: Run all tests
type: boolean
default: false
paths:
description: Comma separated packages to test
type: string
ref:
description: Branch, tag, or commit SHA to run tests on
type: string
default: main
# For nightly tests.
# schedule:
# # https://crontab.guru/#0_12_*_*_0
# - cron: 0 12 * * 0 # At 12:00 on Sunday
jobs:
affected:
uses: GoogleCloudPlatform/cloud-samples-tools/.github/workflows/affected.yaml@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
permissions:
statuses: write
with:
head-sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
config-file: .github/config/nodejs.jsonc
paths: ${{ (inputs.run-all && '.') || inputs.paths || '' }}
check-name: Custard CI / tests
create-check-if: ${{ !!github.event.workflow_run }}
lint:
needs: affected
runs-on: ubuntu-latest
permissions:
statuses: write
timeout-minutes: 5
steps:
- name: Check in_progress
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
id: in_progress
with:
sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
status: in_progress
name: Custard CI / ${{ github.job }}
if: ${{ !!github.event.workflow_run }}
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
ref: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- run: npm install
- name: npx gtx lint (${{ needs.affected.outputs.num-paths }} packages)
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/map-run@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
with:
command: npx gts lint
paths: ${{ needs.affected.outputs.paths }}
- name: Check success
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
with:
check: ${{ steps.in_progress.outputs.check }}
status: success
- name: Check failure
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
if: failure()
with:
check: ${{ steps.in_progress.outputs.check }}
status: failure
test:
if: needs.affected.outputs.paths != '[]'
needs: affected
runs-on: ubuntu-latest
timeout-minutes: 120 # 2 hours hard limit
permissions:
id-token: write
statuses: write
strategy:
fail-fast: false
matrix:
path: ${{ fromJson(needs.affected.outputs.paths) }}
continue-on-error: true
env:
GOOGLE_SAMPLES_PROJECT: long-door-651
SERVICE_ACCOUNT: kokoro-system-test@long-door-651.iam.gserviceaccount.com
steps:
- name: Check queued
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
id: queued
with:
sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
name: Custard CI / ${{ github.job }} (${{ matrix.path }})
job-name: ${{ github.job }} (${{ matrix.path }})
if: ${{ !!github.event.workflow_run }}
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
ref: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
- name: Authenticate
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
id: auth
with:
project_id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
workload_identity_provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
service_account: ${{ env.SERVICE_ACCOUNT }}
access_token_lifetime: 600s # 10 minutes
token_format: id_token
id_token_audience: https://action.test/ # service must have this custom audience
id_token_include_email: true
- name: Setup Custard
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/setup-custard@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
with:
path: ${{ matrix.path }}
ci-setup: ${{ toJson(fromJson(needs.affected.outputs.ci-setups)[matrix.path]) }}
id-token: ${{ steps.auth.outputs.id_token }}
- name: Check in_progress
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
id: in_progress
with:
check: ${{ steps.queued.outputs.check }}
status: in_progress
- name: Run tests for ${{ matrix.path }}
run: |
timeout ${{ fromJson(needs.affected.outputs.ci-setups)[matrix.path].timeout-minutes }}m \
make test dir=${{ matrix.path }}
env:
# TODO: remove this when the self-contained runner lands.
SERVICE_ACCOUNT: kokoro-system-test@long-door-651.iam.gserviceaccount.com
- name: Check success
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
with:
check: ${{ steps.in_progress.outputs.check }}
status: success
- name: Check failure
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
if: failure()
with:
check: ${{ steps.in_progress.outputs.check }}
status: failure
done:
needs: [affected, lint, test]
if: always()
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- name: Check success
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@9ee708234e240605d96e78f652c333ed6aa95a23 # v0.3.2
with:
check: ${{ needs.affected.outputs.check }}
status: success