From ab1c442105c5bf1bc4e20a0e70bbb1cb01254ae5 Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sat, 15 Nov 2025 23:16:22 +0100 Subject: [PATCH 1/5] test the checks --- .github/workflows/run-checks-on-pr.yaml | 6 ++-- .github/workflows/run-new-tests-check.yaml | 40 +++++++++++----------- tests/example.spec.ts | 6 ++++ 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/run-checks-on-pr.yaml b/.github/workflows/run-checks-on-pr.yaml index 5c0cf12..ebe16b6 100644 --- a/.github/workflows/run-checks-on-pr.yaml +++ b/.github/workflows/run-checks-on-pr.yaml @@ -1,8 +1,8 @@ name: Run checks on PR on: - pull_request: - branches: [ main ] + pull_request: + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -21,4 +21,4 @@ jobs: run-changed-or-added-tests: uses: ./.github/workflows/run-new-tests-check.yaml with: - base_ref: ${{ github.base_ref }} \ No newline at end of file + base_ref: ${{ github.base_ref }} diff --git a/.github/workflows/run-new-tests-check.yaml b/.github/workflows/run-new-tests-check.yaml index dbe148b..c680010 100644 --- a/.github/workflows/run-new-tests-check.yaml +++ b/.github/workflows/run-new-tests-check.yaml @@ -1,20 +1,20 @@ name: Run changed or added tests on: - workflow_call: - inputs: - base_ref: - description: 'Base branch to compare against' - required: false - default: 'main' - type: string - workflow_dispatch: - inputs: - base_ref: - description: 'Base branch to compare against' - required: false - default: 'main' - type: string + workflow_call: + inputs: + base_ref: + description: 'Base branch to compare against' + required: false + default: 'main' + type: string + workflow_dispatch: + inputs: + base_ref: + description: 'Base branch to compare against' + required: false + default: 'main' + type: string jobs: run-changed-or-added-tests: @@ -29,7 +29,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - + - name: Set up Node.js and Playwright uses: ./.github/actions/setup-playwright @@ -39,7 +39,7 @@ jobs: BASE_REF="${{ inputs.base_ref || 'main' }}" git fetch origin "$BASE_REF" NEW_TESTS=$(git diff --name-only --diff-filter=ACMR "$BASE_REF"...HEAD -- tests/ || echo '') - + if [ -z "$NEW_TESTS" ]; then echo "No new or changed tests found" echo "has_new_tests=false" >> $GITHUB_OUTPUT @@ -60,15 +60,15 @@ jobs: id: list-tests run: | TEST_FILES=$(echo "${{ steps.find-new-tests.outputs.new_test_files }}" | tr '\n' ' ') - + if [ -z "$TEST_FILES" ]; then echo "No test files to process" echo "has_new_tests=false" >> $GITHUB_OUTPUT exit 0 fi - + TEST_LIST=$(yarn playwright test --project=${{ matrix.project }} "$TEST_FILES" --list || echo '') - + if [ -z "$TEST_LIST" ]; then echo "No tests found for project ${{ matrix.project }}" echo "has_new_tests=false" >> $GITHUB_OUTPUT @@ -90,4 +90,4 @@ jobs: with: name: new-tests-results-${{ matrix.project }}-${{ github.run_id }} path: playwright-report/ - retention-days: 7 \ No newline at end of file + retention-days: 7 diff --git a/tests/example.spec.ts b/tests/example.spec.ts index fefb4c9..35016c5 100644 --- a/tests/example.spec.ts +++ b/tests/example.spec.ts @@ -16,3 +16,9 @@ test('get started link', { tag: ['@smoke', '@regression', '@mobile'] }, async ({ // Expects page to have a heading with the name of Installation. await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); }); + +test('new test', { tag: ['@new'] }, async ({ page }) => { + await page.goto('https://playwright.dev/'); + + await expect(page).toHaveTitle(/Playwright/); +}); From 8e610d984ccff95f9133ee209aa4f373ac6b1ecf Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sat, 15 Nov 2025 23:21:43 +0100 Subject: [PATCH 2/5] fix the changes collection --- .github/workflows/run-new-tests-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-new-tests-check.yaml b/.github/workflows/run-new-tests-check.yaml index c680010..88b8b48 100644 --- a/.github/workflows/run-new-tests-check.yaml +++ b/.github/workflows/run-new-tests-check.yaml @@ -38,7 +38,7 @@ jobs: run: | BASE_REF="${{ inputs.base_ref || 'main' }}" git fetch origin "$BASE_REF" - NEW_TESTS=$(git diff --name-only --diff-filter=ACMR "$BASE_REF"...HEAD -- tests/ || echo '') + NEW_TESTS=$(git diff --name-only --diff-filter=ACMR origin/"$BASE_REF"...HEAD -- tests/ || echo '') if [ -z "$NEW_TESTS" ]; then echo "No new or changed tests found" From 55f49a2e46489388f7623159e9efb8a25d958abc Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sat, 15 Nov 2025 23:31:17 +0100 Subject: [PATCH 3/5] fix the space issue --- .github/workflows/run-new-tests-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-new-tests-check.yaml b/.github/workflows/run-new-tests-check.yaml index 88b8b48..b976dc3 100644 --- a/.github/workflows/run-new-tests-check.yaml +++ b/.github/workflows/run-new-tests-check.yaml @@ -59,7 +59,7 @@ jobs: if: ${{ steps.find-new-tests.outputs.has_new_tests == 'true' }} id: list-tests run: | - TEST_FILES=$(echo "${{ steps.find-new-tests.outputs.new_test_files }}" | tr '\n' ' ') + TEST_FILES=$(echo "${{ steps.find-new-tests.outputs.new_test_files }}" | xargs) if [ -z "$TEST_FILES" ]; then echo "No test files to process" From 4aef040d358fcd8eb596cc5c8df6f3d24930c8b6 Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sat, 15 Nov 2025 23:39:47 +0100 Subject: [PATCH 4/5] fix dependencies issue --- .github/actions/setup-playwright/action.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/setup-playwright/action.yaml b/.github/actions/setup-playwright/action.yaml index df2f1bf..b88fabc 100644 --- a/.github/actions/setup-playwright/action.yaml +++ b/.github/actions/setup-playwright/action.yaml @@ -28,3 +28,7 @@ runs: if: steps.cache-playwright.outputs.cache-hit != 'true' run: yarn playwright install --with-deps shell: bash + + - name: Ensure system dependencies are installed + run: yarn playwright install-deps + shell: bash \ No newline at end of file From 141754093251efabba22f80e845290dcc6d43ce1 Mon Sep 17 00:00:00 2001 From: Daria Domina Date: Sat, 15 Nov 2025 23:42:52 +0100 Subject: [PATCH 5/5] improve on cache --- .github/actions/setup-playwright/action.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-playwright/action.yaml b/.github/actions/setup-playwright/action.yaml index b88fabc..1aeec63 100644 --- a/.github/actions/setup-playwright/action.yaml +++ b/.github/actions/setup-playwright/action.yaml @@ -30,5 +30,6 @@ runs: shell: bash - name: Ensure system dependencies are installed + if: steps.cache-playwright.outputs.cache-hit == 'true' run: yarn playwright install-deps - shell: bash \ No newline at end of file + shell: bash