|
| 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 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + os: [ubuntu-latest, windows-latest] |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + submodules: recursive |
| 21 | + |
| 22 | + - uses: actions/setup-dotnet@v4 |
| 23 | + with: |
| 24 | + dotnet-version: '8.0.x' |
| 25 | + |
| 26 | + - name: Clone test data |
| 27 | + run: git clone --depth 1 https://github.com/MS2Community/MapleStory2-XML.git test-data |
| 28 | + |
| 29 | + - name: Diagnose test data |
| 30 | + shell: bash |
| 31 | + run: | |
| 32 | + echo "File count:" |
| 33 | + find test-data/Server -type f | wc -l |
| 34 | + echo "Sample file raw:" |
| 35 | + sha256sum test-data/Server/AI/AI_Anos.xml || true |
| 36 | + wc -c test-data/Server/AI/AI_Anos.xml || true |
| 37 | + echo "Sample file after CRLF strip:" |
| 38 | + tr -d '\r' < test-data/Server/AI/AI_Anos.xml | sha256sum |
| 39 | + tr -d '\r' < test-data/Server/AI/AI_Anos.xml | wc -c |
| 40 | + echo "All files combined hash after CRLF strip:" |
| 41 | + find test-data/Server -type f | sort | while read f; do tr -d '\r' < "$f"; done | sha256sum |
| 42 | +
|
| 43 | + - name: Build |
| 44 | + run: dotnet build MS2Tools.sln -c Release |
| 45 | + |
| 46 | + - name: Run tests |
| 47 | + run: dotnet test MS2Lib/MS2Lib.Tests/MS2Lib.Tests.csproj -c Release --no-build |
| 48 | + |
| 49 | + - name: Create archive from test-fixture (run 1) |
| 50 | + run: dotnet run --project MS2Create -c Release --no-build -- ./test-fixture ./out-fixture1 TestFixture MS2F |
| 51 | + |
| 52 | + - name: Create archive from test-fixture (run 2) |
| 53 | + run: dotnet run --project MS2Create -c Release --no-build -- ./test-fixture ./out-fixture2 TestFixture MS2F |
| 54 | + |
| 55 | + - name: Create archive from Server (run 1) |
| 56 | + run: dotnet run --project MS2Create -c Release --no-build -- ./test-data/Server ./out-server1 Server MS2F |
| 57 | + |
| 58 | + - name: Create archive from Server (run 2) |
| 59 | + run: dotnet run --project MS2Create -c Release --no-build -- ./test-data/Server ./out-server2 Server MS2F |
| 60 | + |
| 61 | + - name: Archive file sizes |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + ls -la out-server1/Server.m2d out-server1/Server.m2h |
| 65 | +
|
| 66 | + - name: Hash outputs |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + echo "=== Test Fixture ===" |
| 70 | + sha256sum out-fixture1/TestFixture.m2d out-fixture1/TestFixture.m2h |
| 71 | + sha256sum out-fixture2/TestFixture.m2d out-fixture2/TestFixture.m2h |
| 72 | + awk '{print $1}' <(sha256sum out-fixture1/TestFixture.m2d out-fixture1/TestFixture.m2h) > fixture-run1.txt |
| 73 | + awk '{print $1}' <(sha256sum out-fixture2/TestFixture.m2d out-fixture2/TestFixture.m2h) > fixture-run2.txt |
| 74 | + echo "=== Server ===" |
| 75 | + sha256sum out-server1/Server.m2d out-server1/Server.m2h |
| 76 | + sha256sum out-server2/Server.m2d out-server2/Server.m2h |
| 77 | + awk '{print $1}' <(sha256sum out-server1/Server.m2d out-server1/Server.m2h) > server-run1.txt |
| 78 | + awk '{print $1}' <(sha256sum out-server2/Server.m2d out-server2/Server.m2h) > server-run2.txt |
| 79 | +
|
| 80 | + - name: Verify same-platform determinism (test-fixture) |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + if diff fixture-run1.txt fixture-run2.txt; then |
| 84 | + echo "PASS: Test fixture — same-platform runs are identical" |
| 85 | + else |
| 86 | + echo "FAIL: Test fixture — same-platform runs differ!" |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | +
|
| 90 | + - name: Verify same-platform determinism (Server) |
| 91 | + shell: bash |
| 92 | + run: | |
| 93 | + if diff server-run1.txt server-run2.txt; then |
| 94 | + echo "PASS: Server — same-platform runs are identical" |
| 95 | + else |
| 96 | + echo "FAIL: Server — same-platform runs differ!" |
| 97 | + exit 1 |
| 98 | + fi |
| 99 | +
|
| 100 | + - name: Upload hashes |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: hashes-${{ matrix.os }} |
| 104 | + path: server-run1.txt |
| 105 | + |
| 106 | + - name: Upload archive for comparison |
| 107 | + if: always() |
| 108 | + uses: actions/upload-artifact@v4 |
| 109 | + with: |
| 110 | + name: archive-${{ matrix.os }} |
| 111 | + path: out-server1/ |
| 112 | + |
| 113 | + compare-platforms: |
| 114 | + needs: build-archive |
| 115 | + runs-on: ubuntu-latest |
| 116 | + steps: |
| 117 | + - name: Download Windows hashes |
| 118 | + uses: actions/download-artifact@v4 |
| 119 | + with: |
| 120 | + name: hashes-windows-latest |
| 121 | + path: win |
| 122 | + |
| 123 | + - name: Download Linux hashes |
| 124 | + uses: actions/download-artifact@v4 |
| 125 | + with: |
| 126 | + name: hashes-ubuntu-latest |
| 127 | + path: linux |
| 128 | + |
| 129 | + - name: Compare cross-platform hashes (Server) |
| 130 | + run: | |
| 131 | + echo "=== Windows ===" |
| 132 | + cat win/server-run1.txt |
| 133 | + echo "=== Linux ===" |
| 134 | + cat linux/server-run1.txt |
| 135 | + echo "=== Diff ===" |
| 136 | + if diff win/server-run1.txt linux/server-run1.txt; then |
| 137 | + echo "PASS: Cross-platform Server archives are byte-identical!" |
| 138 | + else |
| 139 | + echo "FAIL: Cross-platform Server archives differ" |
| 140 | + exit 1 |
| 141 | + fi |
0 commit comments