From 183cdf5ff79e345c5567623a0e117ab89564e567 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Thu, 3 Feb 2022 16:36:12 -0800 Subject: [PATCH] build: move run/imageprocessing to GH Actions --- .github/workflows/run-image-processing.yaml | 66 +++++++++++++++++++++ .github/workflows/workflows.json | 3 +- .kokoro/run/image-processing.cfg | 7 --- run/image-processing/test/system.test.js | 2 +- 4 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/run-image-processing.yaml delete mode 100644 .kokoro/run/image-processing.cfg diff --git a/.github/workflows/run-image-processing.yaml b/.github/workflows/run-image-processing.yaml new file mode 100644 index 0000000000..6553b0ef68 --- /dev/null +++ b/.github/workflows/run-image-processing.yaml @@ -0,0 +1,66 @@ +name: run-image-processing +on: + push: + branches: + - main + paths: + - 'run/image-processing/**' + pull_request: + paths: + - 'run/image-processing/**' + pull_request_target: + types: [labeled] + schedule: + - cron: '0 2 * * *' +jobs: + test: + if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} + runs-on: ubuntu-latest + permissions: + contents: 'write' + pull-requests: 'write' + id-token: 'write' + steps: + - uses: 'google-github-actions/auth@v0.3.1' + with: + workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' + service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' + access_token_lifetime: 600s + - uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: actions/setup-node@v2 + with: + node-version: 14 + - run: npm install + working-directory: run/image-processing + - run: npm test + working-directory: run/image-processing + env: + MOCHA_REPORTER_SUITENAME: run_image_processing + MOCHA_REPORTER_OUTPUT: run_image_processing_sponge_log.xml + MOCHA_REPORTER: xunit + - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.issues.removeLabel({ + name: 'actions:force-run', + owner: 'GoogleCloudPlatform', + repo: 'nodejs-docs-samples', + issue_number: context.payload.pull_request.number + }); + } catch (e) { + if (!e.message.includes('Label does not exist')) { + throw e; + } + } + - if: ${{ github.event_name == 'schedule'}} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/.github/workflows/workflows.json b/.github/workflows/workflows.json index 166b620eea..8c07598c64 100644 --- a/.github/workflows/workflows.json +++ b/.github/workflows/workflows.json @@ -13,5 +13,6 @@ "monitoring/opencensus", "monitoring/prometheus", "datacatalog/cloud-client", - "datacatalog/quickstart" + "datacatalog/quickstart", + "run/image-processing" ] diff --git a/.kokoro/run/image-processing.cfg b/.kokoro/run/image-processing.cfg deleted file mode 100644 index 32ec554b93..0000000000 --- a/.kokoro/run/image-processing.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Set the folder in which the tests are run -env_vars: { - key: "PROJECT" - value: "run/image-processing" -} diff --git a/run/image-processing/test/system.test.js b/run/image-processing/test/system.test.js index 66b126b99e..aeeb818ec3 100644 --- a/run/image-processing/test/system.test.js +++ b/run/image-processing/test/system.test.js @@ -13,8 +13,8 @@ // limitations under the License. const assert = require('assert'); -const got = require('got'); const {execSync} = require('child_process'); +const got = require('got'); const {GoogleAuth} = require('google-auth-library'); const auth = new GoogleAuth();