-
-
Notifications
You must be signed in to change notification settings - Fork 140
291 lines (251 loc) · 10.2 KB
/
build.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
name: Build Pulsar Binaries
on:
push:
branches:
- 'master'
tags:
- '**'
pull_request:
workflow_dispatch:
env:
# Variables needed for build information
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYTHON_VERSION: '3.12'
NODE_VERSION: 16
ROLLING_UPLOAD_TOKEN: ${{ secrets.ROLLING_RELEASE_UPLOAD_TOKEN }}
# Below variables allow us to quickly control visual tests for each platform
RUN_WINDOWS_VT: false
RUN_LINUX_VT: true
RUN_MACOS_VT: true
jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, macos-12, windows-latest ]
include:
- os: ubuntu-latest
image: "debian:10"
fail-fast: false
runs-on: ${{ matrix.os }}
container: ${{ matrix.image }}
outputs:
timestamp: ${{ steps.linux-binary-version.outputs.timestamp }}
steps:
- name: Install build dependencies - Linux
if: ${{ runner.os == 'Linux' }}
run: apt-get update && apt-get install -y git python3 python3-pip make gcc g++ libx11-dev libxkbfile-dev pkg-config libsecret-1-dev rpm xvfb ffmpeg zstd
- name: Checkout the latest code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Python
# actions/setup-python's copy of Python is compiled for too new glibc,
# which won't work in a Debian 10 Docker image.
# Get Python from apt repos instead on Linux.
if: ${{ runner.os != 'Linux' }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python setuptools
# This is needed for Python 3.12+, since many versions of node-gyp
# are incompatible with Python 3.12+, which no-longer ships 'distutils'
# out of the box. 'setuptools' package provides 'distutils'.
run: python3 -m pip install setuptools
- name: Install Yarn - Linux
if: ${{ runner.os == 'Linux' }}
run: npm install -g yarn
- name: Setup Git Submodule
if: ${{ runner.os != 'Linux' }}
run: |
git submodule init
git submodule update
- name: Setup Git Submodule - Linux
if: ${{ runner.os == 'Linux' }}
run: |
git config --global --add safe.directory /__w/pulsar/pulsar
git submodule init
git submodule update
- name: Set Timestamp for Binary Version - Linux
id: linux-binary-version
if: ${{ runner.os == 'Linux' }}
# This output is currently only set for the sake of the Rolling binary upload script.
# See the "test-and-upload-Linux" job below.
run: echo "timestamp=`date -u +%Y%m%d%H`" >> "$GITHUB_OUTPUT"
- name: Check Pulsar Version
if: ${{ runner.os != 'Windows' }}
run: sed -i -e "s/[0-9]*-dev/`date -u +%Y%m%d%H`/g" package.json
- name: Check Pulsar Version - Windows
if: ${{ runner.os == 'Windows' }}
run: (Get-Content package.json) -replace '[0-9]*-dev', (date -u +%Y%m%d%H) | Set-Content -Path package.json
- name: Reinstall Current Node-GYP NodeJS Headers
# Overwrite bad headers that get downloaded.
# NodeJS versions above 16 should come with `[email protected]` that has a fix
# for this issue. At that point this additional step can be removed.
run: npx node-gyp install ${{ env.NODE_VERSION }}
- name: Install Pulsar Dependencies
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e
with:
timeout_minutes: 30
max_attempts: 3
retry_on: error
command: yarn install --ignore-engines
on_retry_command: rm -R node_modules
- name: Build Pulsar
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e
with:
timeout_minutes: 30
max_attempts: 3
retry_on: error
command: |
yarn build
yarn run build:apm
- name: Cache Pulsar dependencies - Linux
if: ${{ runner.os == 'Linux' }}
uses: actions/cache/save@v4
with:
path: |
node_modules
packages
key: Linux-dependencies-${{ github.sha }}-${{ github.workflow }}
# macOS Signing Stuff
- name: Build Pulsar Binaries (macOS) (Signed)
if: ${{ runner.os == 'macOS' && github.event_name == 'push' }}
# Note: PRs generated from forks cannot access GitHub Secrets.
# So if the PR is from a fork, we can still build, but cannot sign.
# Note: We aren't attempting to sign for *any* PRs anymore, though.
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
APPLEID: ${{ secrets.APPLEID }}
APPLEID_PASSWORD: ${{ secrets.APPLEID_PASSWORD }}
TEAM_ID: ${{ secrets.TEAM_ID }}
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e
with:
timeout_minutes: 45
max_attempts: 3
retry_on: error
command: yarn dist
- name: Build Pulsar Binaries (macOS) (Unsigned)
if: ${{ runner.os == 'macOS' && github.event_name != 'push' }}
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e
with:
timeout_minutes: 45
max_attempts: 3
retry_on: error
command: yarn dist
- name: Build Pulsar Binaries
if: ${{ runner.os != 'macOS' }}
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e
with:
timeout_minutes: 30
max_attempts: 3
retry_on: error
command: yarn dist
- name: Rename Pulsar Binaries for Regular release (Linux)
if: ${{ runner.os == 'Linux' }}
run: node ./script/rename.js "Linux"
- name: Rename Pulsar Binaries for Regular release (macOS)
if: ${{ runner.os == 'macOS' }}
run: node ./script/rename.js "Intel.Mac"
- name: Rename Pulsar Binaries for Regular release (Windows)
if: ${{ runner.os == 'Windows' }}
run: node ./script/rename.js "Windows"
- name: Cache Pulsar Binaries - Linux
if: ${{ runner.os == 'Linux' }}
uses: actions/cache/save@v4
with:
path: ./binaries
key: pulsar-Linux-Binaries-${{ github.sha }}-${{ github.workflow }}
- name: Upload Binary Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }} Binaries
path: ./binaries/*
- name: Test Binary - Windows
if: runner.os == 'Windows' && env.RUN_WINDOWS_VT == true
# TODO: Convert script to PowerShell
run: |
mkdir extracted; tar -xf binaries/*zip -C ./extracted/
export BINARY_NAME=./extracted/Pulsar.exe
PLAYWRIGHT_JUNIT_OUTPUT_NAME=report.xml npx playwright test --reporter=junit,list || echo "Yeah, tests failed, Windows is like this"
- name: Test Binary - macOS
if: runner.os == 'macOS' && env.RUN_MACOS_VT == true
run: |
export PATH="/usr/local/opt/node@16/bin:/usr/local/bin:$PATH"
rm -R node_modules/electron; yarn install --check-files
hdiutil mount binaries/*Pulsar*dmg
export BINARY_NAME=`ls /Volumes/Pulsar*/Pulsar.app/Contents/MacOS/Pulsar`
PLAYWRIGHT_JUNIT_OUTPUT_NAME=report.xml arch -x86_64 npx playwright test --reporter=junit,list
- name: Add binaries to Rolling Release Repo
if: ${{ github.event_name == 'push' && runner.os != 'Linux' }}
# We only want to upload rolling binaries if they are a commit to master
# Otherwise we want to not upload if it's a PR or manually triggered build
run: |
cd ./script/rolling-release-scripts
npm install
node ./rolling-release-binary-upload.js
- name: Upload Video Artifacts
# Run whether this job passed or failed, unless explicitly cancelled.
if: ${{ !cancelled() && runner.os != 'Linux' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }} Videos
path: ./tests/videos/**
test-and-upload-Linux:
# I couldn't figure out how to get these visual tests to actually run in the
# Debian Docker environment. If anyone can make it work, feel free to
# re-combine visual testing on Linux back into the main build job above!
# - DeeDeeG
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout the latest code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore Cached Pulsar Binaries - Linux
if: ${{ runner.os == 'Linux' }}
uses: actions/cache/restore@v4
with:
path: ./binaries
key: pulsar-Linux-Binaries-${{ github.sha }}-${{ github.workflow }}
- name: Restore Cached Pulsar dependencies - Linux
if: ${{ runner.os == 'Linux' }}
uses: actions/cache/restore@v4
with:
path: |
node_modules
packages
key: Linux-dependencies-${{ github.sha }}-${{ github.workflow }}
- name: Test Binary - Linux
if: ${{ (runner.os == 'Linux') && env.RUN_LINUX_VT }}
run: |
rm -R node_modules/electron; yarn install --check-files
./binaries/*AppImage --appimage-extract
export BINARY_NAME='squashfs-root/pulsar'
mkdir -p ./tests/videos
Xvfb -screen 0 1024x768x24+32 :99 & nohup ffmpeg -video_size 1024x768 -f x11grab -i :99.0 ./tests/videos/out.mpg & DISPLAY=:99 PLAYWRIGHT_JUNIT_OUTPUT_NAME=report.xml npx playwright test --reporter=junit,list
- name: Check Pulsar Version
if: ${{ runner.os != 'Windows' }}
run: sed -i -e "s/[0-9]*-dev/${TIMESTAMP}/g" package.json
env:
TIMESTAMP: ${{needs.build.outputs.timestamp}}
- name: Add binaries to Rolling Release Repo - Linux
if: ${{ github.event_name == 'push' && runner.os == 'Linux' }}
# We only want to upload rolling binaries if they are a commit to master
# Otherwise we want to not upload if it's a PR or manually triggered build
run: |
cd ./script/rolling-release-scripts
npm install
node ./rolling-release-binary-upload.js
- name: Upload Video Artifacts - Linux
# Run whether this job passed or failed, unless explicitly cancelled.
if: ${{ !cancelled() && runner.os == 'Linux' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }} Videos
path: ./tests/videos/**