Skip to content

Commit 9e2e0ad

Browse files
committed
Add initial GHA CI files
1 parent 4d442ca commit 9e2e0ad

File tree

5 files changed

+924
-0
lines changed

5 files changed

+924
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Setup Chrome'
2+
description: 'Install Chrome and set CHROME_BIN environment variable'
3+
4+
inputs:
5+
chrome-version:
6+
description: 'Chrome version to install'
7+
default: '135.0.7049.95'
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- uses: browser-actions/setup-chrome@v2
13+
id: setup-chrome
14+
with:
15+
chrome-version: ${{ inputs.chrome-version }}
16+
17+
- name: Set Chrome binary path
18+
run: echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV
19+
shell: bash
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'Setup Workspace'
2+
description: 'Setup Node.js, install dependencies, and download build artifacts'
3+
4+
inputs:
5+
node-version:
6+
description: 'Node.js version to use'
7+
default: '18.20.4'
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- uses: actions/setup-node@v6
13+
with:
14+
node-version: ${{ inputs.node-version }}
15+
cache: 'npm'
16+
17+
- name: Install dependencies
18+
run: npm ci
19+
shell: bash
20+
env:
21+
NODE_OPTIONS: '--max-old-space-size=4096'
22+
23+
- uses: actions/download-artifact@v8
24+
with:
25+
name: build-output
26+
path: .

.github/scripts/split_files.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
// Replacement for `circleci tests split`
4+
// Reads lines from stdin and emits only those where index % SHARD_TOTAL == SHARD_INDEX
5+
// Environment variables SHARD_INDEX and SHARD_TOTAL must be set.
6+
7+
import { readFileSync } from 'fs';
8+
9+
const lines = readFileSync('/dev/stdin', 'utf8').trim().split('\n').filter(Boolean);
10+
const index = parseInt(process.env.SHARD_INDEX);
11+
const total = parseInt(process.env.SHARD_TOTAL);
12+
13+
if (isNaN(index) || isNaN(total) || total <= 0) {
14+
console.error('SHARD_INDEX and SHARD_TOTAL environment variables must be set to valid integers');
15+
process.exit(1);
16+
}
17+
18+
lines.forEach((line, i) => {
19+
if (i % total === index) console.log(line);
20+
});

.github/scripts/test.sh

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/bin/bash
2+
3+
# GitHub Actions version of .circleci/test.sh
4+
# Replaces `circleci tests split` with split_files.mjs
5+
6+
set +e
7+
set +o pipefail
8+
9+
ROOT=$(dirname $0)/../..
10+
SPLIT="$ROOT/.github/scripts/split_files.mjs"
11+
EXIT_STATE=0
12+
MAX_AUTO_RETRY=0
13+
14+
log () {
15+
echo -e "\n$1"
16+
}
17+
18+
# inspired by https://unix.stackexchange.com/a/82602
19+
retry () {
20+
local n=1
21+
22+
until [ $n -ge $MAX_AUTO_RETRY ]; do
23+
"$@" --failFast && break
24+
log "run $n of $MAX_AUTO_RETRY failed, trying again ..."
25+
n=$[$n+1]
26+
done
27+
28+
if [ $n -eq $MAX_AUTO_RETRY ]; then
29+
log "one last time, w/o failing fast"
30+
"$@" && n=0
31+
fi
32+
33+
if [ $n -eq $MAX_AUTO_RETRY ]; then
34+
log "all $n runs failed, moving on."
35+
EXIT_STATE=1
36+
fi
37+
}
38+
39+
case $1 in
40+
41+
no-gl-jasmine)
42+
SUITE=$(ls -1 $ROOT/test/jasmine/tests/* | sort | node "$SPLIT")
43+
MAX_AUTO_RETRY=2
44+
retry npm run test-jasmine -- $SUITE --skip-tags=gl,noCI,flaky || EXIT_STATE=$?
45+
46+
exit $EXIT_STATE
47+
;;
48+
49+
webgl-jasmine)
50+
SHARDS=($(node $ROOT/tasks/shard_jasmine_tests.js --limit=5 --tag=gl | node "$SPLIT"))
51+
for s in ${SHARDS[@]}; do
52+
MAX_AUTO_RETRY=2
53+
retry npm run test-jasmine -- "$s" --tags=gl --skip-tags=noCI --doNotFailOnEmptyTestSuite
54+
done
55+
56+
exit $EXIT_STATE
57+
;;
58+
59+
virtual-webgl-jasmine)
60+
SHARDS=($(node $ROOT/tasks/shard_jasmine_tests.js --limit=5 --tag=gl | node "$SPLIT"))
61+
for s in ${SHARDS[@]}; do
62+
MAX_AUTO_RETRY=2
63+
retry ./node_modules/karma/bin/karma start test/jasmine/karma.conf.js --virtualWebgl --tags=gl --skip-tags=noCI,noVirtualWebgl --doNotFailOnEmptyTestSuite -- "$s"
64+
done
65+
66+
exit $EXIT_STATE
67+
;;
68+
69+
flaky-no-gl-jasmine)
70+
SHARDS=($(node $ROOT/tasks/shard_jasmine_tests.js --limit=1 --tag=flaky | node "$SPLIT"))
71+
72+
for s in ${SHARDS[@]}; do
73+
MAX_AUTO_RETRY=5
74+
retry npm run test-jasmine -- "$s" --tags=flaky --skip-tags=noCI
75+
done
76+
77+
exit $EXIT_STATE
78+
;;
79+
80+
bundle-jasmine)
81+
npm run test-bundle || EXIT_STATE=$?
82+
exit $EXIT_STATE
83+
;;
84+
85+
mathjax-firefox)
86+
./node_modules/karma/bin/karma start test/jasmine/karma.conf.js --FF --bundleTest=mathjax --nowatch || EXIT_STATE=$?
87+
exit $EXIT_STATE
88+
;;
89+
90+
mathjax-firefox)
91+
./node_modules/karma/bin/karma start test/jasmine/karma.conf.js --FF --bundleTest=mathjax --nowatch &&
92+
./node_modules/karma/bin/karma start test/jasmine/karma.conf.js --FF --bundleTest=mathjax --mathjax3 --nowatch &&
93+
./node_modules/karma/bin/karma start test/jasmine/karma.conf.js --FF --bundleTest=mathjax_config --mathjax3 --nowatch &&
94+
./node_modules/karma/bin/karma start test/jasmine/karma.conf.js --FF --bundleTest=mathjax_config --nowatch || EXIT_STATE=$?
95+
exit $EXIT_STATE
96+
;;
97+
98+
make-baselines-virtual-webgl)
99+
SUITE=$({\
100+
find $ROOT/test/image/mocks/gl* -type f -printf "%f\n"; \
101+
find $ROOT/test/image/mocks/map* -type f -printf "%f\n"; \
102+
} | sed 's/\.json$//1' | sort | node "$SPLIT")
103+
sudo python3 test/image/make_baseline.py virtual-webgl $SUITE || EXIT_STATE=$?
104+
exit $EXIT_STATE
105+
;;
106+
107+
make-baselines-mathjax3)
108+
sudo python3 test/image/make_baseline.py mathjax3 legend_mathjax_title_and_items mathjax parcats_grid_subplots table_latex_multitrace_scatter table_plain_birds table_wrapped_birds ternary-mathjax ternary-mathjax-title-place-subtitle || EXIT_STATE=$?
109+
exit $EXIT_STATE
110+
;;
111+
112+
make-baselines-b64)
113+
SUITE=$(find $ROOT/test/image/mocks/ -type f -printf "%f\n" | sed 's/\.json$//1' | sort | node "$SPLIT")
114+
sudo python3 test/image/make_baseline.py b64 $SUITE || EXIT_STATE=$?
115+
exit $EXIT_STATE
116+
;;
117+
118+
make-baselines)
119+
SUITE=$(find $ROOT/test/image/mocks/ -type f -printf "%f\n" | sed 's/\.json$//1' | sort | node "$SPLIT")
120+
sudo python3 test/image/make_baseline.py $SUITE || EXIT_STATE=$?
121+
exit $EXIT_STATE
122+
;;
123+
124+
test-image)
125+
node test/image/compare_pixels_test.js || { tar -cvf build/baselines.tar build/test_images/*.png ; exit 1 ; } || EXIT_STATE=$?
126+
exit $EXIT_STATE
127+
;;
128+
129+
test-image-mathjax3)
130+
node test/image/compare_pixels_test.js mathjax3 || { tar -cvf build/baselines.tar build/test_images/*.png ; exit 1 ; } || EXIT_STATE=$?
131+
exit $EXIT_STATE
132+
;;
133+
134+
test-image-virtual-webgl)
135+
node test/image/compare_pixels_test.js virtual-webgl || { tar -cvf build/baselines.tar build/test_images/*.png ; exit 1 ; } || EXIT_STATE=$?
136+
exit $EXIT_STATE
137+
;;
138+
139+
source-syntax)
140+
npm run lint || EXIT_STATE=$?
141+
npm run test-syntax || EXIT_STATE=$?
142+
exit $EXIT_STATE
143+
;;
144+
145+
esac

0 commit comments

Comments
 (0)