-
Notifications
You must be signed in to change notification settings - Fork 284
104 lines (92 loc) · 3.46 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
name: CI
on:
push:
# Prevent duplicate runs of this workflow on our own internal PRs.
branches:
- main
- next/*
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- main
- next/*
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
node_version: ${{ steps.set_matrix.outputs.node_version }}
rust_toolchain: ${{ steps.set_matrix.outputs.rust_toolchain }}
steps:
- name: Set Matrix
id: set_matrix
env:
FULL_NODE_VERSIONS: '["18.x", "20.x"]'
FULL_RUST_TOOLCHAINS: '["stable", "nightly"]'
PARTIAL_NODE_VERSIONS: '["20.x"]'
PARTIAL_RUST_TOOLCHAINS: '["stable"]'
HAS_FULL_MATRIX_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'full matrix') }}
IS_PUSHED: ${{ github.event_name == 'push' }}
run: |
if [[ "$HAS_FULL_MATRIX_LABEL" == "true" ]] || [[ "$IS_PUSHED" == "true" ]]; then
echo "node_version=$FULL_NODE_VERSIONS" >> $GITHUB_OUTPUT
echo "rust_toolchain=$FULL_RUST_TOOLCHAINS" >> $GITHUB_OUTPUT
else
echo "node_version=$PARTIAL_NODE_VERSIONS" >> $GITHUB_OUTPUT
echo "rust_toolchain=$PARTIAL_RUST_TOOLCHAINS" >> $GITHUB_OUTPUT
fi
build:
needs: matrix
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: ${{fromJson(needs.matrix.outputs.node_version)}}
rust-toolchain: ${{fromJson(needs.matrix.outputs.rust_toolchain)}}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Use Rust ${{ matrix.rust-toolchain }}
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
components: clippy,rustfmt
- name: Linkme nightly workaround
if: matrix.rust-toolchain == 'nightly' && matrix.os == 'ubuntu-latest'
# Workaround for linkme with `rust-lld`
# https://blog.rust-lang.org/2024/05/17/enabling-rust-lld-on-linux.html#possible-drawbacks
run: echo RUSTFLAGS=${RUSTFLAGS}\ -Clink-arg=-Wl,-z,nostart-stop-gc >> $GITHUB_ENV
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Cache Electron (Linux)
if: matrix.os == 'ubuntu-latest'
uses: actions/cache@v4
with:
key: ${{ runner.os }}-electron-${{ hashFiles('./package-lock.json') }}
path: ~/.cache/electron
- name: Cache Electron (Windows)
if: matrix.os == 'windows-latest'
uses: actions/cache@v4
with:
key: ${{ runner.os }}-electron-${{ hashFiles('./package-lock.json') }}
path: "%LOCALAPPDATA%\\electron\\Cache"
- name: Cache Electron (macOS)
if: matrix.os == 'macos-latest'
uses: actions/cache@v4
with:
key: ${{ runner.os }}-electron-${{ hashFiles('./package-lock.json') }}
path: ~/Library/Caches/electron
- name: npm install
run: npm ci --prefer-offline --no-audit --no-fund
- name: Test (Linux)
if: matrix.os == 'ubuntu-latest'
run: xvfb-run --auto-servernum npm test -- --nocapture
- name: Test
if: matrix.os != 'ubuntu-latest'
run: npm test