Update validate.yml: bump action versions, fix schema caching #5
This file contains hidden or 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: 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 | |
| curl -fsSL -o schemas/recipe.json https://json.schemastore.org/minecraft-recipe.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/*/advancements/**/*.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 | |
| - name: Verify Recipes | |
| run: | | |
| python3 -c 'from glob import glob;open("globs.txt","w").writelines(f+"\n" for f in glob("BoxedDataPack/data/*/recipes/**/*.json",recursive=True))' | |
| yajsv -s schemas/recipe.json -q -l globs.txt | |
| rm globs.txt |