-
Notifications
You must be signed in to change notification settings - Fork 40
171 lines (148 loc) · 6.07 KB
/
ci-web.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: CI Web
on:
workflow_call:
workflow_dispatch:
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
# But on the main branch, we don't want that behavior.
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
#
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
concurrency:
group: ci-web-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
# We use the version 18.12 because the version >= 18.13 have some breaking changes on how they format the date.
# That would break our unit test if we don't update them.
node-version: 18.12.0
wasm-pack-version: 0.12.1
permissions:
contents: read
packages: read
jobs:
test-web-app:
runs-on: ubuntu-22.04
name: 🌐 Web tests
# Just a fail-safe timeout, see the fine grain per-task timeout instead
timeout-minutes: 20
# Testbed server comes as a Docker image, so it will eventually goes out of sync
# with the tests (typically a new API is introduced in the Parsec server, or a new
# testbed template is introduced).
# In such case, the container url should be updated from the, see:
# https://github.com/Scille/parsec-cloud/pkgs/container/parsec-cloud%2Fparsec-testbed-server
services:
parsec-testbed-server:
image: ghcr.io/scille/parsec-cloud/parsec-testbed-server:3.1.1-a.0.dev.20032.1b69f9d
ports:
- 6777:6777
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin v4.2.1
timeout-minutes: 5
- name: Retrieve runner specs
id: runner-specs
uses: ./.github/actions/system-info
timeout-minutes: 1
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # pin v4.0.4
with:
node-version: ${{ env.node-version }}
cache: npm
cache-dependency-path: client/package-lock.json
timeout-minutes: 2
- name: Install dependencies
run: |
# Execute 'npm install' until success,
# This is done that way because sometime some CDN response with 503
until npm install --ignore-scripts; do
echo "Failed install, retrying ...";
done
working-directory: client
timeout-minutes: 5
- name: Check lint with eslint
run: npx eslint . --max-warnings=0
working-directory: client
timeout-minutes: 2
- name: Check lint with vue-tsc
run: npx vue-tsc --noEmit
working-directory: client
timeout-minutes: 2
- name: Check prettier
run: npx prettier . --check
working-directory: client
timeout-minutes: 5
- name: Setup cache-key
id: cache-key
run: >-
echo "key=web-${{ hashFiles(
'bindings/web/**',
'libparsec/**',
'rust-toolchain.toml',
'Cargo.lock'
) }}-libparsec" >> "$GITHUB_OUTPUT"
shell: bash
- name: Restore libparsec if Rust hasn't been modified
id: cache-libparsec
uses: actions/cache/restore@3624ceb22c1c5a301c8db4169662070a689d9ea8 # pin v4.1.1
with:
key: ${{ steps.cache-key.outputs.key }}
path: |
bindings/web/pkg/
bindings/web/pkg/
timeout-minutes: 2
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # pin v1.10.1
if: steps.cache-libparsec.outputs.cache-hit != 'true'
with:
target: wasm32-unknown-unknown
# We setup the cache by hand, see below
cache: false
timeout-minutes: 5
- name: Retrieve Rust cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # pin v2.7.5
if: steps.cache-libparsec.outputs.cache-hit != 'true'
with:
# Cache is limited to 10Go (and cache is ~700mo per platform !). On top of that.
# cache is only shared between master and the PRs (and not across PRs).
# So we only save the cache on master build given it's the ones that are the
# most likely to be reused.
save-if: ${{ github.ref == 'refs/heads/master' }}
key: ${{ steps.runner-specs.outputs.os }}-${{ steps.runner-specs.outputs.release }}
timeout-minutes: 5
# Install wasm-pack command
- uses: taiki-e/install-action@437c908c7e5ee18b63a261286cbe5147219f8a39 # pin v2.44.44
with:
tool: wasm-pack@${{ env.wasm-pack-version }}
- name: Build web bindings
if: steps.cache-libparsec.outputs.cache-hit != 'true'
run: npm run build:dev
working-directory: bindings/web
timeout-minutes: 10
- name: Save libparsec to be reuse later
if: steps.cache-libparsec.outputs.cache-hit != 'true'
uses: actions/cache/save@3624ceb22c1c5a301c8db4169662070a689d9ea8 # pin v4.1.1
with:
key: ${{ steps.cache-key.outputs.key }}
path: |
bindings/web/pkg/
bindings/web/pkg/
timeout-minutes: 2
- name: Unit tests
run: npm run test:unit
working-directory: client
timeout-minutes: 10
- name: Check testbed server is running
run: curl http://localhost:6777
- name: Install Playwright dependencies
run: npx playwright install --with-deps
working-directory: client
timeout-minutes: 5
- name: E2E tests
run: npm run test:e2e:headless
env:
TESTBED_SERVER: parsec3://localhost:6777?no_ssl=true
working-directory: client
timeout-minutes: 20
- name: Archive test results
if: failure()
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # pin v4.4.3
with:
name: playwright-artifacts
path: client/test-results/