-
-
Notifications
You must be signed in to change notification settings - Fork 211
182 lines (161 loc) · 5.15 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
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
172
173
174
175
176
177
178
179
180
181
182
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
Build:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
# - ubuntu-22.04
- ubuntu-20.04
- windows-2022
node_version:
- 18
node_arch:
- x64
cpp_arch:
- x64
docker:
- ""
docker_cmd:
- ""
include:
- os: windows-2022
node_version: 18
node_arch: ia32
cpp_arch: amd64_x86
# - os: windows-2022
# node_version: 18
# node_arch: x64
# arch: arm64
# cpp_arch: amd64_arm64
- os: macos-13
node_version: 18
node_arch: x64
cpp_arch: x64
- os: macos-14
node_version: 18
node_arch: arm64
cpp_arch: amd64_arm64
# Alpine
- os: ubuntu-22.04
docker: node:18-alpine
docker_cmd:
apk add --no-cache pkgconfig curl tar python3 make gcc g++ cmake
musl-dev && npm i -g pnpm && pnpm install && pnpm run
build.prebuild
node_version: 18
node_arch: x64
cpp_arch: x64
env:
npm_config_zmq_draft: false
npm_config_zmq_shared: false
npm_config_arch: ${{ matrix.node_arch }}
npm_config_target_arch: ${{ matrix.node_arch }}
setup_node_arch: ${{ matrix.node_arch }}
steps:
- uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
with:
path: |
./node_modules/
./build/
key:
# prettier-ignore
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch}}-ZMQ_DRAFT:${{env.npm_config_zmq_draft }}-Node:${{ matrix.node_version}}-${{hashFiles('./package.json') }}"
restore-keys: |
"cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ env.npm_config_zmq_draft }}-Node:${{ matrix.node_version }}-"
- name: Env map
run: |
if [ "${{ matrix.node_arch }}" = "ia32" ]; then
echo "setup_node_arch=x86" > $GITHUB_ENV
fi
shell: bash
- name: Setup Cpp
if: ${{ !matrix.docker }}
uses: aminya/setup-cpp@v1
with:
vcvarsall: ${{ contains(matrix.os, 'windows') }}
cmake: true
python: true
architecture: ${{ matrix.cpp_arch }}
- uses: pnpm/action-setup@v4
if: ${{ !matrix.docker }}
with:
version: 9
- name: Install Node
if: ${{ !matrix.docker }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
architecture: ${{ env.setup_node_arch }}
- name: Install Mac-OS x86_64 Dependencies
if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'x64' }}
run: |
brew install libsodium gnutls
- name: Install Mac-OS arm64 Dependencies
if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'arm64' }}
run: |
brew uninstall libsodium --force --ignore-dependencies
source ./script/macos-arm-deps.sh
echo "PATH=$PATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
- name: Install Dependencies and Build
if: ${{ !matrix.docker }}
run: pnpm install
- name: Prebuild
if: ${{ !matrix.docker }}
run: pnpm run build.prebuild
- name: Prebuild Docker
if: ${{ matrix.docker }}
run: |
docker login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
docker pull ${{ matrix.docker }}
docker tag ${{ matrix.docker }} builder
docker run --volume ${{ github.workspace }}:/app --workdir /app --privileged builder sh -c "${{ matrix.docker_cmd }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: ./prebuilds
name: prebuilds-${{ strategy.job-index }}
overwrite: true
- name: Lint
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}"
run: pnpm run lint-test
- name: Test
if: ${{ !matrix.docker }}
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 1
command: |
pnpm run test
continue-on-error: true
- name: Test Electron (Main)
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}"
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 1
command: |
sudo apt-get install xvfb
pnpm install -g electron@latest
xvfb-run --auto-servernum pnpm run test.electron.main
continue-on-error: true
merge-prebuilds:
runs-on: ubuntu-latest
needs: Build
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: prebuilds
pattern: prebuilds-*
delete-merged: true