diff --git a/.github/workflows/opencensus.yaml b/.github/workflows/opencensus.yaml new file mode 100644 index 0000000000..764cd59372 --- /dev/null +++ b/.github/workflows/opencensus.yaml @@ -0,0 +1,66 @@ +name: opencensus +on: + push: + branches: + - main + paths: + - 'opencensus/**' + pull_request: + paths: + - 'opencensus/**' + pull_request_target: + types: [labeled] + schedule: + - cron: '0 2 * * *' +jobs: + opencensus: + 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: opencensus + - run: npm test + working-directory: opencensus + env: + MOCHA_REPORTER_SUITENAME: opencensus + MOCHA_REPORTER_OUTPUT: opencensus_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/.kokoro/opencensus.cfg b/.kokoro/opencensus.cfg deleted file mode 100644 index 844f2bcd80..0000000000 --- a/.kokoro/opencensus.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: "opencensus" -} - -# 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/opencensus/system-test/metrics-quickstart.test.js b/opencensus/system-test/metrics-quickstart.test.js index e706d163f9..0cf16ff0d4 100644 --- a/opencensus/system-test/metrics-quickstart.test.js +++ b/opencensus/system-test/metrics-quickstart.test.js @@ -14,8 +14,8 @@ 'use strict'; -const assert = require('assert'); const childProcess = require('child_process'); +const assert = require('assert'); it('Should throw an error without projectId', async () => { process.env.GOOGLE_PROJECT_ID = '';