Test Tools Data #187
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 Tools Data | |
on: | |
schedule: | |
# At 03:07 on Saturday (because why not) | |
- cron: "7 3 * * 6" | |
workflow_dispatch: | |
env: | |
JAVA_VERSION: 17 | |
JAVA_DISTRO: temurin | |
NATIVE_JAVA_VERSION: 21 | |
GRAALVM_DIST: graalvm-community | |
FAIL_ISSUE: 140 | |
permissions: read-all | |
jobs: | |
cache-setup: | |
runs-on: ubuntu-latest | |
outputs: | |
cache_key: ${{ steps.test-data-key.outputs.cache_key }} | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 1 | |
- name: Tools release cache key | |
id: test-data-key | |
run: | | |
LATEST_VERSION=$(curl -sLH 'Accept: application/json' https://api.github.com/repos/5etools-mirror-3/5etools-src/releases/latest | jq -r .tag_name) | |
echo $LATEST_VERSION | |
echo "🔹 Use $LATEST_VERSION" | |
echo "tools_version=${LATEST_VERSION}" >> $GITHUB_OUTPUT | |
echo "cache_key=Data-5etools-${LATEST_VERSION}" >> $GITHUB_OUTPUT | |
- name: Check Cache Data | |
id: test-data-check | |
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | |
with: | |
path: sources | |
key: ${{ steps.test-data-key.outputs.cache_key }} | |
lookup-only: true | |
enableCrossOsArchive: true | |
- name: Download Test Data | |
id: test-data-download | |
if: steps.test-data-check.outputs.cache-hit != 'true' | |
env: | |
LATEST_VERSION: ${{ steps.test-data-key.outputs.tools_version }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mkdir -p sources | |
echo "🔹 Download $LATEST_VERSION" | |
gh repo clone 5etools-mirror-3/5etools-src sources/5etools-src -- --depth=1 -c advice.detachedHead=false -b $LATEST_VERSION | |
gh repo clone 5etools-mirror-3/5etools-img sources/5etools-img -- --depth=1 -c advice.detachedHead=false -b $LATEST_VERSION | |
gh repo clone TheGiddyLimit/unearthed-arcana sources/5e-unearthed-arcana -- --depth=1 | |
gh repo clone TheGiddyLimit/homebrew sources/5e-homebrew -- --depth=1 | |
# Remove image contents. We just need the files to exist (linking) | |
find sources -type f -type f \ | |
\( -iname \*.jpg -o -iname \*.png -o -iname \*.webp \) \ | |
| while read FILE; do echo > "$FILE"; done | |
ls -al sources | |
test-with-data: | |
name: Test with data | |
needs: cache-setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 1 | |
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | |
id: cache | |
with: | |
path: sources | |
key: ${{ needs.cache-setup.outputs.cache_key }} | |
fail-on-cache-miss: true | |
- name: Set up JDK ${{ env.JAVA_VERSION }} | |
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: ${{ env.JAVA_DISTRO }} | |
cache: maven | |
- name: Build with Maven | |
id: mvn-build | |
run: | | |
ls -al sources | |
./mvnw -B -ntp -DskipFormat verify | |
native-test-with-data: | |
name: Test on ${{ matrix.os }} | |
needs: [cache-setup, test-with-data] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
max-parallel: 1 | |
matrix: | |
os: [windows-latest, macos-latest, ubuntu-latest] | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 1 | |
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | |
id: cache | |
with: | |
path: sources | |
key: ${{ needs.cache-setup.outputs.cache_key }} | |
fail-on-cache-miss: true | |
enableCrossOsArchive: true | |
- uses: graalvm/setup-graalvm@4a200f28cd70d1940b5e33bd00830b7dc71a7e2b # v1.2.6 | |
with: | |
distribution: ${{ env.GRAALVM_DIST }} | |
java-version: ${{ env.NATIVE_JAVA_VERSION }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
cache: 'maven' | |
- if: runner.os == 'Windows' | |
name: clean before native build | |
shell: cmd | |
run: | | |
./mvnw -B -ntp -DskipTests -DskipFormat clean | |
- name: Build, run, and test in native mode | |
id: mvn-native-build | |
run: | | |
./mvnw -B -ntp -Dnative -DskipFormat verify | |
report-native-build: | |
name: Report errors | |
runs-on: ubuntu-latest | |
if: ${{ failure() }} | |
needs: [test-with-data, native-test-with-data] | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 1 | |
- id: gh-issue | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh issue comment ${{ env.FAIL_ISSUE }} --body "[Maven build failed: ${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" | |
gh issue reopen ${{ env.FAIL_ISSUE }} |