-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (115 loc) · 4.68 KB
/
Copy pathdeploy-perf-graph.yml
File metadata and controls
132 lines (115 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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