-
Notifications
You must be signed in to change notification settings - Fork 428
133 lines (115 loc) · 3.94 KB
/
Copy pathbench.yml
File metadata and controls
133 lines (115 loc) · 3.94 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
133
name: bench
permissions: {}
on:
push:
branches:
- master
paths-ignore:
- '.github/workflows/preview.yml'
- 'assets/**'
- 'docs/**'
- 'example/**'
- 'site/**'
- '.gitignore'
- '.node-version'
- '.npmrc'
- '.nvmrc'
- '.prettierignore'
- '.prettierrc.json'
- '*.md'
- 'deno*'
- 'jsr*'
- 'LICENSE'
- 'outdated-typescript.d.ts'
pull_request:
paths-ignore:
- '.github/workflows/preview.yml'
- 'assets/**'
- 'docs/**'
- 'example/**'
- 'site/**'
- '.gitignore'
- '.node-version'
- '.npmrc'
- '.nvmrc'
- '.prettierignore'
- '.prettierrc.json'
- '*.md'
- 'deno*'
- 'jsr*'
- 'LICENSE'
- 'outdated-typescript.d.ts'
jobs:
typescript:
concurrency:
cancel-in-progress: ${{ github.ref_name != 'master' }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
name: TypeScript Benchmarks
permissions:
pull-requests: write # required for PR comment.
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
with:
cache: true
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: lts/*
- name: Install dependencies
run: pnpm install
- name: Run benchmarks
id: bench
run: |
# Run benchmarks and capture output
pnpm bench:ts > /tmp/bench_output.txt 2>&1
exit_code=$?
# Extract summary (everything from "⏱️" to end of file)
summary=$(grep -A999 "⏱️" /tmp/bench_output.txt || echo "✅ ⏱️ No benchmark changes detected.")
# Check if there are benchmark changes
if echo "$summary" | grep -q "No benchmark changes detected"; then
has_changes="false"
else
has_changes="true"
fi
# Set outputs
echo "benchmark_failed=$([ $exit_code -eq 0 ] && echo 'false' || echo 'true')" >> $GITHUB_OUTPUT
echo "has_changes=$has_changes" >> $GITHUB_OUTPUT
echo "summary<<EOF" >> $GITHUB_OUTPUT
echo "$summary" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Post benchmark results (with changes)
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && steps.bench.outputs.has_changes == 'true'
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
comment-tag: typescript-benchmarks
message: |
<details>
<summary>⏱️ <strong>TypeScript Benchmark Results</strong></summary>
```
${{ steps.bench.outputs.summary }}
```
</details>
- name: Post benchmark results (no changes)
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && steps.bench.outputs.has_changes == 'false'
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
comment-tag: typescript-benchmarks
message: |
⏱️ **TypeScript Benchmark Results**
```
${{ steps.bench.outputs.summary }}
```
- name: Fail job if benchmark command failed
if: steps.bench.outputs.benchmark_failed == 'true'
run: |
echo "Benchmark command failed with exit code 1"
exit 1