-
-
Notifications
You must be signed in to change notification settings - Fork 44
174 lines (142 loc) · 5.04 KB
/
tools-data.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Test Tools Data
on:
schedule:
# At 03:07 on Saturday (because why not)
- cron: "7 3 * * 6"
workflow_dispatch:
env:
JAVA_VERSION: 17
GRAALVM_DIST: graalvm-community
JAVA_DISTRO: temurin
FAIL_ISSUE: 140
jobs:
cache-setup:
runs-on: ubuntu-latest
outputs:
cache_key: ${{ steps.test-data-key.outputs.cache_key }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Tools release cache key
id: test-data-key
run: |
LATEST_RELEASE=$(curl -sLH 'Accept: application/json' https://api.github.com/repos/5etools-mirror-1/5etools-mirror-1.github.io/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-5etools-${LATEST_VERSION}" >> $GITHUB_OUTPUT
- name: Check Cache Data
id: test-data-check
uses: actions/[email protected]
with:
path: sources/5etools-mirror-1.github.io
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"
ARTIFACT_URL="https://github.com/5etools-mirror-1/5etools-mirror-1.github.io/archive/refs/tags/$LATEST_VERSION.tar.gz"
VER=$(echo $LATEST_VERSION | cut -c 2-)
ROOT="5etools-mirror-1.github.io-$VER"
curl -LsS -o 5etools.tar.gz $ARTIFACT_URL
tar xzf 5etools.tar.gz ${ROOT}/data ${ROOT}/img
mv ${ROOT} sources/5etools-mirror-1.github.io
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@v4
with:
fetch-depth: 1
- uses: actions/cache/[email protected]
id: cache
with:
path: sources/5etools-mirror-1.github.io
key: ${{ needs.cache-setup.outputs.cache_key }}
fail-on-cache-miss: true
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
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
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@v4
with:
fetch-depth: 1
- uses: actions/cache/[email protected]
id: cache
with:
path: sources/5etools-mirror-1.github.io
key: ${{ needs.cache-setup.outputs.cache_key }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- uses: graalvm/setup-graalvm@v1
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@v4
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 }}