From d1d56a7176d408d4631ced6c36a49dfdedd53347 Mon Sep 17 00:00:00 2001 From: platane Date: Sat, 16 Mar 2024 07:29:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/_test-e2e.yml | 51 ++++++++++++++++++++---- .github/workflows/main.yml | 6 ++- .github/workflows/publish-production.yml | 1 + .github/workflows/recuring-live-test.yml | 26 ++++++++++-- 4 files changed, 73 insertions(+), 11 deletions(-) diff --git a/.github/workflows/_test-e2e.yml b/.github/workflows/_test-e2e.yml index 1ef7208..72e4cb9 100644 --- a/.github/workflows/_test-e2e.yml +++ b/.github/workflows/_test-e2e.yml @@ -6,6 +6,13 @@ on: APP_URL: type: string required: true + outputs: + report_url: + description: "Url to the uploaded html report" + value: ${{ jobs.collect-report.outputs.report_url }} + secrets: + CLOUDFLARE_ACCOUNT_ID: + CLOUDFLARE_PUBLISH_TOKEN: jobs: e2e: @@ -13,9 +20,11 @@ jobs: strategy: fail-fast: false matrix: - shard: ["1/1"] - browser: [chromium] # browser: [chromium, firefox, webkit] + browser: [chromium] + shardIndex: [1] + env: + shardTotal: 1 steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 @@ -39,15 +48,43 @@ jobs: - run: | bunx playwright test \ --project ${{ matrix.browser }} \ - --shard ${{ matrix.shard }} \ - --reporter github \ + --shard ${{ matrix.shardIndex }}/${{ env.shardTotal }} \ + --reporter github,blob \ --forbid-only \ --workers 1 working-directory: packages/e2e env: APP_URL: ${{ inputs.APP_URL }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 + if: always() + with: + name: e2e-blob-report-${{ matrix.browser }}-${{ matrix.shardIndex }} + path: packages/e2e/blob-report + retention-days: 1 + + collect-report: + runs-on: ubuntu-latest + needs: [e2e] + if: failure() + outputs: + report_url: ${{ steps.report-upload.outputs.url }} + steps: + - uses: actions/download-artifact@v4 with: - name: playwright-screenshots-${{ matrix.browser }} - path: packages/e2e/playwright-screenshots + path: blob-report + pattern: e2e-blob-report-* + merge-multiple: true + + - uses: oven-sh/setup-bun@v1 + + - name: upload html report + id: report-upload + run: | + bunx playwright merge-reports --reporter html blob-report + bunx wrangler pages deploy playwright-report --project-name=timezone-rocks --branch=test-report | tee deploy_log.txt + URL=`cat deploy_out.txt | grep -Eo "https://[^ ]*"` + echo url=$URL >> "$GITHUB_OUTPUT" + env: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_PUBLISH_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aeec415..21954b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,9 @@ name: main -on: [push] +on: + push: + paths: + - "**" jobs: main: @@ -41,3 +44,4 @@ jobs: uses: ./.github/workflows/_test-e2e.yml with: APP_URL: ${{ needs.main.outputs.published_url }} + secrets: inherit diff --git a/.github/workflows/publish-production.yml b/.github/workflows/publish-production.yml index 3916381..9ca5a05 100644 --- a/.github/workflows/publish-production.yml +++ b/.github/workflows/publish-production.yml @@ -35,3 +35,4 @@ jobs: uses: ./.github/workflows/_test-e2e.yml with: APP_URL: "https://timezone.rocks" + secrets: inherit diff --git a/.github/workflows/recuring-live-test.yml b/.github/workflows/recuring-live-test.yml index 5edb5e5..a40091a 100644 --- a/.github/workflows/recuring-live-test.yml +++ b/.github/workflows/recuring-live-test.yml @@ -1,14 +1,34 @@ name: Recuring live test on: - deployment_status: schedule: - - cron: "0 12 * * *" + - cron: "0 12 */3 * *" workflow_dispatch: + inputs: + app_url: + type: string + description: url to test + default: https://timezone.rocks + required: true jobs: e2e: uses: ./.github/workflows/_test-e2e.yml with: - APP_URL: "https://timezone.rocks" + APP_URL: ${{ inputs.app_url || 'https://timezone.rocks' }} + secrets: inherit + + notify: + runs-on: ubuntu-latest + needs: [e2e] + if: failure() + steps: + - name: Leave comment with the report + # if: github.event_name == 'schedule' + run: | + BODY="🚨 e2e test failed [report](${{ needs.e2e.outputs.report_url }}) [run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) [app](${{ inputs.app_url || 'https://timezone.rocks' }})" + gh issue comment 15 --body $BODY + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }}