Repository navigation
76 lines (66 loc) · 2.5 KB
/
Copy pathperf.yml
File metadata and controls
76 lines (66 loc) · 2.5 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
name: Perf
on:
pull_request:
permissions:
contents: read
pull-requests: read
concurrency:
group: perf-${{ github.event.number }}
cancel-in-progress: true
jobs:
perf:
name: Perf
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
persist-credentials: false
# The checkout is main merged with this PR, so its first parent is the main it merges into.
- id: diff
run: |
if git diff --quiet HEAD^1 HEAD -- backend frontend lib package.json pnpm-lock.yaml .nvmrc scripts/perf.mts .tests/perf .tests/helpers .github/workflows/perf.yml; then
echo "changed=false" >> "${GITHUB_OUTPUT}"
else
echo "changed=true" >> "${GITHUB_OUTPUT}"
fi
- if: steps.diff.outputs.changed == 'true'
uses: voidzero-dev/setup-vp@cab1ab9eaff52d4857875f4f2c016e36af8f2c76 # v1.22.0
with:
node-version-file: .nvmrc
cache: true
run-install: |
- args: ["--frozen-lockfile"]
- name: Set up main
if: steps.diff.outputs.changed == 'true'
run: |
git worktree add ../base HEAD^1
cd ../base
vp install --frozen-lockfile
vp run build
- if: steps.diff.outputs.changed == 'true'
run: vp run build
# Read labels now, not from the event, so adding perf-accepted and re-running the job applies it.
- name: Compare
if: steps.diff.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.number }}
REPORT_DIR: ${{ runner.temp }}/perf-report
run: |
mkdir -p "$REPORT_DIR"
echo "$PR_NUMBER" > "$REPORT_DIR/pr"
if gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json labels --jq '.labels[].name' | grep -qx perf-accepted; then
node scripts/perf.mts compare ../base --json "$REPORT_DIR/comparison.json" --report-only
else
node scripts/perf.mts compare ../base --json "$REPORT_DIR/comparison.json"
fi
# perf-report.yml turns this into the PR comment.
- if: always() && steps.diff.outputs.changed == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: perf-report
path: ${{ runner.temp }}/perf-report
if-no-files-found: ignore
retention-days: 7