Repository navigation
106 lines (93 loc) · 3.81 KB
/
Copy pathvalidate.yml
File metadata and controls
106 lines (93 loc) · 3.81 KB
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
name: Validate Datapack
on:
push:
pull_request:
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: false # only caches go projects, not general go pkgs
- name: get go cache env
id: go-cache-env
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "GOMODCACHE<<$EOF" >> $GITHUB_ENV
go env GOMODCACHE >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
echo "GOCACHE<<$EOF" >> $GITHUB_ENV
go env GOCACHE >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: cache go
uses: actions/cache@v4
with:
path: |
${{env.GOMODCACHE}}
${{env.GOCACHE}}
key: ${{ runner.os }}-gomod
- name: install yajsv
run: go install github.com/neilpa/yajsv@v1.4.1
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: get cache week
id: week
run: echo "value=$(date +%Y-%U)" >> $GITHUB_OUTPUT
- name: cache schemas
id: cache-schemas
uses: actions/cache@v4
with:
path: schemas/
key: ${{ runner.os }}-schemas-${{ steps.week.outputs.value }}
- name: fetch schemas
if: steps.cache-schemas.outputs.cache-hit != 'true'
run: |
curl -fsSL -o schemas/advancement.json https://json.schemastore.org/minecraft-advancement.json
curl -fsSL -o schemas/tag.json https://json.schemastore.org/minecraft-tag.json
# pack-mcmeta.json is maintained locally (schemastore version is outdated)
- name: Verify pack.mcmeta
run: yajsv -s schemas/pack-mcmeta.json -q "BoxedDataPack/pack.mcmeta"
- name: Verify Advancements
run: |
python3 -c 'from glob import glob;open("globs.txt","w").writelines(f+"\n" for f in glob("BoxedDataPack/data/*/advancement/**/*.json",recursive=True))'
yajsv -s schemas/advancement.json -q -l globs.txt
rm globs.txt
- name: Verify Tags
run: |
python3 -c 'from glob import glob;open("globs.txt","w").writelines(f+"\n" for f in glob("BoxedDataPack/data/*/tags/**/*.json",recursive=True))'
yajsv -s schemas/tag.json -q -l globs.txt
rm globs.txt
# The schemastore recipe schema is older than Minecraft 1.21.2, when ingredients became
# plain strings, so it rejects every current recipe. Until it catches up, recipes are
# only checked for being JSON with a type and a result. Loading the pack on a server is
# the real test.
- name: Verify Recipes
run: |
python3 - <<'PY'
import json, sys
from glob import glob
bad = []
files = glob("BoxedDataPack/data/*/recipe/**/*.json", recursive=True)
for f in files:
try:
j = json.load(open(f))
except ValueError as e:
bad.append(f"{f}: {e}")
continue
if "type" not in j or "result" not in j:
bad.append(f"{f}: needs a type and a result")
print(f"{len(files)} recipes checked")
if bad:
print("\n".join(bad))
sys.exit(1)
PY
# Folders had plural names before Minecraft 1.21 and are ignored by the game now
- name: No old folder names
run: |
if { find BoxedDataPack/data -mindepth 2 -maxdepth 2 -type d \( -name advancements -o -name recipes \); find BoxedDataPack/data -mindepth 3 -maxdepth 3 -type d -path '*/tags/*' \( -name items -o -name blocks -o -name entity_types \); } | grep . ; then
echo "These folders use names the game no longer reads"; exit 1
fi