Skip to content

Commit 6e27d2e

Browse files
Add GitHub Actions workflow for archive determinism testing
Builds and archives a test fixture on both Windows and Linux runners, verifying same-platform determinism and comparing cross-platform output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7ddcda2 commit 6e27d2e

6 files changed

Lines changed: 129 additions & 0 deletions

File tree

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
###############################################################################
44
* text=auto
55

6+
# Test fixtures must be byte-identical across platforms
7+
test-fixture/** -text
8+
69
###############################################################################
710
# Set default behavior for command prompt diff.
811
#

.github/workflows/determinism.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Archive Determinism Check
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-archive:
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: recursive
20+
21+
- uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: '8.0.x'
24+
25+
- name: Print .NET info
26+
run: dotnet --info
27+
28+
- name: Build
29+
run: dotnet build MS2Tools.sln -c Release
30+
31+
- name: Run tests
32+
run: dotnet test MS2Lib/MS2Lib.Tests/MS2Lib.Tests.csproj -c Release --no-build
33+
34+
- name: Create archive (run 1)
35+
run: dotnet run --project MS2Create -c Release --no-build -- ./test-fixture ./out1 Test MS2F
36+
37+
- name: Create archive (run 2)
38+
run: dotnet run --project MS2Create -c Release --no-build -- ./test-fixture ./out2 Test MS2F
39+
40+
- name: Hash outputs
41+
shell: bash
42+
run: |
43+
sha256sum out1/Test.m2d out1/Test.m2h > hashes-run1.txt
44+
sha256sum out2/Test.m2d out2/Test.m2h > hashes-run2.txt
45+
echo "=== Run 1 ==="
46+
cat hashes-run1.txt
47+
echo "=== Run 2 ==="
48+
cat hashes-run2.txt
49+
50+
- name: Verify same-platform determinism
51+
shell: bash
52+
run: |
53+
if diff hashes-run1.txt hashes-run2.txt; then
54+
echo "PASS: Same-platform runs are identical"
55+
else
56+
echo "FAIL: Same-platform runs differ!"
57+
exit 1
58+
fi
59+
60+
- name: Upload hashes
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: hashes-${{ matrix.os }}
64+
path: hashes-run1.txt
65+
66+
- name: Upload archive
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: archive-${{ matrix.os }}
70+
path: out1/
71+
72+
compare-platforms:
73+
needs: build-archive
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Download Windows hashes
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: hashes-windows-latest
80+
path: win
81+
82+
- name: Download Linux hashes
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: hashes-ubuntu-latest
86+
path: linux
87+
88+
- name: Compare cross-platform hashes
89+
run: |
90+
echo "=== Windows ==="
91+
cat win/hashes-run1.txt
92+
echo "=== Linux ==="
93+
cat linux/hashes-run1.txt
94+
echo "=== Diff ==="
95+
if diff win/hashes-run1.txt linux/hashes-run1.txt; then
96+
echo "PASS: Cross-platform archives are identical"
97+
else
98+
echo "INFO: Cross-platform archives differ (expected due to native zlib differences)"
99+
echo "This is not a failure — see workflow summary for details."
100+
fi

test-fixture/a.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<ms2>
2+
<environment>
3+
<property name="test" value="determinism check" />
4+
<property name="id" value="1001" />
5+
<property name="description" value="This is a test fixture for verifying cross-platform archive determinism." />
6+
</environment>
7+
</ms2>

test-fixture/b.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<ms2>
2+
<npc id="2001" name="TestNPC">
3+
<stats hp="1000" mp="500" level="10" />
4+
<dialogue>
5+
<line id="1">Hello adventurer!</line>
6+
<line id="2">Welcome to MapleStory 2.</line>
7+
</dialogue>
8+
</npc>
9+
</ms2>

test-fixture/subdir/c.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<ms2>
2+
<item id="30000001" name="Sword of Testing">
3+
<stats attack="100" defense="0" speed="5" />
4+
<requirements level="1" job="knight" />
5+
<description>A trusty sword used for testing archive determinism.</description>
6+
</item>
7+
</ms2>

test-fixture/subdir/d.zlib

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Binary test content for zlib compression type detection.
2+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
3+
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

0 commit comments

Comments
 (0)