|
| 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