Build and verify central pack candidates in development CI

This commit is contained in:
unimatrixgit 2026-11-28 14:34:50 +01:00
commit 09cba2e732
3 changed files with 64 additions and 4 deletions

View file

@ -1,5 +1,6 @@
name: DuneRealms Resourcepack CI
on:
workflow_dispatch:
push:
branches: [main]
paths:
@ -16,6 +17,7 @@ on:
- '.forgejo/workflows/resourcepack-ci.yml'
jobs:
resourcepack:
if: github.repository == 'unimatrix/MC' && github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: dune-ci
steps:
- name: Checkout exact reviewed revision
@ -63,3 +65,46 @@ jobs:
JarvisConnector/build/libs/jarvistranslator.jar
if-no-files-found: error
retention-days: 7
central-pack-development:
if: github.repository == 'dev/MC' && github.event_name == 'workflow_dispatch'
runs-on: dune-ci
steps:
- name: Check out exact development revision
shell: bash
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
git init .
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 "https://www.dunerealms.com/git/${GITHUB_REPOSITORY}.git" "$GITHUB_SHA"
git checkout --detach FETCH_HEAD
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Verify baseline and build a central pack candidate
shell: bash
run: |
set -euo pipefail
node --test tools/build-planet-texture-packs.test.mjs
curl --fail --location --retry 2 https://www.dunerealms.com/downloads/DuneRealms-Network-Artwork-v3.zip -o central-pack-baseline.zip
python3 - <<'PYTHON'
import pathlib
import runpy
repair = runpy.run_path('tools/build-resourcepack-repair.py')
entries = repair['read_pack'](pathlib.Path('central-pack-baseline.zip'), repair['OLD_NETWORK'])
for name, data in repair['world_artwork'](entries).items():
target = pathlib.Path('central-pack-base') / name
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(data)
PYTHON
node tools/build-central-resource-pack.mjs central-pack-base central-pack-output 1
printf '%s\n' "$GITHUB_SHA" > central-pack-output/SOURCE_COMMIT
(cd central-pack-output && sha256sum -- *.zip central-pack-manifest.json SOURCE_COMMIT > SHA256SUMS)
- uses: actions/upload-artifact@v3
with:
name: DuneRealms-Central-Pack-Development
path: central-pack-output/
if-no-files-found: error
retention-days: 7

View file

@ -14,6 +14,11 @@ if(new Set(cubeItems).size!==cubeItems.length||cubeItems.some(item=>!/^[a-z0-9_]
const json=value=>Buffer.from(JSON.stringify(value));
const hash=(algorithm,bytes)=>createHash(algorithm).update(bytes).digest('hex');
function addEntry(entries,name,bytes){
if(entries.has(name)&&!entries.get(name).equals(bytes))throw Error('Conflicting pack entry: '+name);
entries.set(name,bytes);
}
export function centralPackEntries(base){
const merged=new Map(base);
if(!merged.has('pack.mcmeta'))throw Error('The base must be an extracted network resource pack');
@ -29,8 +34,7 @@ export function centralPackEntries(base){
const target=name.startsWith(texturePrefix)
?packPrefix+planet+'/'+name.slice(texturePrefix.length)
:'licenses/planet-materials/'+name;
if(merged.has(target)&&!merged.get(target).equals(bytes))throw Error('Conflicting pack entry: '+target);
merged.set(target,bytes);
addEntry(merged,target,bytes);
}
for(const material of cubeItems){
const id=planet+'/'+material;
@ -43,8 +47,8 @@ export function centralPackEntries(base){
sprites.set(texture,texture);
}
}
merged.set('assets/dunerealms/items/planets/'+id+'.json',json({model:{type:'minecraft:model',model:'dunerealms:item/planets/'+id}}));
merged.set('assets/dunerealms/models/item/planets/'+id+'.json',json({
addEntry(merged,'assets/dunerealms/items/planets/'+id+'.json',json({model:{type:'minecraft:model',model:'dunerealms:item/planets/'+id}}));
addEntry(merged,'assets/dunerealms/models/item/planets/'+id+'.json',json({
parent:'minecraft:block/cube_all',textures:{all:texture}
}));
}

View file

@ -85,3 +85,14 @@ test('the central pack registers its planet block sprites without replacing exis
for(const planet of ['arrakis','caladan'])assert(sprites.has('dunerealms:planets/'+planet+'/block/stone'));
assert.deepEqual(centralPackEntries(entries).get(atlasPath),entries.get(atlasPath));
});
test('central generation refuses to overwrite a different item definition or model',()=>{
const metadata=Buffer.from(JSON.stringify({pack:{pack_format:64}}));
const generated=centralPackEntries(new Map([['pack.mcmeta',metadata]]));
for(const prefix of ['items','models/item']){
const file='assets/dunerealms/'+prefix+'/planets/arrakis/stone.json';
assert(generated.has(file));
assert.throws(()=>centralPackEntries(new Map([['pack.mcmeta',metadata],[file,Buffer.from('{}')]])),
error=>error.message==='Conflicting pack entry: '+file);
}
});