|
| 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 |
0 commit comments