diff --git a/.github/full-parallel-prod.yml b/.github/full-parallel-prod.yml deleted file mode 100644 index 7ba0baf..0000000 --- a/.github/full-parallel-prod.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: demo.playwright.pwc.prod -on: - workflow_dispatch: - pull_request: - branches: [main] - push: - branches: [main] -jobs: - basicTests: - strategy: - fail-fast: false - matrix: - shard: [1, 2, 3, 4, 5] - name: "PW tests" - timeout-minutes: 60 - runs-on: ubuntu-22.04 - container: mcr.microsoft.com/playwright:latest - env: - TESTGROUP: basic - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - # https://github.com/actions/runner-images/issues/6775 - - run: | - echo "$GITHUB_WORKSPACE" - git config --global --add safe.directory "$GITHUB_WORKSPACE" - - - uses: actions/setup-node@v4 - with: - node-version: "18.x" - - - name: Install dependencies - run: | - npm ci - npx playwright install chrome - - - name: Run Basic Tests - Project A - continue-on-error: true - working-directory: ${{ env.TESTGROUP }} - env: - CURRENTS_PROJECT_ID: bnsqNa - CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }} - run: | - npx pwc --project a --shard=${{ matrix.shard }}/${{ strategy.job-total }} --ci-build-id "${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}" - - - name: Run Basic Tests - Project B - continue-on-error: true - working-directory: ${{ env.TESTGROUP }} - env: - CURRENTS_PROJECT_ID: bnsqNa - CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }} - run: | - npx pwc --project b --shard=${{ matrix.shard }}/${{ strategy.job-total }} --ci-build-id "${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}" diff --git a/.github/workflows/rerun-shards-pwc.yml b/.github/workflows/rerun-shards-pwc.yml index 4005b87..3ea7102 100644 --- a/.github/workflows/rerun-shards-pwc.yml +++ b/.github/workflows/rerun-shards-pwc.yml @@ -1,4 +1,4 @@ -name: demo.playwright.failed-only-shards +name: failed-only-shards on: workflow_dispatch: @@ -35,8 +35,8 @@ jobs: npx playwright install chrome npm install -g @currents/cmd@beta - name: Load last run from cache - env: - DEBUG: "currents,currents:*" + # env: + # DEBUG: "currents,currents:*" run: | npx currents cache get \ --preset last-run \ @@ -56,9 +56,10 @@ jobs: # env: # DEBUG: "currents,currents:*" if: ${{ always() }} + # --pw-output-dir is the directory where the test results are stored run: | npx currents cache set \ --preset last-run \ - --pw-output-dir basic/test-results \ # This is the directory where the test results are stored + --pw-output-dir basic/test-results \ --matrix-index ${{ matrix.shard }} \ --matrix-total ${{ strategy.job-total }} diff --git a/.github/workflows/rerun-shards-reporter.yml b/.github/workflows/rerun-shards-reporter.yml new file mode 100644 index 0000000..a7bbc0c --- /dev/null +++ b/.github/workflows/rerun-shards-reporter.yml @@ -0,0 +1,65 @@ +name: failed-only-reporter + +on: + push: + +jobs: + test-reporter: + strategy: + fail-fast: false + matrix: + shard: [1, 2, 3] + timeout-minutes: 60 + runs-on: ubuntu-latest + container: mcr.microsoft.com/playwright:latest + env: + CURRENTS_PROJECT_ID: bnsqNa + CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }} + CURRENTS_CI_BUILD_ID: reporter-${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }} + CURRENTS_API_URL: ${{ secrets.CURRENTS_API_URL }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + + # https://github.com/actions/runner-images/issues/6775 + - run: | + echo "$GITHUB_WORKSPACE" + git config --global --add safe.directory "$GITHUB_WORKSPACE" + - uses: actions/setup-node@v4 + with: + node-version: "20.x" + + - name: Install dependencies + run: | + npm ci + npx playwright install chrome + npm install -g @currents/cmd@beta + + - name: Load last run from cache + # env: + # DEBUG: "currents,currents:*" + run: | + npx currents cache get \ + --preset last-run \ + --preset-output .preset_output \ + --matrix-index ${{ matrix.shard }} \ + --matrix-total ${{ strategy.job-total }} + echo "EXTRA_PW_FLAGS=$(cat .preset_output)" >> $GITHUB_ENV + + - name: Playwright Tests + working-directory: ./basic + run: | + COMMAND="npx playwright test --config playwright.config.reporter.ts $EXTRA_PW_FLAGS" + echo "Running command: $COMMAND" + $COMMAND + - name: Cache the last run results + # env: + # DEBUG: "currents,currents:*" + if: ${{ always() }} + run: | + npx currents cache set \ + --preset last-run \ + --pw-output-dir basic/test-results \ + --matrix-index ${{ matrix.shard }} \ + --matrix-total ${{ strategy.job-total }} diff --git a/.github/workflows/reruns-or8n.yml b/.github/workflows/reruns-or8n.yml new file mode 100644 index 0000000..ce20734 --- /dev/null +++ b/.github/workflows/reruns-or8n.yml @@ -0,0 +1,56 @@ +name: failed-only-or8n + +on: + push: + +jobs: + test-or8n: + strategy: + fail-fast: false + matrix: + shard: [1, 2, 3] + timeout-minutes: 60 + runs-on: ubuntu-latest + container: mcr.microsoft.com/playwright:latest + env: + CURRENTS_PROJECT_ID: bnsqNa + CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }} + CURRENTS_CI_BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }} + CURRENTS_API_KEY: ${{ secrets.CURRENTS_API_KEY }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + + # https://github.com/actions/runner-images/issues/6775 + - run: | + echo "$GITHUB_WORKSPACE" + git config --global --add safe.directory "$GITHUB_WORKSPACE" + - uses: actions/setup-node@v4 + with: + node-version: "20.x" + + - name: Install dependencies + run: | + npm ci + npx playwright install chrome + npm install -g @currents/cmd@beta + - name: Resolve Playwright options + # --output basic/test-results/.last-run.json should point to the directory where the test results are stored + run: | + PREVIOUS_CI_BUILD_ID="${GITHUB_REPOSITORY}-${GITHUB_RUN_ID}-$((GITHUB_RUN_ATTEMPT - 1))" + EXTRA_PW_FLAGS="" + if [ ${{ github.run_attempt }} -gt 1 ]; then + if npx currents api get-run --pw-last-run --ci-build-id + $PREVIOUS_CI_BUILD_ID --output basic/test-results/.last-run.json; then + EXTRA_PW_FLAGS="--last-failed" + fi + fi + echo "EXTRA_PW_FLAGS=$EXTRA_PW_FLAGS" >> $GITHUB_ENV + + - name: Playwright Tests + working-directory: ./basic + run: | + COMMAND="npx pwc-p ${{ env.EXTRA_PW_FLAGS }}" + echo "Running command: $COMMAND" + eval $COMMAND diff --git a/README.md b/README.md index 9238bd7..daed39a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,12 @@ Examples of various variants of integrating Currents with Playwright on GitHub A - [argos-example.yml](.github/workflows/argos-example.yml) - parallel run using Argos CI and Currents orchestration. +### Reruns only the failed tests + +- [rerun-shards-pwc.yml](.github/workflows/rerun-shards-pwc.yml) - rerun only the tests that failed in the previous run, using `pwc` helper command that is included in `@currents/playwright` package. +- [rerun-shards-reporter.yml](.github/workflows/rerun-shards-reporter.yml) - rerun only the tests that failed in the previous run, using reporter explicitly configured in `playwright.config.ts` +- [reruns-or8n.yml](.github/workflows/reruns-or8n.yml) - rerun only the tests that failed in the previous orchestrated run + ## Additional resources - Playwright Features on Currents: https://currents.dev/playwright diff --git a/basic/2-actions.spec.ts b/basic/2-actions.spec.ts index 56d377b..c41d9b3 100644 --- a/basic/2-actions.spec.ts +++ b/basic/2-actions.spec.ts @@ -12,7 +12,7 @@ test.beforeEach(async ({ page }) => { * by the completed items to ensure that the item is not visible anymore. * @see https://playwright.dev/docs/api/class-locator */ -test("basic interaction @basic", async ({ page }, testInfo) => { +test.skip("basic interaction @basic", async ({ page }, testInfo) => { const inputBox = page.locator("input.new-todo"); const todoList = page.locator(".todo-list"); @@ -33,7 +33,7 @@ test("basic interaction @basic", async ({ page }, testInfo) => { * Playwright supports different selector engines which you can combine with '>>'. * @see https://playwright.dev/docs/selectors */ -test("element selectors @basic", async ({ page }) => { +test.skip("element selectors @basic", async ({ page }) => { // When no selector engine is specified, Playwright will use the css selector engine. await page.type(".header input", "Learn Playwright"); // So the selector above is the same as the following: diff --git a/basic/3-assertions.spec.ts b/basic/3-assertions.spec.ts index 1f23194..e2013a7 100644 --- a/basic/3-assertions.spec.ts +++ b/basic/3-assertions.spec.ts @@ -10,7 +10,7 @@ test.beforeEach(async ({ page }) => { */ test("should be able to use assertions", async ({ page }) => { await test.step("toHaveTitle/toHaveURL", async () => { - await expect(page).toHaveTitle("Vanilla ES6 • TodoMVC"); + await expect(page).toHaveTitle("TodoMVC: Backbone"); await expect(page).toHaveURL("https://todomvc.com/examples/backbone/dist/"); });