Compare commits

...
20 changed files with 286 additions and 155 deletions

No files matched your search

+36 -25
View File
@@ -31,13 +31,13 @@ jobs:
path: waozixyz/arcade
- name: Check release following
run: python3 tests/game_updates_test.py
- name: Pin the latest game releases
id: pin
- name: Find newer game releases
id: updates
env:
GH_TOKEN: ${{ github.token }}
run: |
python3 scripts/follow-game-releases.py pin
if git diff --quiet -- ziran.lock; then
python3 scripts/follow-game-releases.py check
if [ "$(python3 -c 'import json; print(len(json.load(open("build/game-updates.json"))))')" = 0 ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Arcade already pins every game's latest release."
exit 0
@@ -46,37 +46,48 @@ jobs:
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import json
lock = json.load(open('ziran.lock'))
shovey = lock['root']['dependencies']['shovey']
print('toolchain=' + lock['toolchain']['commit'])
PY
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
if: steps.updates.outputs.changed == 'true'
with:
repository: ziranlang/ziran
ref: ${{ steps.updates.outputs.toolchain }}
path: ziranlang/ziran
- name: Install build dependencies
if: steps.updates.outputs.changed == 'true'
working-directory: .
run: sh ziranlang/ziran/scripts/ci_packages.sh build-essential python3-pil python3-cryptography
- name: Build the locked toolchain and pin game dependencies
id: pin
if: steps.updates.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
make -j2 -C ../../ziranlang/ziran
echo "$GITHUB_WORKSPACE/ziranlang/ziran/build/bin" >> "$GITHUB_PATH"
python3 scripts/follow-game-releases.py pin --ziran ../../ziranlang/ziran/build/bin/ziran
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import json
lock = json.load(open('ziran.lock'))
shovey = lock['root']['dependencies']['shovey']
print('shovey=' + next(p['commit'] for p in lock['packages'] if p['id'] == shovey))
PY
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
if: steps.pin.outputs.changed == 'true'
with:
repository: ziranlang/ziran
ref: ${{ steps.pin.outputs.toolchain }}
path: ziranlang/ziran
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
if: steps.pin.outputs.changed == 'true'
if: steps.updates.outputs.changed == 'true'
with:
repository: waozixyz/shovey
ref: ${{ steps.pin.outputs.shovey }}
path: waozixyz/shovey
- name: Install build dependencies
if: steps.pin.outputs.changed == 'true'
working-directory: .
run: sh ziranlang/ziran/scripts/ci_packages.sh build-essential python3-pil python3-cryptography
- name: Build the locked toolchain and fetch packages
if: steps.pin.outputs.changed == 'true'
- name: Fetch the updated packages
if: steps.updates.outputs.changed == 'true'
run: |
make -j2 -C ../../ziranlang/ziran
echo "$GITHUB_WORKSPACE/ziranlang/ziran/build/bin" >> "$GITHUB_PATH"
# The game is generated in its own checkout at the pinned release.
printf '[overrides]\nshovey = "../shovey"\nziran = "../../ziranlang/ziran"\n' > ziran.local.toml
../../ziranlang/ziran/build/bin/ziran fetch
- name: Write the Arcade release
id: release
if: steps.pin.outputs.changed == 'true'
if: steps.updates.outputs.changed == 'true'
run: |
python3 scripts/follow-game-releases.py changelog --ziran ../../ziranlang/ziran/build/bin/ziran
sh update_version.sh
@@ -84,7 +95,7 @@ jobs:
echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT"
head -12 CHANGELOG.md
- name: Build and check the collection
if: steps.pin.outputs.changed == 'true'
if: steps.updates.outputs.changed == 'true'
run: |
make -C ../shovey levels landscape
make collection
@@ -92,18 +103,18 @@ jobs:
python3 tests/publisher_test.py
- name: Commit the release
id: commit
if: steps.pin.outputs.changed == 'true'
if: steps.updates.outputs.changed == 'true'
env:
VERSION: ${{ steps.release.outputs.version }}
run: |
git config user.name Waozi
git config user.email [email protected]
git add ziran.lock CHANGELOG.md VERSION apps/versions.json assets/arcade/library
git add ziran.toml ziran.lock CHANGELOG.md VERSION apps/versions.json assets/arcade/library
git commit -q -m "Release Arcade $VERSION with the latest game releases"
git push origin HEAD:master
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Attach the checked catalog and game archive
if: steps.pin.outputs.changed == 'true'
if: steps.updates.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.release.outputs.version }}
+14
View File
@@ -1,5 +1,19 @@
# Arcade changelog
## 0.7.88
- Apfelwurm 0.2.0: Play with softer Dusk, Forest and Sage themes, with saved sound and control settings.
- Apfelwurm 0.2.0: See a continuous painted meadow instead of a repeating grass grid, and clear Profile and Dew icons on the title.
- Apfelwurm 0.2.0: Sign in through the shared Profile to sync completed levels, playtime, settings and your chosen character across devices.
- Apfelwurm 0.2.0: Browse the skin shop from the title beside Profile and your Dew balance. Mint, Berry and Rose cost 10, 20 and 30 Dew, with confirmation before buying.
- Apfelwurm 0.2.0: Earn Night owl after five hours of active play, Golden apple by reaching level 40, and Explorer by visiting waozi.xyz. Purchased skins belong to your account.
- Apfelwurm 0.2.0: Unlock all 200 levels by playing. The mobile selector shows large previews for unlocked levels and only a lock for later ones. Dew is used for optional cosmetics.
## 0.7.87
- Open the game library faster with smaller cached cover thumbnails for every game.
- Keep covers sharp and logos transparent while downloading much less artwork.
## 0.7.86
- Shovey 0.6.154: Keep opened chests open across restarts and account sync; show the blue Dew diamond only while their reward is unclaimed.
+1 -1
View File
@@ -13,7 +13,7 @@ existing saved games remain available for a later return.
Each edition has a separate save and earned unlocks. Unlocked puzzles show
their whole board; locked puzzles keep their lock until earned.
The published Arcade carries only its catalog, well under one megabyte. Its host supplies the shared Apps controller (Inner Breeze its own, standalone Arcade the `apps.zx` installed beside it), and the covers and previews download once as one separate art bundle. Title screens and logos keep their original resolution and full colours; only library previews use small copies. The art lives in `assets/arcade/library/` (`python3 scripts/library-art.py` refreshes it when a game's art changes; the build stops until it does). Inner Breeze needs host interface 35 for it. Each game
The published Arcade carries only its catalog, well under one megabyte. Its host supplies the shared Apps controller (Inner Breeze its own, standalone Arcade the `apps.zx` installed beside it), and the covers and previews download once as one separate art bundle. Library covers use thumbnails up to 640 pixels on their longest side, and logos up to 512 pixels, preserving full colours and transparency. Games keep their original artwork. The verified art bundle stays cached across restarts and is replaced when its content changes. The art lives in `assets/arcade/library/` (`python3 scripts/library-art.py` refreshes it when a game's art changes; the build stops until it does). Inner Breeze needs host interface 35 for it. Each game
downloads when opened, with its existing identity and saved progress. This
catalog requires Inner Breeze host API 34. Downloaded games work offline;
standalone Shovey keeps its complete offline collection. Apfelwurm comes from
+1 -1
View File
@@ -1 +1 @@
0.7.86
0.7.88
+4 -4
View File
@@ -34,15 +34,15 @@
"arcade": {
"id": "inbe.arcade",
"title": "Arcade",
"version": "0.7.86",
"sequence": 165,
"version": "0.7.88",
"sequence": 167,
"host_api": 36
},
"wurm": {
"id": "xyz.waozi.wurm",
"title": "Apfelwurm",
"version": "0.1.8",
"sequence": 6,
"version": "0.2.0",
"sequence": 7,
"host_api": 12
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 458 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 444 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 516 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 429 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 559 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 461 KiB

+2 -2
View File
@@ -22,8 +22,8 @@ def digest(path):
def library_art(root, name, key, source):
"""Arcade's committed library art (scripts/library-art.py): original title
screens and logos, small previews. Never pack a copy of outdated art."""
"""Arcade's committed library thumbnails (scripts/library-art.py).
Never pack a copy of outdated art."""
library = Path(root) / "assets/arcade/library"
sources = json.loads((library / "sources.json").read_text())
copy = f"{name}-{key}"
+52 -46
View File
@@ -1,11 +1,11 @@
#!/usr/bin/env python3
"""Follow the published releases of Arcade's game packages.
`pin` moves each game package in ziran.lock to the commit of its repository's
latest published GitHub release, when that commit is ahead of the current pin.
Only the game's own entry changes: its dependencies keep Arcade's pins, so the
games build against the same Kryon and Apps as Arcade. The ids and layout are
the ones `ziran lock` writes. The updates are recorded in build/game-updates.json.
`check` records newer published game releases without changing dependencies.
`pin` selects their exact commits in ziran.toml and asks Ziran to update each
game and its transitive dependencies. New game imports must reach the lock;
unrelated packages and the compiler stay pinned. The updates are recorded in
build/game-updates.json.
`changelog` adds an Arcade release entry naming each updated game with the
notes of its newest release, for update_version.sh to synchronize.
@@ -26,31 +26,6 @@ ROOT = Path(__file__).resolve().parents[1]
UPDATES = ROOT / 'build/game-updates.json'
def package_id(url, commit):
"""The id `ziran lock` gives a source at a commit (PkgSourceId)."""
return 'p' + hashlib.sha256((url + '\n' + commit).encode()).hexdigest()[:16]
def write_lock(lock):
"""The lock as Ziran writes it: sorted keys, one-line maps, packages kept
in their order."""
def value(item):
if isinstance(item, dict):
return '{' + ', '.join(json.dumps(k) + ': ' + json.dumps(item[k]) for k in sorted(item)) + '}'
return json.dumps(item)
def block(item, indent):
pad = ' ' * indent
fields = [pad + ' ' + json.dumps(k) + ': ' + value(item[k]) for k in sorted(item)]
return pad + '{\n' + ',\n'.join(fields) + '\n' + pad + '}'
text = '{\n "format": ' + json.dumps(lock['format']) + ',\n "packages": [\n'
text += ',\n'.join(block(item, 4) for item in lock['packages']) + '\n ],\n'
text += ' "root": ' + block(lock['root'], 2).lstrip() + ',\n'
text += ' "toolchain": ' + block(lock['toolchain'], 2).lstrip() + '\n}\n'
return text
def gh(*args):
return subprocess.check_output(['gh', *args], text=True).strip()
@@ -62,11 +37,8 @@ def repository(url):
return match[1]
def pin():
lock_path = ROOT / 'ziran.lock'
lock = json.loads(lock_path.read_text())
if write_lock(lock) != lock_path.read_text():
raise SystemExit('ziran.lock is not in the layout ziran lock writes')
def released_updates():
lock = json.loads((ROOT / 'ziran.lock').read_text())
names = json.loads((ROOT / 'games.json').read_text())['packages']
updates = []
for name in names:
@@ -75,6 +47,8 @@ def pin():
repo = repository(entry['url'])
tag = gh('release', 'view', '--repo', repo, '--json', 'tagName', '--jq', '.tagName')
commit = gh('api', f'repos/{repo}/commits/{tag}', '--jq', '.sha')
if not re.fullmatch(r'[0-9a-f]{40}', commit):
raise SystemExit(f'{name}: invalid release commit')
if commit == entry['commit']:
continue
# Release metadata can be recorded before the game is published.
@@ -84,20 +58,50 @@ def pin():
if status != 'ahead':
print(f'{name}: release {tag} is {status} of the pinned {entry["commit"][:12]}; kept')
continue
new_id = package_id(entry['url'], commit)
entry['commit'] = commit
entry['id'] = new_id
for owner in [lock['root'], *lock['packages']]:
for alias, target in owner['dependencies'].items():
if target == old_id:
owner['dependencies'][alias] = new_id
updates.append({'name': name, 'repository': repo, 'tag': tag, 'commit': commit})
print(f'{name}: {repo} {tag} ({commit[:12]})')
lock_path.write_text(write_lock(lock))
return updates
def record_updates(updates):
UPDATES.parent.mkdir(parents=True, exist_ok=True)
UPDATES.write_text(json.dumps(updates, indent=2) + '\n')
def pin(ziran):
updates = released_updates()
manifest = ROOT / 'ziran.toml'
lock_path = ROOT / 'ziran.lock'
original_manifest = manifest.read_bytes()
original_lock = lock_path.read_bytes()
try:
for update in updates:
name, commit = update['name'], update['commit']
# Edit the declaration; only the package manager writes the graph.
section = re.compile(r'(^\[dependencies\.' + re.escape(name) +
r'\]\s*\n)([^\[]*)', re.M)
text = manifest.read_text()
match = section.search(text)
if match is None:
raise ValueError(f'{name}: missing dependency declaration')
body, count = re.subn(r'^ref[ \t]*=[ \t]*"[^"\n]*"[ \t]*$',
f'ref = "{commit}"', match[2], flags=re.M)
if count != 1:
raise ValueError(f'{name}: expected one dependency ref')
manifest.write_text(text[:match.start(2)] + body + text[match.end(2):])
subprocess.run([str(ziran), 'update', name], cwd=ROOT, check=True)
lock = json.loads(lock_path.read_text())
target = lock['root']['dependencies'][name]
entry = next(p for p in lock['packages'] if p['id'] == target)
if entry['commit'] != commit:
raise ValueError(f'{name}: Ziran did not select the released commit; remove its local override')
except BaseException:
manifest.write_bytes(original_manifest)
lock_path.write_bytes(original_lock)
raise
record_updates(updates)
def newest_notes(changelog):
"""The bullets of a changelog's newest numeric release."""
text = changelog.read_text()
@@ -147,11 +151,13 @@ def art():
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('command', choices=['pin', 'changelog', 'art'])
parser.add_argument('command', choices=['check', 'pin', 'changelog', 'art'])
parser.add_argument('--ziran', default=str(ROOT / 'scripts/ziran.sh'))
args = parser.parse_args()
if args.command == 'pin':
pin()
if args.command == 'check':
record_updates(released_updates())
elif args.command == 'pin':
pin(args.ziran)
elif args.command == 'changelog':
changelog(args.ziran)
else:
+19 -14
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
"""Stage each game's original title art and small library previews.
"""Stage bounded thumbnails for every game's library covers and previews.
Title screens and logos retain their original bytes, resolution, colours and
transparency. Only small library previews are resized and palette limited.
Arcade downloads the art separately from its small launcher.
Library covers retain full colour and transparency at thumbnail resolution.
Games keep their own original title artwork. Arcade downloads this small art
bundle separately from its launcher and caches it by its content digest.
The copies and sources.json, which records the SHA-256 of the art each copy
was made from, are committed. The collection build uses them as they are,
@@ -19,23 +19,28 @@ from game_packages import declared_packages
ROOT = Path(__file__).resolve().parents[1]
LIBRARY = ROOT / 'assets/arcade/library'
# Previews are small tiles and icons; full-screen artwork keeps its source.
PREVIEW_LONGEST = 480
COVER_LONGEST = 640
LOGO_LONGEST = 512
def small_copy(data, key):
if key != 'preview':
return data
image = Image.open(io.BytesIO(data))
image.load()
scale = min(1.0, PREVIEW_LONGEST / max(image.size))
longest = PREVIEW_LONGEST if key == 'preview' else LOGO_LONGEST if key == 'logo' else COVER_LONGEST
scale = min(1.0, longest / max(image.size))
if scale == 1.0 and key != 'preview':
return data
alpha = 'A' in image.getbands() or 'transparency' in image.info
image = image.convert('RGBA' if alpha else 'RGB')
if scale < 1.0:
size = (round(image.width * scale), round(image.height * scale))
image = image.convert('RGBA' if 'A' in image.getbands() else 'RGB').resize(size, Image.Resampling.LANCZOS)
if 'A' in image.getbands():
image = image.convert('RGBA').quantize(256, method=Image.Quantize.FASTOCTREE, dither=Image.Dither.FLOYDSTEINBERG)
else:
image = image.convert('RGB').quantize(256, dither=Image.Dither.FLOYDSTEINBERG)
size = (max(1, round(image.width * scale)), max(1, round(image.height * scale)))
image = image.resize(size, Image.Resampling.LANCZOS)
if key == 'preview':
if alpha:
image = image.quantize(256, method=Image.Quantize.FASTOCTREE, dither=Image.Dither.FLOYDSTEINBERG)
else:
image = image.quantize(256, dither=Image.Dither.FLOYDSTEINBERG)
output = io.BytesIO()
image.save(output, 'PNG', optimize=True)
return output.getvalue()
+49 -3
View File
@@ -1,6 +1,7 @@
"""Exercise packaging from the actual registered game builds, preserving bytes."""
import hashlib
import importlib.util
import io
import json
from pathlib import Path
import shlex
@@ -9,6 +10,7 @@ import tempfile
import unittest
import sys
import tarfile
from PIL import Image
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
@@ -91,7 +93,7 @@ class CollectionTests(unittest.TestCase):
with self.assertRaisesRegex(ValueError, "wurm-portrait art changed"):
self.stage()
def test_title_screens_keep_original_resolution_colours_and_transparency(self):
def test_every_library_cover_uses_a_bounded_thumbnail(self):
catalog, packages = builder.stage(self.root, self.controller, self.controller_digest, self.output)
children = {child['id']: child for child in catalog['children']}
for package in packages:
@@ -104,8 +106,15 @@ class CollectionTests(unittest.TestCase):
continue
original = (app['source'] / app['cover'][key]).read_bytes()
with self.subTest(app=child['id'], image=key):
self.assertEqual(artist.small_copy(original, key), original)
self.assertEqual((self.output / child['cover'][key]).read_bytes(), original)
with Image.open(io.BytesIO(original)) as source:
with Image.open(self.output / child['cover'][key]) as thumbnail:
limit = 512 if key == 'logo' else 640
self.assertLessEqual(max(thumbnail.size), limit)
self.assertLessEqual(thumbnail.width, source.width)
self.assertLessEqual(thumbnail.height, source.height)
self.assertAlmostEqual(thumbnail.width / thumbnail.height,
source.width / source.height, delta=0.01)
self.assertIn(thumbnail.mode, ('RGB', 'RGBA'))
def test_editor_download_reuses_verified_shovey_assets(self):
catalog = self.stage()
@@ -251,5 +260,42 @@ class CollectionTests(unittest.TestCase):
self.assertFalse(self.output.exists())
class LibraryThumbnailTests(unittest.TestCase):
def test_cover_keeps_full_colour_at_thumbnail_resolution(self):
source = Image.new('RGB', (900, 1200))
source.putdata([(x % 256, y % 256, (x + y) % 256)
for y in range(1200) for x in range(900)])
data = io.BytesIO()
source.save(data, 'PNG')
with Image.open(io.BytesIO(artist.small_copy(data.getvalue(), 'portrait'))) as thumbnail:
self.assertEqual(thumbnail.size, (480, 640))
self.assertEqual(thumbnail.mode, 'RGB')
self.assertIsNone(thumbnail.getcolors(256))
def test_logo_retains_transparency(self):
source = Image.new('RGBA', (1200, 400), (45, 155, 90, 0))
source.paste((200, 35, 100, 255), (100, 50, 1100, 350))
data = io.BytesIO()
source.save(data, 'PNG')
with Image.open(io.BytesIO(artist.small_copy(data.getvalue(), 'logo'))) as thumbnail:
self.assertEqual(thumbnail.size, (512, 171))
self.assertEqual(thumbnail.mode, 'RGBA')
self.assertEqual(thumbnail.getpixel((0, 0))[3], 0)
self.assertEqual(thumbnail.getpixel((256, 85))[3], 255)
def test_small_covers_are_neither_enlarged_nor_reencoded(self):
source = Image.new('RGB', (120, 180), (25, 50, 75))
data = io.BytesIO()
source.save(data, 'PNG')
self.assertEqual(artist.small_copy(data.getvalue(), 'portrait'), data.getvalue())
def test_thin_logos_keep_at_least_one_pixel(self):
source = Image.new('RGBA', (4096, 1), (25, 50, 75, 255))
data = io.BytesIO()
source.save(data, 'PNG')
with Image.open(io.BytesIO(artist.small_copy(data.getvalue(), 'logo'))) as thumbnail:
self.assertEqual(thumbnail.size, (512, 1))
if __name__ == "__main__":
unittest.main()
+71 -22
View File
@@ -1,8 +1,10 @@
"""Release metadata must not prevent Arcade from following the actual game source."""
"""Released games must bring new dependency edges without moving backwards."""
import importlib.util
import json
from pathlib import Path
import subprocess
import tempfile
import tomllib
import unittest
from unittest.mock import patch
@@ -13,47 +15,94 @@ spec.loader.exec_module(follower)
class GameUpdates(unittest.TestCase):
def follow(self, comparison, same_commit=False):
def follow(self, comparison, same_commit=False, failure=False, wrong_commit=False):
with tempfile.TemporaryDirectory(prefix='arcade-release-metadata-') as temporary:
root = Path(temporary)
(root / 'apps').mkdir()
old = '1' * 40
new = old if same_commit else '2' * 40
url = 'https://github.com/waozixyz/wurm.git'
identifier = follower.package_id(url, old)
lock = {'format': 1, 'toolchain': {}, 'root': {'dependencies': {'wurm': identifier}},
'packages': [{'id': identifier, 'name': 'Apfelwurm', 'url': url,
'commit': old, 'ref': 'master', 'dependencies': {}}]}
(root / 'ziran.lock').write_text(follower.write_lock(lock))
lock = {'format': 1, 'toolchain': {'commit': 'compiler'},
'root': {'dependencies': {'wurm': 'old', 'other': 'unrelated'}},
'packages': [{'id': 'old', 'name': 'Apfelwurm',
'url': 'https://github.com/waozixyz/wurm.git',
'commit': old, 'ref': 'master', 'dependencies': {}},
{'id': 'unrelated', 'commit': 'unchanged', 'dependencies': {}}]}
original_lock = json.dumps(lock)
(root / 'ziran.lock').write_text(original_lock)
original_manifest = ('[package]\nname = "Arcade"\n\n[dependencies.wurm]\n'
'git = "https://github.com/waozixyz/wurm.git"\nref = "master"\n\n'
'[dependencies.other]\nref = "stable"\n')
(root / 'ziran.toml').write_text(original_manifest)
(root / 'games.json').write_text(json.dumps({'packages': ['wurm']}))
# This is the normal release order: metadata first, game release next.
(root / 'apps/versions.json').write_text(json.dumps({'node_apps': {'wurm': {'version': '0.1.8'}}}))
# Release metadata may name a release before its source is pinned.
(root / 'apps/versions.json').write_text(json.dumps({'node_apps': {'wurm': {'version': '0.2.0'}}}))
def gh(*arguments):
if arguments[0] == 'release':
return 'v0.1.8'
return 'v0.2.0'
return comparison if '/compare/' in arguments[1] else new
updates = root / 'updates.json'
with patch.object(follower, 'ROOT', root), patch.object(follower, 'UPDATES', updates), patch.object(follower, 'gh', gh):
follower.pin()
return json.loads((root / 'ziran.lock').read_text()), json.loads(updates.read_text()), old, new
def resolve(command, **kwargs):
self.assertEqual(command, ['verified-ziran', 'update', 'wurm'])
self.assertEqual(kwargs, {'cwd': root, 'check': True})
self.assertIn(f'ref = "{new}"', (root / 'ziran.toml').read_text())
declaration = tomllib.loads((root / 'ziran.toml').read_text())
self.assertEqual(declaration['dependencies']['wurm']['ref'], new)
self.assertEqual(declaration['dependencies']['other']['ref'], 'stable')
if failure:
(root / 'ziran.lock').write_text('partial resolver output')
raise subprocess.CalledProcessError(1, command)
# A package-manager result with a newly introduced Entity import.
# The follower must retain this graph verbatim, rather than
# replacing the game id while preserving its old empty edges.
lock['root']['dependencies']['wurm'] = 'released'
lock['packages'][0].update(id='released', commit=old if wrong_commit else new,
ref=new, dependencies={'entity': 'accounts'})
lock['packages'].append({'id': 'accounts', 'commit': 'new-entity', 'dependencies': {}})
(root / 'ziran.lock').write_text(json.dumps(lock))
def test_metadata_already_names_the_release(self):
lock, updates, old, new = self.follow('ahead')
updates = root / 'updates.json'
with patch.object(follower, 'ROOT', root), patch.object(follower, 'UPDATES', updates), \
patch.object(follower, 'gh', gh), patch.object(follower.subprocess, 'run', side_effect=resolve) as run:
# Discovery must not require a compiler or modify either input.
follower.record_updates(follower.released_updates())
self.assertEqual((root / 'ziran.lock').read_text(), original_lock)
self.assertEqual((root / 'ziran.toml').read_text(), original_manifest)
run.assert_not_called()
if failure or wrong_commit:
with self.assertRaises((subprocess.CalledProcessError, ValueError)):
follower.pin('verified-ziran')
self.assertEqual((root / 'ziran.lock').read_text(), original_lock)
self.assertEqual((root / 'ziran.toml').read_text(), original_manifest)
else:
follower.pin('verified-ziran')
calls = run.call_count
return json.loads((root / 'ziran.lock').read_text()), json.loads(updates.read_text()), old, new, calls
def test_new_release_refreshes_transitive_graph(self):
lock, updates, old, new, calls = self.follow('ahead')
self.assertEqual(lock['packages'][0]['commit'], new)
self.assertEqual(lock['root']['dependencies']['wurm'], lock['packages'][0]['id'])
self.assertEqual(len(updates), 1)
self.assertEqual(lock['packages'][0]['dependencies'], {'entity': 'accounts'})
self.assertEqual(lock['packages'][1]['commit'], 'unchanged')
self.assertEqual(lock['toolchain']['commit'], 'compiler')
self.assertEqual((len(updates), calls), (1, 1))
def test_same_source_is_unchanged(self):
lock, updates, old, new = self.follow('identical', same_commit=True)
lock, updates, old, new, calls = self.follow('identical', same_commit=True)
self.assertEqual(lock['packages'][0]['commit'], old)
self.assertEqual(updates, [])
self.assertEqual((updates, calls), ([], 0))
def test_older_release_never_moves_the_pin_back(self):
lock, updates, old, new = self.follow('behind')
lock, updates, old, new, calls = self.follow('behind')
self.assertEqual(lock['packages'][0]['commit'], old)
self.assertEqual(updates, [])
self.assertEqual((updates, calls), ([], 0))
def test_failed_resolution_restores_manifest_and_lock(self):
self.follow('ahead', failure=True)
def test_local_override_cannot_publish_wrong_game(self):
self.follow('ahead', wrong_commit=True)
if __name__ == '__main__':
+36 -36
View File
@@ -3,12 +3,20 @@
"packages": [
{
"commit": "dc1cfe389905c63c0bb453727d06d72afc1fa0b0",
"dependencies": {"crypto": "pc23fbf455e97614d", "kryon": "p39132f61dd28d78f"},
"dependencies": {"crypto": "pc23fbf455e97614d", "kryon": "peb24c24393004f5f"},
"id": "p00b93f1ddcd2802f",
"name": "Apps",
"ref": "master",
"url": "https://github.com/waozixyz/apps.git"
},
{
"commit": "90a3e7d9b1b9ef6a7f5eab7aff55eba3353e604e",
"dependencies": {"apps": "p00b93f1ddcd2802f", "entity": "p4d0db653f861a40d", "kryon": "peb24c24393004f5f", "mingcute": "pe1027b9d16704793"},
"id": "p08f35f0240dbbdff",
"name": "Shovey",
"ref": "master",
"url": "https://github.com/waozixyz/shovey.git"
},
{
"commit": "b31299434c785d0f2bd82f36b5bfd2fd36ba1216",
"dependencies": {},
@@ -28,7 +36,7 @@
},
{
"commit": "1cb9df183089a77c8a16448a556186f30b261a98",
"dependencies": {"kryon": "p39132f61dd28d78f"},
"dependencies": {"kryon": "peb24c24393004f5f"},
"id": "p1b13dda539ed2a39",
"name": "Kss",
"ref": "master",
@@ -36,7 +44,7 @@
},
{
"commit": "bad2caaa84ef3eae61e40c99bf572d2b060d0ca2",
"dependencies": {"kryon": "p39132f61dd28d78f"},
"dependencies": {"kryon": "peb24c24393004f5f"},
"id": "p20eb23d3e6db3711",
"name": "Game2D",
"ref": "master",
@@ -60,17 +68,9 @@
"source": true,
"url": "https://github.com/curl/curl.git"
},
{
"commit": "68f2e8d30b8d2f28b29c1d8875193b33bea44ead",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "p39132f61dd28d78f",
"name": "kryon",
"ref": "master",
"url": "https://github.com/kryonlabs/kryon.git"
},
{
"commit": "2f6f1f57d7de742ef7ebc01159c2315acf793d5b",
"dependencies": {"apps": "p00b93f1ddcd2802f", "crypto": "pc23fbf455e97614d", "curl": "p2f75403ea4cb61e4", "daochi_client": "p9972fcdd2d5ba999", "game2d": "p20eb23d3e6db3711", "kryon": "p39132f61dd28d78f", "kss": "p1b13dda539ed2a39", "liboqs": "p4b0a50b49959e674", "mingcute": "pe1027b9d16704793", "monocypher": "p809b4d31a48625a3", "oqs": "p7098ac9cd92f7e5f", "plot": "pab5377a2950368a2", "qrcode": "p0dfa70137405b096", "rini": "p09fa77e94b0dfc6c", "self": "pa4da0de6c3c44e61", "sqlite": "p219661bf4be659ed"},
"dependencies": {"apps": "p00b93f1ddcd2802f", "crypto": "pc23fbf455e97614d", "curl": "p2f75403ea4cb61e4", "daochi_client": "p9972fcdd2d5ba999", "game2d": "p20eb23d3e6db3711", "kryon": "peb24c24393004f5f", "kss": "p1b13dda539ed2a39", "liboqs": "p4b0a50b49959e674", "mingcute": "pe1027b9d16704793", "monocypher": "p809b4d31a48625a3", "oqs": "p7098ac9cd92f7e5f", "plot": "pab5377a2950368a2", "qrcode": "p0dfa70137405b096", "rini": "p09fa77e94b0dfc6c", "self": "pa4da0de6c3c44e61", "sqlite": "p219661bf4be659ed"},
"id": "p48228a6b7e2920d3",
"name": "Inbe",
"ref": "master",
@@ -85,6 +85,14 @@
"source": true,
"url": "https://github.com/open-quantum-safe/liboqs.git"
},
{
"commit": "91ef8713174a1d88106dd8ea2293ef8d46f8ee66",
"dependencies": {"daochi_client": "p9972fcdd2d5ba999", "kryon": "peb24c24393004f5f", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"id": "p4d0db653f861a40d",
"name": "Entity",
"ref": "master",
"url": "https://github.com/waozixyz/entity.git"
},
{
"commit": "fafa2cea97d0cb379d832086ba45a989fa6f9c8e",
"dependencies": {},
@@ -102,6 +110,14 @@
"ref": "master",
"url": "https://github.com/ziranlang/oqs.git"
},
{
"commit": "a2798e2a2faa5686878bdc16411b3ffcf2a7fdba",
"dependencies": {"apps": "p00b93f1ddcd2802f", "entity": "p4d0db653f861a40d", "kryon": "peb24c24393004f5f", "mingcute": "pe1027b9d16704793"},
"id": "p7491d26bc9d1b060",
"name": "Apfelwurm",
"ref": "a2798e2a2faa5686878bdc16411b3ffcf2a7fdba",
"url": "https://github.com/waozixyz/wurm.git"
},
{
"commit": "f5f0a19a5dc6c14a49adb3cd63ea79a60f6ba77b",
"dependencies": {},
@@ -119,17 +135,9 @@
"ref": "master",
"url": "https://github.com/ziranlang/daochi-client.git"
},
{
"commit": "ead42286d2fe16cd46768e4d3d6a5fad26d1c831",
"dependencies": {"daochi_client": "p9972fcdd2d5ba999", "kryon": "p39132f61dd28d78f", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"id": "p9ea7a59dcc9f75a2",
"name": "Entity",
"ref": "master",
"url": "https://github.com/waozixyz/entity.git"
},
{
"commit": "357a71d1ee2c7c9526c2af18793ea8628c505034",
"dependencies": {"daochi_client": "p9972fcdd2d5ba999", "kryon": "p39132f61dd28d78f", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"dependencies": {"daochi_client": "p9972fcdd2d5ba999", "kryon": "peb24c24393004f5f", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
"id": "pa4da0de6c3c44e61",
"name": "Self",
"ref": "master",
@@ -137,7 +145,7 @@
},
{
"commit": "3f888653b6b97010163d824c4cc72476be3214f3",
"dependencies": {"kryon": "p39132f61dd28d78f"},
"dependencies": {"kryon": "peb24c24393004f5f"},
"id": "pab5377a2950368a2",
"name": "plot",
"ref": "master",
@@ -151,14 +159,6 @@
"ref": "master",
"url": "https://github.com/ziranlang/crypto.git"
},
{
"commit": "90a3e7d9b1b9ef6a7f5eab7aff55eba3353e604e",
"dependencies": {"apps": "p00b93f1ddcd2802f", "entity": "p9ea7a59dcc9f75a2", "kryon": "p39132f61dd28d78f", "mingcute": "pe1027b9d16704793"},
"id": "p08f35f0240dbbdff",
"name": "Shovey",
"ref": "master",
"url": "https://github.com/waozixyz/shovey.git"
},
{
"commit": "9cc6872f75447c3a24c16764f9829d0f58751cb0",
"dependencies": {},
@@ -168,16 +168,16 @@
"url": "https://github.com/kryonlabs/mingcute.git"
},
{
"commit": "76e95cd951ddc82d9a507f5e43f6b72fc597bc96",
"dependencies": {"apps": "p00b93f1ddcd2802f", "kryon": "p39132f61dd28d78f", "mingcute": "pe1027b9d16704793"},
"id": "pceb767df382e3cc7",
"name": "Apfelwurm",
"commit": "65d207e21ebc8969c920d7d495d448db1e90d849",
"dependencies": {"raylib": "p5a77c9c35110e925"},
"id": "peb24c24393004f5f",
"name": "kryon",
"ref": "master",
"url": "https://github.com/waozixyz/wurm.git"
"url": "https://github.com/kryonlabs/kryon.git"
}
],
"root": {
"dependencies": {"apps": "p00b93f1ddcd2802f", "entity": "p9ea7a59dcc9f75a2", "inbe": "p48228a6b7e2920d3", "kryon": "p39132f61dd28d78f", "mingcute": "pe1027b9d16704793", "shovey": "p08f35f0240dbbdff", "wurm": "pceb767df382e3cc7"},
"dependencies": {"apps": "p00b93f1ddcd2802f", "entity": "p4d0db653f861a40d", "inbe": "p48228a6b7e2920d3", "kryon": "peb24c24393004f5f", "mingcute": "pe1027b9d16704793", "shovey": "p08f35f0240dbbdff", "wurm": "p7491d26bc9d1b060"},
"name": "Arcade"
},
"toolchain": {
+1 -1
View File
@@ -56,4 +56,4 @@ ref = "master"
[dependencies.wurm]
git = "https://github.com/waozixyz/wurm.git"
ref = "master"
ref = "a2798e2a2faa5686878bdc16411b3ffcf2a7fdba"