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 Multiple JDKs | |
on: | |
push: | |
pull_request: | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-24.04, windows-2022, macos-13] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
defaults: | |
run: | |
shell: bash | |
working-directory: ./ | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Pick and display a random JDK version and distribution | |
id: pick-jdk | |
run: | | |
JDK_VERSIONS=(8 11 17 21 22) | |
JDK_DISTRIBUTIONS=(temurin semeru oracle) | |
while true; do | |
JDK_VERSION=${JDK_VERSIONS[$RANDOM % ${#JDK_VERSIONS[@]}]} | |
JDK_DISTRIBUTION=${JDK_DISTRIBUTIONS[$RANDOM % ${#JDK_DISTRIBUTIONS[@]}]} | |
if [[ "$JDK_DISTRIBUTION" == "oracle" && "$JDK_VERSION" -lt 17 ]]; then | |
echo "Oracle JDK requires version 17 or later. Retrying..." | |
elif [[ "$RUNNER_OS" == "macOS" && "$RUNNER_ARCH" == "ARM64" && "$JDK_VERSION" -lt 11 ]]; then | |
echo "Apple Silicon (arm64) requires JDK 11 or later. Retrying..." | |
elif [[ "$RUNNER_OS" == "macOS" && "$RUNNER_ARCH" == "ARM64" && "$JDK_DISTRIBUTION" == semeru ]]; then | |
echo "Apple Silicon (arm64) has problems with semeru. Retrying..." | |
elif [[ "$RUNNER_OS" == "macOS" && "$JDK_DISTRIBUTION" == dragonwell ]]; then | |
echo "Apple Silicon has problems with dragonwell. Retrying..." | |
elif [[ "$JDK_VERSION" == "22" && "$JDK_DISTRIBUTION" == dragonwell ]]; then | |
echo "No dragonwell 22. Retrying..." | |
else | |
echo "Selected JDK version: $JDK_VERSION" | |
echo "Selected JDK distribution: $JDK_DISTRIBUTION" | |
echo "Running on: $RUNNER_OS $RUNNER_ARCH" | |
echo "JDK_VERSION=$JDK_VERSION" >> $GITHUB_ENV | |
echo "JDK_DISTRIBUTION=$JDK_DISTRIBUTION" >> $GITHUB_ENV | |
break | |
fi | |
done | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: ${{ env.JDK_DISTRIBUTION }} | |
java-version: ${{ env.JDK_VERSION }} | |
cache: sbt | |
- uses: sbt/setup-sbt@v1 | |
- name: Cache SBT | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.ivy2/cache | |
~/.sbt | |
~/.coursier | |
~/.cache/coursier | |
key: sbt-${{ matrix.os }}-${{ env.JDK_DISTRIBUTION }}-${{ env.JDK_VERSION }}-${{ hashFiles('**/*.sbt') }} | |
restore-keys: | | |
sbt-${{ matrix.os }}-${{ env.JDK_DISTRIBUTION }}-${{ env.JDK_VERSION }}- | |
- name: Clone scala-graph and publishM2 (for Java8 and Scala Native) | |
run: | | |
git clone https://github.com/mio-19/scala-graph | |
cd scala-graph | |
git checkout 6381eb20c8595f5507410f4e2bfa9e27b8d88a30 | |
sbt publishM2 | |
- name: SBT Clean | |
run: sbt clean | |
continue-on-error: true | |
- name: Run Tests | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 25 | |
max_attempts: 3 | |
shell: bash | |
command: sbt test |