-
-
Notifications
You must be signed in to change notification settings - Fork 106
135 lines (130 loc) · 4.45 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# build and test on linux, windows, mac with node 14, 16, 18
name: CI
on:
push:
branches:
- main
- v2
pull_request:
branches:
- main
- v2
env:
# we call `pnpm playwright install` instead
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
# cancel in-progress runs on new commits to same PR (gitub.event.number)
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
# use min permissions
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
# "checks" job runs on linux + 16 only and checks that install, build, lint and audit work
# it also primes the pnpm store cache for linux, important for downstream tests
checks:
timeout-minutes: 5
runs-on: ${{ matrix.os }}
strategy:
matrix:
# pseudo-matrix for convenience, NEVER use more than a single combination
node: [16]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: install pnpm
shell: bash
run: |
PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json)
echo installing pnpm version $PNPM_VER
npm i -g pnpm@$PNPM_VER
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- name: install
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
- name: format
run: pnpm check:format
- name: lint
if: (${{ success() }} || ${{ failure() }})
run: pnpm check:lint
- name: types
if: (${{ success() }} || ${{ failure() }})
run: pnpm check:types
- name: audit
if: (${{ success() }} || ${{ failure() }})
run: pnpm check:audit
- name: publint
if: (${{ success() }} || ${{ failure() }})
run: pnpm check:publint
test:
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node: [16]
os: [ubuntu-latest, macos-latest, windows-latest]
svelte: [4]
include:
- node: 14
os: ubuntu-latest
svelte: 3
- node: 18
os: ubuntu-latest
svelte: 4
- node: 20
os: ubuntu-latest
svelte: 4
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: install pnpm
if: matrix.node != 14
shell: bash
run: |
PNPM_VER=$(jq -r '.packageManager | if .[0:5] == "pnpm@" then .[5:] else "packageManager in package.json does not start with pnpm@\n" | halt_error(1) end' package.json)
echo installing pnpm version $PNPM_VER
npm i -g pnpm@$PNPM_VER
- name: install legacy pnpm for node14
if: matrix.node == 14
run: |
npm i -g pnpm@^7.33.0
tmppkg="$(jq '.engines.pnpm = "^7.33.0"' package.json)" && echo -E "${tmppkg}" > package.json && tmppkg=""
- name: use svelte 3
if: matrix.svelte == 3
run: |
tmppkg="$(jq '.devDependencies.svelte = "^3.59.2"' package.json)" && echo -E "${tmppkg}" > package.json && tmppkg=""
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- name: install
if: matrix.node != 14 && matrix.svelte != 3
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts
- name: install for node14 or svelte3
if: matrix.node == 14 || matrix.svelte == 3
run: pnpm install --no-frozen-lockfile --prefer-offline --ignore-scripts
- name: install playwright chromium
run: pnpm playwright install chromium
- name: run tests
run: pnpm test
- name: archive tests temp directory
if: failure()
shell: bash
run: tar -cvf test-temp.tar --exclude="node_modules" temp/
- uses: actions/upload-artifact@v3
if: failure()
with:
name: test-failure-${{github.run_id}}-${{ matrix.os }}-${{ matrix.node }}-${{ matrix.svelte }}
path: |
test-temp.tar
pnpm-debug.log