dev: include test context when running tests #359
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
workflow_call: # for Publish | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
skip_tests: ${{ steps.check_for_skip.outputs.skip_tests }} | |
tests: ${{ steps.set-tests.outputs.tests }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Clojure deps cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.m2/repository | |
~/.deps.clj | |
~/.gitlibs | |
enableCrossOsArchive: true | |
key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }} | |
restore-keys: cljdeps- | |
- name: "Setup Java" | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- name: Install Clojure Tools | |
uses: DeLaGuardo/[email protected] | |
with: | |
bb: 'latest' | |
# This assumes downloaded deps are same for all OSes | |
- name: Bring down deps | |
run: bb download-deps | |
- name: Check if Tests Should Run | |
id: check_for_skip | |
run: bb -ci-set-skip-tests | |
- id: set-tests | |
if: steps.check_for_skip.outputs.skip_tests == 'false' | |
name: Set test var for matrix | |
# run test.clj directly instead of via bb task to avoid generic task output | |
run: echo "tests=$(bb script/test_matrix.clj --format json)" >> $GITHUB_OUTPUT | |
build: | |
needs: setup | |
runs-on: ${{ matrix.os }}-latest | |
if: needs.setup.outputs.skip_tests == 'false' | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{fromJSON(needs.setup.outputs.tests)}} | |
name: ${{ matrix.desc }} | |
steps: | |
- name: Don't convert line endings on checkout (Windows) | |
if: matrix.os == 'windows' | |
run: git config --global core.autocrlf false | |
- name: Tune Windows network | |
if: ${{ matrix.os == 'windows' }} | |
run: Disable-NetAdapterChecksumOffload -Name * -TcpIPv4 -UdpIPv4 -TcpIPv6 -UdpIPv6 | |
- name: Tune macOS network | |
if: ${{ matrix.os == 'macos' }} | |
run: | | |
sudo sysctl -w net.link.generic.system.hwcksum_tx=0 | |
sudo sysctl -w net.link.generic.system.hwcksum_rx=0 | |
- name: Install Ubuntu X11 Utils | |
if: ${{ matrix.os == 'ubuntu' }} | |
run: sudo apt-get -y install x11-utils | |
- name: Install Linux Windows Manager | |
if: ${{ matrix.os == 'ubuntu' }} | |
run: sudo apt-get -y install fluxbox | |
# No longer pre-installed on macOS github action runners | |
- name: Install Image Magick on macOS | |
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'imagemagick') }} | |
run: brew install imagemagick | |
# No longer pre-installed on macOS github action runners | |
- name: Install Microsoft Edge on macOS | |
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'edge') }} | |
run: | | |
brew install --cask microsoft-edge | |
EDGE_VERSION=$(defaults read /Applications/Microsoft\ Edge.app/Contents/Info CFBundleShortVersionString) | |
MAJOR_VERSION=$(echo $EDGE_VERSION | cut -d'.' -f1) | |
DRIVER_VERSION=$(curl -s "https://msedgedriver.azureedge.net/LATEST_RELEASE_${MAJOR_VERSION}_MACOS" | iconv -f UTF-16LE -t UTF-8 | sed 's/^\xEF\xBB\xBF//' | tr -d '\r\n') | |
echo "Installing msedgedriver version ${DRIVER_VERSION} for Edge version ${EDGE_VERSION}" | |
DRIVER_URL="https://msedgedriver.azureedge.net/${DRIVER_VERSION}/edgedriver_mac64_m1.zip" | |
wget $DRIVER_URL | |
mkdir $RUNNER_TEMP/edgedriver | |
unzip edgedriver_mac64_m1.zip -d $RUNNER_TEMP/edgedriver | |
echo "$RUNNER_TEMP/edgedriver" >> $GITHUB_PATH | |
# No longer pre-installed on macOS github action runners | |
- name: Install Firefox on macOS | |
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'firefox') }} | |
run: | | |
brew install --cask firefox | |
brew install geckodriver | |
- uses: actions/checkout@v4 | |
- name: Restore Clojure deps from cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
~/.m2/repository | |
~/.deps.clj | |
~/.gitlibs | |
enableCrossOsArchive: true | |
key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }} | |
restore-keys: cljdeps- | |
- name: Cache fixup for Windows | |
# cache is restored using relative paths from Linux, this is not appropriate for Windows | |
# this is admitedly fragile/hackey, will revisit if it cracks | |
if: ${{ matrix.os == 'windows' }} | |
run: | | |
mv ../../../.m2 ${USERPROFILE} | |
mv ../../../.deps.clj ${USERPROFILE} | |
mv ../../../.gitlibs ${USERPROFILE} | |
shell: bash | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: ${{ matrix.jdk-version }} | |
- name: Install Clojure Tools | |
uses: DeLaGuardo/[email protected] | |
with: | |
bb: 'latest' | |
- name: Tools versions | |
run: bb tools-versions | |
- name: Run Tests | |
run: ${{ matrix.cmd }} | |
- name: Upload test debug output | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.id }}-debug-screenshots | |
path: target/debug-screenshots/* | |
if-no-files-found: ignore |