scoring infra

This commit is contained in:
Adien Akhmad 2025-11-17 13:44:50 +07:00
parent 695525d24d
commit cb2b0f46bd
2 changed files with 81 additions and 1 deletions

3
.gitignore vendored
View file

@ -1,3 +1,4 @@
/bin/ /bin/
/obj/ /obj/
/test/benchmark_output/ /test/benchmark_output/
/.contest

79
mise.toml Normal file
View file

@ -0,0 +1,79 @@
# Quick Guide
# - install mise
# - download the asset and extract them to ASSET_PATH_RO
# - mise run verify-asset
# - require hashdeep
# `hashdeep` package in debian
# or `md5deep` package in fedora
# or uncomment `tools."http:hashdeep"` below in windows
# - mise run serve
# - mise run arrange
# - mise run action
# - mise run assert
[env]
ASSET_PATH_RO = "{{ [xdg_cache_home, 'stitch-a-ton', 'asset'] | join_path }}"
CONTEST_HOST = "http://localhost:7007"
CONTEST_API = "/api/image/generate"
CONTEST_OUTPUT = "{{ [cwd, '.contest'] | join_path }}"
DOTNET_ENVIRONMENT = "Production"
ANSWER_COMMIT_HASH = "deb8c493546fa2f8f89b5bfe8ffa04806939645d"
[tools]
dotnet = "8"
xh = "latest"
uv = "latest"
# uncomment these if you're on windows
#[tools."http:hashdeep"]
#version = "4.4"
#[tools."http:hashdeep".platforms]
#windows-x64 = {url = "https://github.com/jessek/hashdeep/releases/download/v4.4/md5deep-4.4.zip"}
[tasks.setup]
run = '''
{% if env.CONTEST_OUTPUT is not exists %}
mkdir .contest
{% endif %}
'''
[tasks.verify-asset]
dir = "{{ env.ASSET_PATH_RO }}"
run = '''
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/asset.txt -o ../asset.txt
hashdeep -arbvk ../asset.txt .
'''
[tasks.arrange]
depends = ['setup']
dir = "{{ env.CONTEST_OUTPUT }}"
outputs = ['action.py', 'assert.py','answer.json']
run = '''
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/answer.json -o answer.json
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/action.py -o action.py
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/assert.py -o assert.py
'''
[tasks.serve]
run = "dotnet run -c Release --no-launch-profile --urls {{env.CONTEST_HOST}}"
[tasks.quick]
depends = ['arrange']
dir = "{{ env.CONTEST_OUTPUT }}"
run = '''
xh post {{env.CONTEST_HOST}}{{env.CONTEST_ENDPOINT}} canvas_rect=A1:H12 crop_offset:=[0,0] crop_size:=[1,1] output_scale:=0.25 -o quick.png
'''
[tasks.action]
depends = ['arrange']
dir = "{{ env.CONTEST_OUTPUT }}"
run = '''
uv run --no-config --script {{ [env.CONTEST_OUTPUT, 'action.py'] | join_path }}
'''
[tasks.assert]
dir = "{{ env.CONTEST_OUTPUT }}"
run = '''
uvx --no-config --with-requirements assert.py pytest assert.py
'''