Deploy Performance Graph #1461
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: Deploy Performance Graph | |
| on: | |
| workflow_run: | |
| # "Picofuzz Full Chain" runs on its own schedule and uploads the | |
| # picofuzz-csv-full_chain artifact; listing it here redeploys the page | |
| # same-day when a fresh full-chain result lands. | |
| workflows: ["Picofuzz Tests", "Picofuzz Full Chain"] | |
| types: [completed] | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| workflow_run_id: | |
| description: Workflow run ID which contains CSV artifacts. | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Read the Actions API to resolve the latest "Picofuzz Full Chain" run. | |
| actions: read | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| working-directory: ./perf-graph | |
| - name: Download picofuzz CSV artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: picofuzz-csv-* | |
| path: ./perf-graph/csv-artifacts | |
| github-token: ${{ secrets.ARTIFACTS_PAT }} | |
| merge-multiple: true | |
| run-id: ${{ github.event.workflow_run.id || inputs.workflow_run_id }} | |
| continue-on-error: true | |
| # The full-chain CSV lives in the separate "Picofuzz Full Chain" workflow, | |
| # so the triggering run above never contains it. Resolve that workflow's | |
| # latest successful run and pull its artifact regardless of what triggered | |
| # this deploy, so the full-chain chart stays fresh on every deploy. | |
| - name: Get latest Picofuzz Full Chain run ID | |
| id: full-chain-run | |
| run: | | |
| api() { | |
| curl -sS -H "Authorization: token $GH_TOKEN" \ | |
| -H "Accept: application/vnd.github.v3+json" "$1" | |
| } | |
| # `// empty` turns a missing/null match into an empty string so an | |
| # unresolved run never leaks a literal "null" into the output. | |
| WORKFLOW_ID=$(api "https://api.github.com/repos/$GH_REPO/actions/workflows" \ | |
| | jq -r '.workflows[]? | select(.name == "Picofuzz Full Chain") | .id // empty') || true | |
| RUN_ID="" | |
| if [ -n "$WORKFLOW_ID" ]; then | |
| RUN_ID=$(api "https://api.github.com/repos/$GH_REPO/actions/workflows/$WORKFLOW_ID/runs?branch=main&status=success&per_page=1" \ | |
| | jq -r '.workflow_runs[0].id // empty') || true | |
| fi | |
| if [ -z "$RUN_ID" ]; then | |
| # Deliberately non-fatal: the full-chain chart falls back to the | |
| # committed/seeded full_chain.csv rather than blocking the deploy of | |
| # the other charts. The warning surfaces the degradation in the log. | |
| echo "::warning::Could not resolve a successful 'Picofuzz Full Chain' run; the full-chain chart will use the committed/seeded full_chain.csv." | |
| fi | |
| echo "run-id=$RUN_ID" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_REPO: ${{ github.repository }} | |
| - name: Download full-chain CSV artifact | |
| if: steps.full-chain-run.outputs.run-id != '' | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: picofuzz-csv-full_chain | |
| path: ./perf-graph/csv-artifacts | |
| github-token: ${{ secrets.ARTIFACTS_PAT }} | |
| run-id: ${{ steps.full-chain-run.outputs.run-id }} | |
| continue-on-error: true | |
| - name: Compile merge script | |
| run: | | |
| npx tsc scripts/merge-csvs.ts --outDir ./scripts-dist --esModuleInterop --module commonjs --target es2020 --moduleResolution node | |
| mv ./scripts-dist/merge-csvs.js ./scripts-dist/merge-csvs.cjs | |
| working-directory: ./perf-graph | |
| - name: Merge CSV files | |
| run: node ./scripts-dist/merge-csvs.cjs | |
| working-directory: ./perf-graph | |
| - name: List merged CSV files | |
| run: | | |
| echo "Files in public directory after merge:" | |
| ls -la ./public/ | |
| echo "" | |
| echo "Line counts:" | |
| wc -l ./public/*.csv | |
| working-directory: ./perf-graph | |
| - name: Build project | |
| run: npm run build | |
| working-directory: ./perf-graph | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v6 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: ./perf-graph/dist | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |