Skip to content

Commit d82f269

Browse files
sofislTakashi Matsuo
andauthored
build: move run/pubsub to GH Actions (GoogleCloudPlatform#2527)
Co-authored-by: Takashi Matsuo <tmatsuo@google.com>
1 parent 9617042 commit d82f269

File tree

5 files changed

+69
-9
lines changed

5 files changed

+69
-9
lines changed

.github/workflows/run-pubsub.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: run-pubsub
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'run/pubsub/**'
8+
pull_request:
9+
paths:
10+
- 'run/pubsub/**'
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: run/pubsub
39+
- run: npm test
40+
working-directory: run/pubsub
41+
env:
42+
MOCHA_REPORTER_SUITENAME: run_pubsub
43+
MOCHA_REPORTER_OUTPUT: run_pubsub_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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@
4444
"run/helloworld",
4545
"run/image-processing",
4646
"run/idp-sql",
47+
"run/pubsub",
4748
"run/system-package"
4849
]

.kokoro/run/pubsub.cfg

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

run/pubsub/test/app.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
const assert = require('assert');
2222
const path = require('path');
2323
const supertest = require('supertest');
24-
const sinon = require('sinon');
2524
const uuid = require('uuid');
25+
const sinon = require('sinon');
2626

2727
let request;
2828

run/pubsub/test/system.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
const assert = require('assert');
1616
const got = require('got');
17+
const auth = new GoogleAuth();
1718
const {execSync} = require('child_process');
1819
const {GoogleAuth} = require('google-auth-library');
19-
const auth = new GoogleAuth();
2020

2121
let BASE_URL, ID_TOKEN;
2222
describe('End-to-End Tests', () => {

0 commit comments

Comments
 (0)