diff --git a/.github/workflows/functions-slack.yaml b/.github/workflows/functions-slack.yaml new file mode 100644 index 0000000000..3298211556 --- /dev/null +++ b/.github/workflows/functions-slack.yaml @@ -0,0 +1,66 @@ +name: functions-slack +on: + push: + branches: + - main + paths: + - 'functions/slack/**' + pull_request: + paths: + - 'functions/slack/**' + 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: functions/slack + - run: npm test + working-directory: functions/slack + env: + MOCHA_REPORTER_SUITENAME: functions_slack + MOCHA_REPORTER_OUTPUT: functions_slack_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 7515222c49..053058b8ab 100644 --- a/.github/workflows/workflows.json +++ b/.github/workflows/workflows.json @@ -25,6 +25,7 @@ "endpoints/getting-started-grpc", "functions/security", "functions/firebase", + "functions/slack", "healthcare/datasets", "healthcare/dicom", "healthcare/fhir", diff --git a/.kokoro/functions/slack.cfg b/.kokoro/functions/slack.cfg deleted file mode 100644 index 7425aac9ba..0000000000 --- a/.kokoro/functions/slack.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Set the folder in which the tests are run -env_vars: { - key: "PROJECT" - value: "functions/slack" -} - -# Tell the trampoline which build file to use. -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-docs-samples/.kokoro/build.sh" -} diff --git a/functions/slack/test/index.test.js b/functions/slack/test/index.test.js index 5a3bb8ef4c..bf04c94d2f 100644 --- a/functions/slack/test/index.test.js +++ b/functions/slack/test/index.test.js @@ -14,8 +14,8 @@ 'use strict'; -const proxyquire = require('proxyquire').noCallThru(); const sinon = require('sinon'); +const proxyquire = require('proxyquire').noCallThru(); const assert = require('assert'); const method = 'POST';