-
-
Notifications
You must be signed in to change notification settings - Fork 4
133 lines (124 loc) · 5.54 KB
/
ci_test_workspace.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
# This file configure a GitHub workflow responsible to perform
# various checks related to the codebase.
#
# For that reason it's runned on every pull request and push to main.
#
# It does the following:
# - Check linting passes (no eslint error on files)
# - Run tests and ensure none is failing
name: workspace_tests
on:
push:
branches:
- main
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#patterns-to-match-file-paths
paths-ignore:
- "docs/**"
- "www/**"
- "**/readme.md"
pull_request:
branches:
- "**"
paths-ignore:
- "docs/**"
- "www/**"
- "./readme.md"
jobs:
test:
strategy:
matrix:
# https://github.com/actions/runner-images
os:
- ubuntu-22.04
- macos-12 # until https://github.com/microsoft/playwright/issues/30585
- windows-2022
node: [22.3.0]
runs-on: ${{ matrix.os }}
name: test on ${{ matrix.os }} and node ${{ matrix.node }}
env:
CI: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
# sudo ulimit should prevent npm link failure
- name: set linux fs limits
if: runner.os == 'Linux'
run: |
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p
sudo sh -c "ulimit -n 65536 && exec su $LOGNAME"
ulimit -n
- name: Install node modules
run: npm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
# Figures out the version of playwright that's installed.
# 1. Because we don't know what version yarn will resolve it to, we have
# to use `yarn why` to get the actually installed version.
# 2. Because we're in a workspace, we need to make sure we get the version
# for the root and not any children, hence the `grep`. If not using
# workspaces, this can be skipped.
# 3. jq comes pre-installed in the Ubuntu runner, so we use that to get
# the correct version string.
# 4. Finally, we use sed to extract just the version number (eg; '1.22.0')
# The result is stored in $PLAYWRIGHT_VERSION
# https://github.com/microsoft/playwright/issues/7249#issuecomment-2299065930
# https://stackoverflow.com/a/33426237/24573072
# https://github.com/actions/runner/issues/1636#issuecomment-1024531638
- name: Detect Playwright version (Windows)
if: runner.os == 'windows'
run: echo "PLAYWRIGHT_VERSION=$(npm ll -p --depth=0 playwright | grep -o '@.*')" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Detect Playwright version (Linux and Mac)
if: runner.os != 'windows'
run: echo "PLAYWRIGHT_VERSION=$(npm ll -p --depth=0 playwright | grep -o '@.*')" >> $GITHUB_ENV
- name: Put $HOME in env
if: runner.os == 'windows'
run: echo "HOME=$HOME" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: toto
env:
FOO: format('{0}{1}', HOME, '\AppData\Local\ms-playwright')
run: echo "${{ env.FOO }}"
# Attempt to restore the correct Playwright browser binaries based on the
# currently installed version of Playwright (The browser binary versions
# may change with Playwright versions).
# Note: Playwright's cache directory is hard coded because that's what it
# says to do in the docs. There doesn't appear to be a command that prints
# it out for us.
- name: Cache by playwright version
uses: actions/cache@v4
id: playwright-cache
with:
# see https://playwright.dev/docs/browsers#managing-browser-binaries
path: ${{ runner.os == 'Windows' && format('{0}{1}', env.HOME, '\AppData\Local\ms-playwright') || runner.os == 'Linux' && '~/.cache/ms-playwright' || '~/Library/Caches/ms-playwright' }}
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
# As a fallback, if the Playwright version has changed, try use the
# most recently cached version. There's a good chance that at least one
# of the browser binary versions haven't been updated, so Playwright can
# skip installing that in the next step.
# Note: When falling back to an old cache, `cache-hit` (used below)
# will be `false`. This allows us to restore the potentially out of
# date cache, but still let Playwright decide if it needs to download
# new binaries or not.
restore-keys: |
${{ runner.os }}-playwright-
# If the Playwright browser binaries weren't able to be restored, we tell
# paywright to install everything for us.
- name: Install Playwright with dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
# https://github.com/microsoft/playwright/issues/7249#issuecomment-1171962742
- name: Install Playwright's dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps
- name: Install certificate # needed for @jsenv/service-worker tests
if: runner.os == 'Linux' # https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
run: npm run https:setup
- name: Fix lightningcss windows
if: runner.os == 'Windows'
run: npm install lightningcss-win32-x64-msvc
- name: Run package tests
run: npm run packages:test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}