Skip to content

Commit 5cb0af4

Browse files
committed
feat(ci): add E2E test action and integrate into CI workflow
1 parent 2b1839c commit 5cb0af4

2 files changed

Lines changed: 61 additions & 83 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: E2E Tests
2+
description: Run E2E tests
3+
4+
inputs:
5+
test_tags:
6+
description: 'Tags to filter tests'
7+
required: true
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: lts/*
15+
16+
- name: 📦 Install dependencies
17+
shell: bash
18+
run: npm ci
19+
working-directory: tests
20+
21+
- name: 📦🌐 Install Playwright dependencies
22+
shell: bash
23+
run: npx playwright install --with-deps
24+
25+
- name: 🎭 Run tests
26+
shell: bash
27+
run: npx playwright test --grep "${{ inputs.test_tags }}"
28+
working-directory: tests
29+
30+
- name: 📤 Upload Playwright report
31+
uses: actions/upload-artifact@v4.3.1
32+
if: always()
33+
with:
34+
name: playwright-report-${{ github.job }}
35+
path: playwright-report/
36+
retention-days: 14

.github/workflows/ci.yml

Lines changed: 25 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -19,101 +19,43 @@ jobs:
1919
critical-test-run:
2020
timeout-minutes: 60
2121
runs-on: ubuntu-latest
22-
strategy:
23-
fail-fast: false
24-
matrix:
25-
browsers: ['chromium']
26-
greps: ['@LOGIN', '@SIGN_UP', '@SANITY', '@MEN_CATEGORY_SHOP']
22+
if: ${{ !cancelled() }}
2723
steps:
28-
- uses: actions/checkout@v4
29-
- uses: actions/setup-node@v4
30-
with:
31-
node-version: lts/*
32-
- name: Install dependencies
33-
run: npm ci
34-
- name: Install Playwright Browsers
35-
run: npx playwright install --with-deps
36-
- name: Run Playwright tests
37-
run: BASE_URL=${{ env.BASE_URL }} npx playwright test --grep ${{ matrix.greps }} --project=${{ matrix.browsers }}
38-
- uses: actions/upload-artifact@v4
39-
if: always()
40-
with:
41-
name: playwright-report-${{ github.job }}
42-
path: playwright-report/
43-
retention-days: 30
44-
- name: Deploy Playwright report to GitHub Pages
45-
uses: peaceiris/actions-gh-pages@v3
46-
with:
47-
github_token: ${{ secrets.GITHUB_TOKEN }}
48-
publish_dir: playwright-report/
24+
- name: Checkout code
25+
uses: actions/checkout@v2
26+
27+
- name: run critical tests
28+
uses: ./.github/actions/e2e-tests
29+
with:
30+
test_tags: '@LOGIN|@SIGN_UP'
4931

5032
regression-test-run:
5133
timeout-minutes: 60
5234
runs-on: ubuntu-latest
53-
needs: critical-test-run
5435
if: ${{ !cancelled() }}
55-
strategy:
56-
fail-fast: false
57-
matrix:
58-
browsers: ['chromium']
59-
greps: ['@LOGIN', '@SIGN_UP', '@SANITY', '@MEN_CATEGORY_SHOP']
6036
steps:
61-
- uses: actions/checkout@v4
62-
- uses: actions/setup-node@v4
63-
with:
64-
node-version: lts/*
65-
- name: Install dependencies
66-
run: npm ci
67-
- name: Install Playwright Browsers
68-
run: npx playwright install --with-deps
69-
- name: Run Playwright tests
70-
run: BASE_URL=${{ env.BASE_URL }} npx playwright test --grep ${{ matrix.greps }} --project=${{ matrix.browsers }}
71-
- uses: actions/upload-artifact@v4
72-
if: always()
73-
with:
74-
name: playwright-report-${{ github.job }}
75-
path: playwright-report/
76-
retention-days: 30
77-
- name: Deploy Playwright report to GitHub Pages
78-
uses: peaceiris/actions-gh-pages@v3
79-
with:
80-
github_token: ${{ secrets.GITHUB_TOKEN }}
81-
publish_dir: playwright-report/
37+
- name: Checkout code
38+
uses: actions/checkout@v2
39+
40+
- name: run regression tests
41+
uses: ./.github/actions/e2e-tests
42+
with:
43+
test_tags: '@LOGIN|@SIGN_UP'
8244

8345
sanity-test-run:
8446
timeout-minutes: 60
8547
runs-on: ubuntu-latest
86-
needs:
87-
- critical-test-run
88-
- regression-test-run
8948
if: ${{ !cancelled() }}
90-
strategy:
91-
fail-fast: false
92-
matrix:
93-
browsers: ['chromium']
94-
greps: ['@LOGIN', '@SIGN_UP', '@SANITY', '@MEN_CATEGORY_SHOP']
9549
steps:
96-
- uses: actions/checkout@v4
97-
- uses: actions/setup-node@v4
98-
with:
99-
node-version: lts/*
100-
- name: Install dependencies
101-
run: npm ci
102-
- name: Install Playwright Browsers
103-
run: npx playwright install --with-deps
104-
- name: Run Playwright tests
105-
run: BASE_URL=${{ env.BASE_URL }} npx playwright test --grep ${{ matrix.greps }} --project=${{ matrix.browsers }}
106-
- uses: actions/upload-artifact@v4
107-
if: always()
108-
with:
109-
name: playwright-report-${{ github.job }}
110-
path: playwright-report/
111-
retention-days: 30
112-
- name: Deploy Playwright report to GitHub Pages
113-
uses: peaceiris/actions-gh-pages@v3
114-
with:
115-
github_token: ${{ secrets.GITHUB_TOKEN }}
116-
publish_dir: playwright-report/
50+
- name: Checkout code
51+
uses: actions/checkout@v2
52+
53+
- name: run sanity tests
54+
uses: ./.github/actions/e2e-tests
55+
with:
56+
test_tags: '@LOGIN|@SIGN_UP'
57+
58+
11759

11860
# status_checks:
11961
# name: E2E status checks
@@ -132,7 +74,7 @@ jobs:
13274
# - name: set pr status checks
13375
# uses: teamniteo/pull_request_status_action@v1.0.0
13476
# with:
135-
# pr_number: ${{ github.event.pull_request.number }}
77+
# pr_number: ${{ github }}
13678
# state: ${{ steps.status-check-status.outputs.status }}
13779
# repository: Romarionijim/Playwright-TypeScript-Mini-Project
13880
# env:

0 commit comments

Comments
 (0)