Skip to content

Commit e0ae581

Browse files
test(endpoints): migrate to github actions (GoogleCloudPlatform#2459)
1 parent d665627 commit e0ae581

7 files changed

Lines changed: 136 additions & 26 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: endpoints-getting-started-grpc
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'endpoints/getting-started-grpc/**'
8+
pull_request:
9+
paths:
10+
- 'endpoints/getting-started-grpc/**'
11+
pull_request_target:
12+
types: [labeled]
13+
schedule:
14+
- cron: '0 2 * * *'
15+
jobs:
16+
test:
17+
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: 'write'
21+
pull-requests: 'write'
22+
id-token: 'write'
23+
steps:
24+
- uses: 'google-github-actions/auth@v0.3.1'
25+
with:
26+
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
27+
service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com'
28+
create_credentials_file: 'true'
29+
access_token_lifetime: 600s
30+
- uses: actions/checkout@v2
31+
with:
32+
ref: ${{github.event.pull_request.head.ref}}
33+
repository: ${{github.event.pull_request.head.repo.full_name}}
34+
- uses: actions/setup-node@v2
35+
with:
36+
node-version: 14
37+
- run: npm install
38+
working-directory: endpoints/getting-started-grpc
39+
- run: npm test
40+
working-directory: endpoints/getting-started-grpc
41+
env:
42+
MOCHA_REPORTER_SUITENAME: endpoints_getting_started_grpc
43+
MOCHA_REPORTER_OUTPUT: endpoints_getting_started_grpc_sponge_log.xml
44+
MOCHA_REPORTER: xunit
45+
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
46+
uses: actions/github-script@v5
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
script: |
50+
try {
51+
await github.rest.issues.removeLabel({
52+
name: 'actions:force-run',
53+
owner: 'GoogleCloudPlatform',
54+
repo: 'nodejs-docs-samples',
55+
issue_number: context.payload.pull_request.number
56+
});
57+
} catch (e) {
58+
if (!e.message.includes('Label does not exist')) {
59+
throw e;
60+
}
61+
}
62+
- if: ${{ github.event_name == 'schedule'}}
63+
run: |
64+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
65+
chmod +x ./flakybot
66+
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: endpoints-getting-started
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'endpoints/getting-started/**'
8+
pull_request:
9+
paths:
10+
- 'endpoints/getting-started/**'
11+
pull_request_target:
12+
types: [labeled]
13+
schedule:
14+
- cron: '0 2 * * *'
15+
jobs:
16+
test:
17+
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: 'write'
21+
pull-requests: 'write'
22+
id-token: 'write'
23+
steps:
24+
- uses: 'google-github-actions/auth@v0.3.1'
25+
with:
26+
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
27+
service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com'
28+
create_credentials_file: 'true'
29+
access_token_lifetime: 600s
30+
- uses: actions/checkout@v2
31+
with:
32+
ref: ${{github.event.pull_request.head.ref}}
33+
repository: ${{github.event.pull_request.head.repo.full_name}}
34+
- uses: actions/setup-node@v2
35+
with:
36+
node-version: 14
37+
- run: npm install
38+
working-directory: endpoints/getting-started
39+
- run: npm test
40+
working-directory: endpoints/getting-started
41+
env:
42+
MOCHA_REPORTER_SUITENAME: endpoints_getting_started
43+
MOCHA_REPORTER_OUTPUT: endpoints_getting_started_sponge_log.xml
44+
MOCHA_REPORTER: xunit
45+
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
46+
uses: actions/github-script@v5
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
script: |
50+
try {
51+
await github.rest.issues.removeLabel({
52+
name: 'actions:force-run',
53+
owner: 'GoogleCloudPlatform',
54+
repo: 'nodejs-docs-samples',
55+
issue_number: context.payload.pull_request.number
56+
});
57+
} catch (e) {
58+
if (!e.message.includes('Label does not exist')) {
59+
throw e;
60+
}
61+
}
62+
- if: ${{ github.event_name == 'schedule'}}
63+
run: |
64+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
65+
chmod +x ./flakybot
66+
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}

.github/workflows/workflows.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"cloud-tasks/function",
44
"composer",
55
"composer/functions/composer-storage-trigger",
6+
"endpoints/getting-started",
7+
"endpoints/getting-started-grpc",
68
"healthcare/datasets",
79
"healthcare/dicom",
810
"healthcare/fhir",

.kokoro/endpoints-getting-started-grpc.cfg

Lines changed: 0 additions & 13 deletions
This file was deleted.

.kokoro/endpoints-getting-started.cfg

Lines changed: 0 additions & 13 deletions
This file was deleted.

endpoints/getting-started-grpc/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@
2828
"wait-port": "^0.2.7"
2929
}
3030
}
31+

endpoints/getting-started/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
"supertest": "^6.0.0"
2727
}
2828
}
29+

0 commit comments

Comments
 (0)