From b415a1a85dcf4649b689a46a1041e5286c9284cc Mon Sep 17 00:00:00 2001 From: Jack Wotherspoon Date: Wed, 24 May 2023 17:33:20 -0400 Subject: [PATCH] ci: setup Flakybot to monitor tests (#127) --- .github/workflows/tests.yml | 65 +++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1452720..8c6bba0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,6 +49,8 @@ jobs: run: shell: ${{ matrix.platform.shell }} permissions: + contents: read + id-token: write issues: write pull-requests: write @@ -78,6 +80,15 @@ jobs: with: node-version: ${{ matrix.node-version }} + - id: 'auth' + name: Authenticate to Google Cloud + if: ${{ github.event_name == 'schedule' || github.event_name == 'push' }} + uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1 + with: + workload_identity_provider: ${{ secrets.PROVIDER_NAME }} + service_account: ${{ secrets.SERVICE_ACCOUNT }} + access_token_lifetime: 600s + - name: Install dependencies run: npm install @@ -85,9 +96,34 @@ jobs: run: npm run prepare - name: Run Tests - run: npx c8 tap -c -t0 + run: npx c8 tap -c -t0 -o test_results.tap timeout-minutes: 5 + - name: Convert test output to XML + if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && always() }} + run: cat test_results.tap | npx tap - --reporter=xunit > sponge_log.xml + + - name: FlakyBot (Linux) + # only run flakybot on periodic (schedule) and continuous (push) events + if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Linux' && always() }} + 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 ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} + - name: FlakyBot (Windows) + # only run flakybot on periodic (schedule) and continuous (push) events + if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Windows' && always() }} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot.exe -o flakybot.exe -s -L + ./flakybot.exe --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} + - name: FlakyBot (macOS) + # only run flakybot on periodic (schedule) and continuous (push) events + if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'macOS' && always() }} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot-darwin-amd64 -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} + system-tests: # run job on proper workflow event triggers (skip job for pull_request event from forks and only run pull_request_target for "tests: run" label) if: "${{ (github.event.action != 'labeled' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) || github.event.label.name == 'tests: run' }}" @@ -197,5 +233,30 @@ jobs: SQLSERVER_USER: '${{ steps.secrets.outputs.SQLSERVER_USER }}' SQLSERVER_PASS: '${{ steps.secrets.outputs.SQLSERVER_PASS }}' SQLSERVER_DB: '${{ steps.secrets.outputs.SQLSERVER_DB }}' - run: npx tap -c -t0 --no-coverage system-test + run: npx tap -c -t0 --no-coverage system-test -o test_results.tap timeout-minutes: 5 + + - name: Convert test output to XML + if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && always() }} + run: cat test_results.tap | npx tap - --reporter=xunit > sponge_log.xml + + - name: FlakyBot (Linux) + # only run flakybot on periodic (schedule) and continuous (push) events + if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Linux' && always() }} + 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 ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} + - name: FlakyBot (Windows) + # only run flakybot on periodic (schedule) and continuous (push) events + if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'Windows' && always() }} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot.exe -o flakybot.exe -s -L + ./flakybot.exe --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} + - name: FlakyBot (macOS) + # only run flakybot on periodic (schedule) and continuous (push) events + if: ${{ (github.event_name == 'schedule' || github.event_name == 'push') && runner.os == 'macOS' && always() }} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot-darwin-amd64 -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo ${{github.repository}} --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}