Skip to content

Commit 2ae85f1

Browse files
authored
ci: use flakybot with matrix workflows (#3112)
* ci: use flakybot with matrix workflows * fix typo * update common test file * test * add missing npm tests * add matrix support * update example text * address code review feedback * test workflow * test schedule * fix upload logic for testing * test template * revert test to functions-slack * fix license header * add newline * fix formatting
1 parent 183a16b commit 2ae85f1

28 files changed

+557
-358
lines changed

.github/workflows/ci.yaml

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2023 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+
115
on:
216
push:
317
branches:
@@ -26,4 +40,4 @@ jobs:
2640
runs-on: ubuntu-latest
2741
steps:
2842
- uses: actions/checkout@v3
29-
- run: ./.github/workflows/region-tags-tests.sh
43+
- run: ./.github/workflows/utils/region-tags-tests.sh
+31-53
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,57 @@
1+
# Copyright 2023 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+
115
name: functions-concepts
216
on:
317
push:
418
branches:
519
- main
620
paths:
721
- 'functions/concepts/**'
22+
- '.github/workflows/functions-concepts.yaml'
823
pull_request:
924
paths:
1025
- 'functions/concepts/**'
26+
- '.github/workflows/functions-concepts.yaml'
1127
pull_request_target:
1228
types: [labeled]
1329
paths:
1430
- 'functions/concepts/**'
31+
- '.github/workflows/functions-concepts.yaml'
1532
schedule:
1633
- cron: '0 0 * * 0'
1734
jobs:
1835
test:
36+
if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run'
1937
strategy:
2038
matrix:
21-
# Each package in this list will be tested independently.
22-
# New packages must be manually added to this list.
23-
package:
39+
path:
2440
- 'functions/concepts/afterResponse'
2541
- 'functions/concepts/afterTimeout'
2642
- 'functions/concepts/backgroundTermination'
2743
- 'functions/concepts/filesystem'
2844
- 'functions/concepts/httpTermination'
2945
- 'functions/concepts/requests'
30-
- 'functions/concepts/stateless'
31-
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
32-
runs-on: ubuntu-latest
33-
timeout-minutes: 60
34-
permissions:
35-
contents: 'write'
36-
pull-requests: 'write'
37-
id-token: 'write'
38-
steps:
39-
- uses: actions/checkout@v3
40-
with:
41-
ref: ${{github.event.pull_request.head.ref}}
42-
repository: ${{github.event.pull_request.head.repo.full_name}}
43-
- uses: google-github-actions/[email protected]
44-
with:
45-
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
46-
service_account: '[email protected]'
47-
create_credentials_file: 'true'
48-
access_token_lifetime: 600s
49-
- uses: actions/setup-node@v3
50-
with:
51-
node-version: 14
52-
- run: npm install
53-
working-directory: ${{ matrix.package }}
54-
- run: npm test -- --reporter xunit --reporter-option output=sponge_log.xml --reporter-option suiteName="${{ matrix.package }}"
55-
working-directory: ${{ matrix.package }}
56-
env:
57-
MOCHA_REPORTER: xunit
58-
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
59-
uses: actions/github-script@v6
60-
with:
61-
github-token: ${{ secrets.GITHUB_TOKEN }}
62-
script: |
63-
try {
64-
await github.rest.issues.removeLabel({
65-
name: 'actions:force-run',
66-
owner: 'GoogleCloudPlatform',
67-
repo: 'nodejs-docs-samples',
68-
issue_number: context.payload.pull_request.number
69-
});
70-
} catch (e) {
71-
if (!e.message.includes('Label does not exist')) {
72-
throw e;
73-
}
74-
}
75-
- if: ${{ github.event_name == 'schedule' && always() }}
76-
run: |
77-
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
78-
chmod +x ./flakybot
79-
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
46+
- 'functions/concepts/stateless'
47+
uses: ./.github/workflows/test.yaml
48+
with:
49+
name: 'functions-concepts'
50+
path: '${{ matrix.path }}'
51+
remove_label:
52+
if: github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' && always()
53+
uses: ./.github/workflows/remove-label.yaml
54+
flakybot:
55+
if: github.event_name == 'schedule' && always()
56+
uses: ./.github/workflows/flakybot.yaml
57+
needs: [test]
+27-53
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2023 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+
115
name: functions-helloworld
216
on:
317
push:
@@ -19,63 +33,23 @@ on:
1933
- cron: '0 0 * * 0'
2034
jobs:
2135
test:
36+
if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run'
2237
strategy:
2338
matrix:
24-
# Each package in this list will be tested independently.
25-
# New packages must be manually added to this list.
26-
package:
39+
path:
2740
- 'functions/helloworld/helloError'
2841
- 'functions/helloworld/helloGCS'
2942
- 'functions/helloworld/helloPubSub'
3043
- 'functions/helloworld/helloworldGet'
3144
- 'functions/helloworld/helloworldHttp'
32-
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
33-
runs-on: ubuntu-latest
34-
timeout-minutes: 60
35-
permissions:
36-
contents: 'write'
37-
pull-requests: 'write'
38-
id-token: 'write'
39-
steps:
40-
- uses: actions/[email protected]
41-
with:
42-
ref: ${{github.event.pull_request.head.sha}}
43-
- uses: 'google-github-actions/[email protected]'
44-
with:
45-
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
46-
service_account: '[email protected]'
47-
create_credentials_file: 'true'
48-
access_token_lifetime: 600s
49-
- uses: actions/[email protected]
50-
with:
51-
node-version: 16
52-
- run: npm install
53-
working-directory: ${{ matrix.package }}
54-
- run: npm test -- --reporter xunit --reporter-option output=sponge_log.xml --reporter-option suiteName="${{ matrix.package }}"
55-
working-directory: ${{ matrix.package }}
56-
env:
57-
MOCHA_REPORTER_SUITENAME: functions_helloworld
58-
MOCHA_REPORTER_OUTPUT: functions_helloworld_sponge_log.xml
59-
MOCHA_REPORTER: xunit
60-
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
61-
uses: actions/github-script@v6
62-
with:
63-
github-token: ${{ secrets.GITHUB_TOKEN }}
64-
script: |
65-
try {
66-
await github.rest.issues.removeLabel({
67-
name: 'actions:force-run',
68-
owner: 'GoogleCloudPlatform',
69-
repo: 'nodejs-docs-samples',
70-
issue_number: context.payload.pull_request.number
71-
});
72-
} catch (e) {
73-
if (!e.message.includes('Label does not exist')) {
74-
throw e;
75-
}
76-
}
77-
- if: ${{ github.event_name == 'schedule' && always() }}
78-
run: |
79-
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
80-
chmod +x ./flakybot
81-
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
45+
uses: ./.github/workflows/test.yaml
46+
with:
47+
name: 'functions-helloworld'
48+
path: '${{ matrix.path }}'
49+
remove_label:
50+
if: github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' && always()
51+
uses: ./.github/workflows/remove-label.yaml
52+
flakybot:
53+
if: github.event_name == 'schedule' && always()
54+
uses: ./.github/workflows/flakybot.yaml
55+
needs: [test]

.github/workflows/functions-http.yaml

+27-53
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2023 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+
115
name: functions-http
216
on:
317
push:
@@ -19,62 +33,22 @@ on:
1933
- cron: '0 0 * * 0'
2034
jobs:
2135
test:
36+
if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run'
2237
strategy:
2338
matrix:
24-
# Each package in this list will be tested independently.
25-
# New packages must be manually added to this list.
26-
package:
39+
path:
2740
- 'functions/http/corsEnabledFunction'
2841
- 'functions/http/corsEnabledFunctionAuth'
2942
- 'functions/http/httpContent'
3043
- 'functions/http/httpMethods'
31-
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
32-
runs-on: ubuntu-latest
33-
timeout-minutes: 60
34-
permissions:
35-
contents: 'write'
36-
pull-requests: 'write'
37-
id-token: 'write'
38-
steps:
39-
- uses: actions/[email protected]
40-
with:
41-
ref: ${{github.event.pull_request.head.sha}}
42-
- uses: 'google-github-actions/[email protected]'
43-
with:
44-
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
45-
service_account: '[email protected]'
46-
create_credentials_file: 'true'
47-
access_token_lifetime: 600s
48-
- uses: actions/[email protected]
49-
with:
50-
node-version: 16
51-
- run: npm install
52-
working-directory: ${{ matrix.package }}
53-
- run: npm test -- --reporter xunit --reporter-option output=sponge_log.xml --reporter-option suiteName="${{ matrix.package }}"
54-
working-directory: ${{ matrix.package }}
55-
env:
56-
MOCHA_REPORTER_SUITENAME: functions_http
57-
MOCHA_REPORTER_OUTPUT: functions_http_sponge_log.xml
58-
MOCHA_REPORTER: xunit
59-
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
60-
uses: actions/github-script@v6
61-
with:
62-
github-token: ${{ secrets.GITHUB_TOKEN }}
63-
script: |
64-
try {
65-
await github.rest.issues.removeLabel({
66-
name: 'actions:force-run',
67-
owner: 'GoogleCloudPlatform',
68-
repo: 'nodejs-docs-samples',
69-
issue_number: context.payload.pull_request.number
70-
});
71-
} catch (e) {
72-
if (!e.message.includes('Label does not exist')) {
73-
throw e;
74-
}
75-
}
76-
- if: ${{ github.event_name == 'schedule' && always() }}
77-
run: |
78-
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
79-
chmod +x ./flakybot
80-
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
44+
uses: ./.github/workflows/test.yaml
45+
with:
46+
name: 'functions-http'
47+
path: '${{ matrix.path }}'
48+
remove_label:
49+
if: github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' && always()
50+
uses: ./.github/workflows/remove-label.yaml
51+
flakybot:
52+
if: github.event_name == 'schedule' && always()
53+
uses: ./.github/workflows/flakybot.yaml
54+
needs: [test]

0 commit comments

Comments
 (0)