Skip to content

Commit e3b3323

Browse files
committed
👷 data actions
1 parent a1b4382 commit e3b3323

File tree

8 files changed

+249
-433
lines changed

8 files changed

+249
-433
lines changed

.github/actions/data-cache/action.yml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: 'Tools data cache'
2+
description: 'find latest release; construct cache key; fetch/build cache'
3+
4+
inputs:
5+
failIfMissing:
6+
description: "Should the job fail if missing"
7+
default: "false"
8+
9+
outputs:
10+
cache_key:
11+
description: Cache retrieval key
12+
value: ${{ steps.test_data.outputs.cache_key }}
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
18+
- name: 5eTools release cache key
19+
id: test_data
20+
shell: bash
21+
run: |
22+
LATEST_5E_VERSION=$(curl -sLH 'Accept: application/json' https://api.github.com/repos/5etools-mirror-3/5etools-src/releases/latest | jq -r .tag_name)
23+
LATEST_PF2E_VERSION=$(curl -sLH 'Accept: application/json' https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest | jq -r .tag_name)
24+
25+
LATEST_VERSION=5e.${LATEST_5E_VERSION}-Pf2e.${LATEST_PF2E_VERSION}
26+
PREFIX="TestData-"
27+
KEY=${PREFIX}${LATEST_VERSION}
28+
29+
echo "🔹 Use 5eTools $LATEST_5E_VERSION and Pf2eTools $LATEST_PF2E_VERSION"
30+
echo "cache_key_prefix=${PREFIX}" >> $GITHUB_OUTPUT
31+
echo "cache_key=${KEY}" >> $GITHUB_OUTPUT
32+
33+
echo "version_5e=${LATEST_5E_VERSION}" >> $GITHUB_OUTPUT
34+
echo "version_pf2e=${LATEST_PF2E_VERSION}" >> $GITHUB_OUTPUT
35+
36+
- name: Check Cache Data
37+
id: test_data_check
38+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
39+
with:
40+
path: sources
41+
key: ${{ steps.test_data.outputs.cache_key }}
42+
fail-on-cache-miss: ${{ inputs.failIfMissing == 'true' }}
43+
enableCrossOsArchive: true
44+
45+
- name: Download Test Data
46+
id: test-data-download
47+
if: steps.test_data_check.outputs.cache-hit != 'true'
48+
shell: bash
49+
env:
50+
LATEST_5E_VERSION: ${{ steps.test_data.outputs.version_5e }}
51+
LATEST_PF2E_VERSION: ${{ steps.test_data.outputs.version_pf2e }}
52+
GITHUB_TOKEN: ${{ github.token }}
53+
run: |
54+
echo "🔹 Download 5e $LATEST_5E_VERSION"
55+
56+
# sparse clone of src
57+
mkdir -p sources/5etools-src
58+
git clone --quiet --depth=1 -b ${LATEST_5E_VERSION} \
59+
-c advice.detachedHead=false \
60+
--no-checkout \
61+
https://github.com/5etools-mirror-3/5etools-src.git sources/5etools-src
62+
pushd sources/5etools-src
63+
git sparse-checkout init
64+
git sparse-checkout set data
65+
git checkout ${LATEST_5E_VERSION}
66+
rm -rf .git
67+
rm -f *.png
68+
rm -f *.html
69+
rm -f *.zip
70+
popd
71+
72+
mkdir -p sources/5etools-img
73+
gh release download ${LATEST_5E_VERSION} -D sources/5etools-img -R 5etools-mirror-3/5etools-img
74+
pushd sources/5etools-img
75+
zip -FF img-${LATEST_5E_VERSION}.zip --out fixed.zip
76+
unzip -q fixed.zip
77+
rm *.z*
78+
du -sh .
79+
# replace all images w/ empty files. We don't care about image content for test purposes
80+
find img -type f | while read FILE; do echo > "$FILE"; done
81+
mv img/* .
82+
du -sh .
83+
popd
84+
85+
echo "🔹 5eTools: Download Homebrew"
86+
87+
# Don't grab all of homebrew. Too big
88+
mkdir -p sources/5e-homebrew/adventure
89+
mkdir -p sources/5e-homebrew/background
90+
mkdir -p sources/5e-homebrew/book
91+
mkdir -p sources/5e-homebrew/class
92+
mkdir -p sources/5e-homebrew/collection
93+
mkdir -p sources/5e-homebrew/creature
94+
mkdir -p sources/5e-homebrew/deity
95+
mkdir -p sources/5e-homebrew/optionalfeature
96+
mkdir -p sources/5e-homebrew/race
97+
mkdir -p sources/5e-homebrew/subclass
98+
99+
paths=(
100+
"collection/MCDM Productions; Strongholds and Followers.json"
101+
"adventure/Anthony Joyce; The Blood Hunter Adventure.json"
102+
"adventure/Arcanum Worlds; Odyssey of the Dragonlords.json"
103+
"adventure/JVC Parry; Call from the Deep.json"
104+
"adventure/Kobold Press; Book of Lairs.json"
105+
"background/D&D Wiki; Featured Quality Backgrounds.json"
106+
"book/Ghostfire Gaming; Grim Hollow Campaign Guide.json"
107+
"book/Ghostfire Gaming; Stibbles Codex of Companions.json"
108+
"book/MCDM Productions; Arcadia Issue 3.json"
109+
"class/D&D Wiki; Swashbuckler.json"
110+
"class/Foxfire94; Vampire.json"
111+
"class/KibblesTasty; Inventor.json"
112+
"class/LaserLlama; Alternate Barbarian.json"
113+
"class/Matthew Mercer; Blood Hunter (2022).json"
114+
"class/badooga; Badooga's Psion.json"
115+
"collection/Arcana Games; Arkadia.json"
116+
"collection/Ghostfire Gaming; Grim Hollow - The Monster Grimoire.json"
117+
"collection/Jasmine Yang; Hamund's Herbalism Handbook.json"
118+
"collection/Keith Baker; Exploring Eberron.json"
119+
"collection/Kobold Press; Deep Magic 14 Elemental Magic.json"
120+
"collection/Kobold Press; Deep Magic.json"
121+
"collection/Loot Tavern; Heliana's Guide To Monster Hunting.json"
122+
"collection/MCDM Productions; The Talent and Psionics Open Playtest Round 2.json"
123+
"collection/Mage Hand Press; Valda's Spire of Secrets.json"
124+
"creature/Dragonix; Monster Manual Expanded III.json"
125+
"creature/Kobold Press; Creature Codex.json"
126+
"creature/Kobold Press; Tome of Beasts 2.json"
127+
"creature/Kobold Press; Tome of Beasts.json"
128+
"creature/MCDM Productions; Flee, Mortals! preview.json"
129+
"creature/MCDM Productions; Flee, Mortals!.json"
130+
"creature/Nerzugal Role-Playing; Nerzugal's Extended Bestiary.json"
131+
"deity/Frog God Games; The Lost Lands.json"
132+
"optionalfeature/laserllama; Laserllama's Exploit Compendium.json"
133+
"race/Middle Finger of Vecna; Archon.json"
134+
"subclass/LaserLlama; Druid Circles.json"
135+
)
136+
137+
for i in "${paths[@]}"; do
138+
echo "$i"
139+
url=${i// /%20}
140+
echo "$url"
141+
curl -s -S -L -o "sources/5e-homebrew/$i" "https://raw.githubusercontent.com/TheGiddyLimit/homebrew/refs/heads/master/${url}"
142+
done
143+
144+
echo "🔹 5eTools: Download Unearthed Arcana"
145+
146+
# Don't grab all of unearthed arcana
147+
mkdir -p sources/5e-unearthed-arcana/collection
148+
149+
paths=(
150+
"collection/Unearthed Arcana - Downtime.json"
151+
"collection/Unearthed Arcana - Encounter Building.json"
152+
"collection/Unearthed Arcana - Into the Wild.json"
153+
"collection/Unearthed Arcana - Quick Characters.json"
154+
"collection/Unearthed Arcana - Traps Revisited.json"
155+
"collection/Unearthed Arcana - When Armies Clash.json"
156+
"collection/Unearthed Arcana 2022 - Character Origins.json"
157+
"collection/Unearthed Arcana 2022 - Expert Classes.json"
158+
"collection/Unearthed Arcana 2022 - The Cleric and Revised Species.json"
159+
"collection/Unearthed Arcana 2023 - Bastions and Cantrips.json"
160+
"collection/Unearthed Arcana 2023 - Druid & Paladin.json"
161+
"collection/Unearthed Arcana 2023 - Player's Handbook Playtest 5.json"
162+
"collection/Unearthed Arcana 2023 - Player's Handbook Playtest 6.json"
163+
"collection/Unearthed Arcana 2023 - Player's Handbook Playtest 7.json"
164+
)
165+
166+
for i in "${paths[@]}"; do
167+
echo "$i"
168+
url=${i// /%20}
169+
echo "$url"
170+
curl -s -S -L -o "sources/5e-unearthed-arcana/$i" "https://raw.githubusercontent.com/TheGiddyLimit/unearthed-arcana/refs/heads/master/${url}"
171+
done
172+
173+
echo "🔹 Pf2eTools Download ${LATEST_PF2E_VERSION}"
174+
175+
# sparse clone of src
176+
mkdir -p sources/Pf2eTools
177+
git clone --quiet --depth=1 -b ${LATEST_PF2E_VERSION} \
178+
-c advice.detachedHead=false \
179+
--no-checkout \
180+
https://github.com/Pf2eToolsOrg/Pf2eTools.git sources/Pf2eTools
181+
pushd sources/Pf2eTools
182+
git sparse-checkout init
183+
git sparse-checkout set data img
184+
git checkout ${LATEST_VERSION}
185+
rm -rf .git
186+
rm -f *.png
187+
rm -f *.html
188+
rm -f *.xml
189+
find img -type f | while read FILE; do echo > "$FILE"; done
190+
popd
191+
192+
ls -al sources
193+
du -sh sources
194+
195+
- name: Always Save Cache
196+
id: test_data_save
197+
if: always() && steps.test_data_check.outputs.cache-hit != 'true'
198+
uses: actions/cache/save@v4
199+
with:
200+
key: ${{ steps.test_data.outputs.cache_key }}
201+
path: sources
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'Fetch Tools data cache'
2+
description: 'Fetch cache using known key'
3+
4+
inputs:
5+
cache_key:
6+
description: Key for data cache
7+
required: true
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
13+
- id: cache_restore
14+
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
15+
with:
16+
path: sources
17+
key: ${{ inputs.cache_key }}
18+
fail-on-cache-miss: true
19+
enableCrossOsArchive: true
20+
restore-keys: |
21+
"TestData-"

.github/workflows/maven.yml

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,11 @@ jobs:
3939
metadata:
4040
uses: ebullient/workflows/.github/workflows/java-snap-metadata.yml@main
4141

42-
tools5e_cache:
43-
uses: ./.github/workflows/tools5e-data-cache.yml
44-
45-
pf2e_cache:
46-
uses: ./.github/workflows/pf2e-data-cache.yml
47-
4842
build:
4943
runs-on: ubuntu-latest
50-
needs: [main_root, metadata, tools5e_cache, pf2e_cache]
44+
needs: [main_root, metadata]
45+
outputs:
46+
cache_key: ${{ steps.data_cache.outputs.cache_key }}
5147
permissions:
5248
contents: write
5349
actions: write
@@ -58,19 +54,8 @@ jobs:
5854
fetch-depth: 0
5955
fetch-tags: false
6056

61-
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
62-
id: tools5e-cache-load
63-
with:
64-
path: sources
65-
key: ${{ needs.tools5e_cache.outputs.cache_key }}
66-
restore-keys: ${{ needs.tools5e_cache.outputs.restore_key }}
67-
68-
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
69-
id: pf2e-cache-load
70-
with:
71-
path: sources/Pf2eTools
72-
key: ${{ needs.pf2e_cache.outputs.cache_key }}
73-
restore-keys: ${{ needs.pf2e_cache.outputs.restore_key }}
57+
- uses: ./.github/actions/data-cache
58+
id: data_cache
7459

7560
- name: Build with Maven
7661
uses: ebullient/workflows/.github/actions/maven-build@main
@@ -87,7 +72,7 @@ jobs:
8772
files: "README.md README-WINDOWS.md docs"
8873

8974
native-build:
90-
needs: [metadata, tools5e_cache, pf2e_cache, build]
75+
needs: [metadata, build]
9176
name: Build ${{ matrix.os }} binary
9277
runs-on: ${{ matrix.os }}
9378
concurrency:
@@ -107,21 +92,9 @@ jobs:
10792
with:
10893
fetch-depth: 1
10994

110-
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
111-
id: tools5e-cache-load
112-
with:
113-
path: sources
114-
key: ${{ needs.tools5e_cache.outputs.cache_key }}
115-
restore-keys: ${{ needs.tools5e_cache.outputs.restore_key }}
116-
enableCrossOsArchive: true
117-
118-
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
119-
id: pf2e-cache-load
95+
- uses: ./.github/actions/native-data-cache
12096
with:
121-
path: sources/Pf2eTools
122-
key: ${{ needs.pf2e_cache.outputs.cache_key }}
123-
restore-keys: ${{ needs.pf2e_cache.outputs.restore_key }}
124-
enableCrossOsArchive: true
97+
cache_key: ${{ needs.build.outputs.cache_key }}
12598

12699
- name: Native build with Maven
127100
uses: ebullient/workflows/.github/actions/native-build@main

.github/workflows/pf2e-data-cache.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)