|
| 1 | +name: Determinism |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + types: [opened, synchronize] |
| 7 | + paths: |
| 8 | + - test/determinism/** |
| 9 | + |
| 10 | +jobs: |
| 11 | + check: |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - os: macos-latest |
| 17 | + work_dir: ${{ env.RUNNER_TEMP }}/r |
| 18 | + - os: ubuntu-latest |
| 19 | + work_dir: ${{ env.RUNNER_TEMP }}/r |
| 20 | + - os: windows-latest |
| 21 | + work_dir: C:\r |
| 22 | + |
| 23 | + runs-on: ${{ matrix.os }} |
| 24 | + name: Check (${{ matrix.os }}) |
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + clean: true |
| 30 | + |
| 31 | + - name: Run tests |
| 32 | + continue-on-error: true |
| 33 | + run: | |
| 34 | + bazel run \ |
| 35 | + --compilation_mode=opt \ |
| 36 | + //test/determinism:tester \ |
| 37 | + -- test \ |
| 38 | + --output="${{ github.workspace }}/results.json" \ |
| 39 | + --work-dir="${{ matrix.work_dir }}" |
| 40 | +
|
| 41 | + - name: Summarize (unix) |
| 42 | + if: runner.os != 'Windows' |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + if [[ ! -f results.json ]]; then |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | +
|
| 49 | + { |
| 50 | + echo '<details>' |
| 51 | + echo |
| 52 | + echo '```json' |
| 53 | + cat results.json |
| 54 | + echo |
| 55 | + echo '```' |
| 56 | + echo |
| 57 | + echo '</details>' |
| 58 | + } >> "$GITHUB_STEP_SUMMARY" |
| 59 | +
|
| 60 | + if [[ "$(cat results.json)" != "[]"* ]]; then |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Summarize (windows) |
| 65 | + if: runner.os == 'Windows' |
| 66 | + shell: pwsh |
| 67 | + run: | |
| 68 | + if (-not (Test-Path results.json)) { exit 1 } |
| 69 | +
|
| 70 | + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '<details>' |
| 71 | + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '' |
| 72 | + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```json' |
| 73 | + Get-Content -Path results.json | Add-Content -Path $env:GITHUB_STEP_SUMMARY |
| 74 | + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '' |
| 75 | + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```' |
| 76 | + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '' |
| 77 | + Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '</details>' |
| 78 | +
|
| 79 | + $content = Get-Content -Path results.json -Raw |
| 80 | + if (-not $content.StartsWith('[]')) { exit 1 } |
| 81 | +
|
| 82 | + - name: Archive output base (unix) |
| 83 | + if: runner.os != 'Windows' && always() |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + if [[ -d "${{ matrix.work_dir }}/o" ]]; then |
| 87 | + tar -czf output-base.tar.gz -C "${{ matrix.work_dir }}" o |
| 88 | + fi |
| 89 | +
|
| 90 | + - name: Archive output base (windows) |
| 91 | + if: runner.os == 'Windows' && always() |
| 92 | + shell: pwsh |
| 93 | + run: | |
| 94 | + if (Test-Path "${{ matrix.work_dir }}\o") { |
| 95 | + Compress-Archive -Path "${{ matrix.work_dir }}\o" -DestinationPath output-base.zip |
| 96 | + } |
| 97 | +
|
| 98 | + - name: Upload output base artifact |
| 99 | + if: always() |
| 100 | + uses: actions/upload-artifact@v4 |
| 101 | + with: |
| 102 | + name: output-base-${{ matrix.os }} |
| 103 | + path: | |
| 104 | + output-base.tar.gz |
| 105 | + output-base.zip |
| 106 | + if-no-files-found: ignore |
0 commit comments