Skip to content

Commit 398da55

Browse files
[TEST] test the checks (#25)
* test the checks * fix the changes collection * fix the space issue * fix dependencies issue * improve on cache
1 parent 22aaf76 commit 398da55

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

.github/actions/setup-playwright/action.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ runs:
2828
if: steps.cache-playwright.outputs.cache-hit != 'true'
2929
run: yarn playwright install --with-deps
3030
shell: bash
31+
32+
- name: Ensure system dependencies are installed
33+
if: steps.cache-playwright.outputs.cache-hit == 'true'
34+
run: yarn playwright install-deps
35+
shell: bash

.github/workflows/run-checks-on-pr.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Run checks on PR
22

33
on:
4-
pull_request:
5-
branches: [ main ]
4+
pull_request:
5+
branches: [main]
66

77
concurrency:
88
group: ${{ github.workflow }}-${{ github.ref }}
@@ -21,4 +21,4 @@ jobs:
2121
run-changed-or-added-tests:
2222
uses: ./.github/workflows/run-new-tests-check.yaml
2323
with:
24-
base_ref: ${{ github.base_ref }}
24+
base_ref: ${{ github.base_ref }}

.github/workflows/run-new-tests-check.yaml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
name: Run changed or added tests
22

33
on:
4-
workflow_call:
5-
inputs:
6-
base_ref:
7-
description: 'Base branch to compare against'
8-
required: false
9-
default: 'main'
10-
type: string
11-
workflow_dispatch:
12-
inputs:
13-
base_ref:
14-
description: 'Base branch to compare against'
15-
required: false
16-
default: 'main'
17-
type: string
4+
workflow_call:
5+
inputs:
6+
base_ref:
7+
description: 'Base branch to compare against'
8+
required: false
9+
default: 'main'
10+
type: string
11+
workflow_dispatch:
12+
inputs:
13+
base_ref:
14+
description: 'Base branch to compare against'
15+
required: false
16+
default: 'main'
17+
type: string
1818

1919
jobs:
2020
run-changed-or-added-tests:
@@ -29,7 +29,7 @@ jobs:
2929
uses: actions/checkout@v4
3030
with:
3131
fetch-depth: 0
32-
32+
3333
- name: Set up Node.js and Playwright
3434
uses: ./.github/actions/setup-playwright
3535

@@ -38,8 +38,8 @@ jobs:
3838
run: |
3939
BASE_REF="${{ inputs.base_ref || 'main' }}"
4040
git fetch origin "$BASE_REF"
41-
NEW_TESTS=$(git diff --name-only --diff-filter=ACMR "$BASE_REF"...HEAD -- tests/ || echo '')
42-
41+
NEW_TESTS=$(git diff --name-only --diff-filter=ACMR origin/"$BASE_REF"...HEAD -- tests/ || echo '')
42+
4343
if [ -z "$NEW_TESTS" ]; then
4444
echo "No new or changed tests found"
4545
echo "has_new_tests=false" >> $GITHUB_OUTPUT
@@ -59,16 +59,16 @@ jobs:
5959
if: ${{ steps.find-new-tests.outputs.has_new_tests == 'true' }}
6060
id: list-tests
6161
run: |
62-
TEST_FILES=$(echo "${{ steps.find-new-tests.outputs.new_test_files }}" | tr '\n' ' ')
63-
62+
TEST_FILES=$(echo "${{ steps.find-new-tests.outputs.new_test_files }}" | xargs)
63+
6464
if [ -z "$TEST_FILES" ]; then
6565
echo "No test files to process"
6666
echo "has_new_tests=false" >> $GITHUB_OUTPUT
6767
exit 0
6868
fi
69-
69+
7070
TEST_LIST=$(yarn playwright test --project=${{ matrix.project }} "$TEST_FILES" --list || echo '')
71-
71+
7272
if [ -z "$TEST_LIST" ]; then
7373
echo "No tests found for project ${{ matrix.project }}"
7474
echo "has_new_tests=false" >> $GITHUB_OUTPUT
@@ -90,4 +90,4 @@ jobs:
9090
with:
9191
name: new-tests-results-${{ matrix.project }}-${{ github.run_id }}
9292
path: playwright-report/
93-
retention-days: 7
93+
retention-days: 7

tests/example.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ test('get started link', { tag: ['@smoke', '@regression', '@mobile'] }, async ({
1616
// Expects page to have a heading with the name of Installation.
1717
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
1818
});
19+
20+
test('new test', { tag: ['@new'] }, async ({ page }) => {
21+
await page.goto('https://playwright.dev/');
22+
23+
await expect(page).toHaveTitle(/Playwright/);
24+
});

0 commit comments

Comments
 (0)