From aa070ab493261cd5da81f2f566e7fa4fa852de34 Mon Sep 17 00:00:00 2001 From: Pekka Kaitaniemi Date: Fri, 26 Jan 2024 17:04:14 +0200 Subject: [PATCH] Add Github actions workflow for running tests --- .github/workflows/clojure.yml | 63 +++++++++++++++++++++++++++++++++++ bin/run-cljs-tests | 32 ++++++++++++++++++ bin/run-clojure-tests | 3 ++ 3 files changed, 98 insertions(+) create mode 100644 .github/workflows/clojure.yml create mode 100755 bin/run-cljs-tests create mode 100755 bin/run-clojure-tests diff --git a/.github/workflows/clojure.yml b/.github/workflows/clojure.yml new file mode 100644 index 0000000..4fd65b2 --- /dev/null +++ b/.github/workflows/clojure.yml @@ -0,0 +1,63 @@ +--- +name: Run tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build-clj: + strategy: + matrix: + # Supported Java versions: LTS releases and latest + jdk: [8, 11, 17, 21] + clojure: [11] + + name: Clojure ${{ matrix.clojure }} (Java ${{ matrix.jdk }}) + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Setup Java ${{ matrix.jdk }} + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: ${{ matrix.jdk }} + cache: maven + - name: Setup Clojure + uses: DeLaGuardo/setup-clojure@master + with: + cli: latest + - name: Run tests + run: CLOJURE_ALIAS=clojure-${{ matrix.clojure }} bin/run-clojure-tests + + build-cljs: + name: ClojureScript + strategy: + matrix: + mode: [none, advanced, cherry-none, cherry-advanced] + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Java 11 + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 11 + cache: maven + - name: Setup Clojure + uses: DeLaGuardo/setup-clojure@master + with: + cli: latest + - name: Setup Node.js + uses: actions/setup-node@v4.0.1 + with: + node-version: 16 + - name: Install dependencies + run: npm ci + - name: Run tests on ${{ matrix.mode }} + run: bin/run-cljs-tests ${{ matrix.mode }} diff --git a/bin/run-cljs-tests b/bin/run-cljs-tests new file mode 100755 index 0000000..a050aca --- /dev/null +++ b/bin/run-cljs-tests @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -eo pipefail + +none() { + echo 'Running CLJS test in Node with optimizations :none' + TEST_SCI=true clojure -M:test:cljs-test-runner:sci:test-sci -c '{:optimizations :none}' "$@" +} + +advanced() { + echo 'Running CLJS test in Node with optimizations :advanced' + TEST_SCI=true clojure -M:test:cljs-test-runner:sci:test-sci -c '{:optimizations :advanced}' -e :simple "$@" +} + +cherry-none() { + echo 'Running CLJS test in Node with cherry + optimizations :none' + clojure -M:test:cljs-test-runner:cherry:test-cherry -c '{:optimizations :none}' "$@" +} + +cherry-advanced() { + echo 'Running CLJS test in Node with cherry + optimizations :advanced' + # :optimize-constants is set to false until https://clojure.atlassian.net/browse/CLJS-3401 is fixed + clojure -M:test:cljs-test-runner:cherry:test-cherry -c '{:optimizations :advanced :optimize-constants false}' -e :simple "$@" +} + +case $1 in + none) none ;; + advanced) advanced ;; + cherry-none) cherry-none ;; + cherry-advanced) cherry-advanced ;; + *) none; advanced; cherry; cherry-advanced ;; +esac diff --git a/bin/run-clojure-tests b/bin/run-clojure-tests new file mode 100755 index 0000000..9c1c4ce --- /dev/null +++ b/bin/run-clojure-tests @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Should work if the env var is empty +clojure -A:$CLOJURE_ALIAS -M:test -m kaocha.runner "$@"