-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (82 loc) · 2.74 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: CI
on:
pull_request:
push:
branches: main
jobs:
lint-staged:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: node_modules
key: Linux-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Run lint-staged (PR update)
if: github.event_name == 'pull_request'
run: |
git remote add headRemote ${{ github.event.pull_request.head.repo.clone_url }}
git fetch headRemote
npx lint-staged --diff=origin/${{ github.base_ref }}...headRemote/${{ github.head_ref }}
- name: Run lint-staged (push to main)
if: github.event_name == 'push' && github.ref_name == github.event.repository.default_branch
run: npx lint-staged --diff=HEAD~...HEAD
test:
needs: lint-staged
strategy:
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Set Playwright cache path
shell: bash
run: |
if [ ${{ runner.os }} == Linux ]; then
echo "PLAYWRIGHT_CACHE_PATH=~/.cache/ms-playwright" >> $GITHUB_ENV
elif [ ${{ runner.os }} == macOS ]; then
echo "PLAYWRIGHT_CACHE_PATH=~/Library/Caches/ms-playwright" >> $GITHUB_ENV
elif [ ${{ runner.os }} == Windows ]; then
echo "PLAYWRIGHT_CACHE_PATH=C:\Users\runneradmin\AppData\Local\ms-playwright" >> $GITHUB_ENV
else
echo "OS not found. Exiting." && exit 1
fi
- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: |
node_modules
${{ env.PLAYWRIGHT_CACHE_PATH }}
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Install Playwright browsers and browser deps
if: steps.cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps chromium chrome
- name: Run e2e tests
run: npm run test:headless
- name: Upload report
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: playwright-report
path: playwright-report