Repository navigation
Output Fuzz #122
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Output Fuzz | |
| on: | |
| schedule: | |
| - cron: '0 3 * * *' | |
| workflow_dispatch: | |
| pull_request: | |
| types: [labeled] | |
| permissions: {} | |
| jobs: | |
| output-fuzz: | |
| if: github.event_name != 'pull_request' || github.event.label.name == 'run-tests' | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| submodules: recursive | |
| persist-credentials: false | |
| - name: Setup Rust | |
| uses: oxc-project/setup-rust@3d6fb132fbe7cdcb66bf8ec193911c2945369d12 # v1.0.17 | |
| with: | |
| cache-key: debug-build | |
| - name: Run output fuzz tests | |
| id: fuzz | |
| continue-on-error: true | |
| env: | |
| PROPTEST_CASES: 5000 | |
| run: | | |
| set -o pipefail | |
| timeout 900 cargo test --workspace -- --nocapture 2>&1 | tee output_fuzz.log | |
| - name: Upload fuzz logs | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: output-fuzz-log-${{ github.run_id }} | |
| path: output_fuzz.log | |
| if-no-files-found: ignore | |
| - name: Mark workflow as failed | |
| if: steps.fuzz.outcome == 'failure' | |
| run: exit 1 | |
| update-tracking-issue: | |
| needs: output-fuzz | |
| if: always() && needs.output-fuzz.result == 'failure' && github.event_name != 'pull_request' | |
| permissions: | |
| issues: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download fuzz logs | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: output-fuzz-log-${{ github.run_id }} | |
| - name: Create or update tracking issue | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const fs = require('node:fs'); | |
| const { owner, repo } = context.repo; | |
| const title = 'Daily output fuzz failure'; | |
| const label = 'zarara-fuzz'; | |
| const nowUtc = new Date().toISOString(); | |
| const runUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`; | |
| const sha = context.sha; | |
| const log = fs.existsSync('output_fuzz.log') | |
| ? fs.readFileSync('output_fuzz.log', 'utf8') | |
| : ''; | |
| const failureMarkdownMatches = [ | |
| ...log.matchAll(/## Failed Seed[\s\S]*?### Generate Fixture\s*```bash[\s\S]*?```/g), | |
| ]; | |
| const failureMarkdown = failureMarkdownMatches.length > 0 | |
| ? failureMarkdownMatches.at(-1)[0].trim() | |
| : 'Failed to parse markdown failure output from `output_fuzz.log`.'; | |
| async function ensureLabelExists() { | |
| try { | |
| await github.rest.issues.getLabel({ owner, repo, name: label }); | |
| } catch (error) { | |
| if (error.status !== 404) { | |
| throw error; | |
| } | |
| await github.rest.issues.createLabel({ | |
| owner, | |
| repo, | |
| name: label, | |
| color: 'd73a4a', | |
| description: 'Daily output fuzz failures', | |
| }); | |
| } | |
| } | |
| await ensureLabelExists(); | |
| const { data: openIssues } = await github.rest.issues.listForRepo({ | |
| owner, | |
| repo, | |
| state: 'open', | |
| labels: label, | |
| per_page: 100, | |
| }); | |
| const existing = openIssues.find((issue) => issue.title === title); | |
| const body = [ | |
| '### Latest failure', | |
| `- Run: ${runUrl}`, | |
| `- SHA: \`${sha}\``, | |
| `- UTC: ${nowUtc}`, | |
| '', | |
| failureMarkdown, | |
| ].join('\n'); | |
| if (existing) { | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: existing.number, | |
| body, | |
| }); | |
| } else { | |
| const created = await github.rest.issues.create({ | |
| owner, | |
| repo, | |
| title, | |
| labels: [label], | |
| body: [ | |
| 'Daily output fuzz guard failed.', | |
| '', | |
| 'This issue stays open until manually closed.', | |
| ].join('\n'), | |
| }); | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: created.data.number, | |
| body, | |
| }); | |
| } |