Skip to content

Pf2e Tools Data

Pf2e Tools Data #79

name: Pf2e Tools Data
on:
schedule:
# At 09:07 on Saturday (because why not)
- cron: "7 9 * * 6"
workflow_dispatch:
env:
JAVA_VERSION: 17
GRAALVM_DIST: graalvm-community
JAVA_DISTRO: temurin
FAIL_ISSUE: 141
permissions:
contents: read
actions: read
jobs:
cache-setup:
runs-on: ubuntu-latest
outputs:
cache_key: ${{ steps.test-data-key.outputs.cache_key }}
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Pf2e Tools release cache key
id: test-data-key
run: |
LATEST_RELEASE=$(curl -sLH 'Accept: application/json' https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest)
LATEST_VERSION=$(echo $LATEST_RELEASE | grep tag_name | sed -e 's/.*"tag_name": "\([^"]*\)".*/\1/')
echo $LATEST_VERSION
echo "🔹 Use $LATEST_VERSION"
echo "tools_version=${LATEST_VERSION}" >> $GITHUB_OUTPUT
echo "cache_key=Data-Pf2eTools-${LATEST_VERSION}" >> $GITHUB_OUTPUT
- name: Check Cache Data
id: test-data-check
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
with:
path: sources/Pf2eTools
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 }}
run: |
echo "🔹 Download $LATEST_VERSION"
ARTIFACT_URL="https://github.com/Pf2eToolsOrg/Pf2eTools/archive/refs/tags/$LATEST_VERSION.tar.gz"
VER=$(echo $LATEST_VERSION | cut -c 2-)
ROOT="Pf2eTools-$VER"
curl -LsS -o Pf2eTools.tar.gz $ARTIFACT_URL
tar xzf Pf2eTools.tar.gz ${ROOT}/data ${ROOT}/img
# Remove image contents. We just need the files to exist (linking)
find ${ROOT}/img -type f | while read FILE; do echo > "$FILE"; done
mkdir -p sources
rm -rf sources/Pf2eTools
mv ${ROOT} sources/Pf2eTools
test-with-data:
name: Test with data
needs: cache-setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/cache/restore@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
id: cache
with:
path: sources/Pf2eTools
key: ${{ needs.cache-setup.outputs.cache_key }}
fail-on-cache-miss: true
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
cache: maven
- name: Build with Maven
id: mvn-build
run: |
./mvnw -B -ntp -DskipFormat verify
- name: Delete snapshots artifacts from cache
run: find ~/.m2 -name \*-SNAPSHOT -type d -exec rm -rf {} +
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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- uses: actions/cache/restore@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
id: cache
with:
path: sources/Pf2eTools
key: ${{ needs.cache-setup.outputs.cache_key }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- uses: graalvm/setup-graalvm@d3f9e14fc3771c0f5aaccb754e441b946b6703f9 # v1.1.8.2
with:
distribution: ${{ env.GRAALVM_DIST }}
java-version: ${{ env.JAVA_VERSION }}
components: "native-image"
cache: 'maven'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build and run
id: mvn-build
env:
MAVEN_OPTS: "-Xmx1g"
run: |
./mvnw -B -ntp -DskipFormat verify
- if: runner.os == 'Windows'
name: clean before native build
shell: cmd
run: |
./mvnw -B -ntp -DskipFormat clean
- name: Build and run in native mode
id: mvn-native-build
env:
MAVEN_OPTS: "-Xmx1g"
run: |
./mvnw -B -ntp -Dnative -DskipTests -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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- 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 }}