Skip to content

Commit 8e3f02a

Browse files
committed
feat: make the mode argument required
1 parent 97c7a6f commit 8e3f02a

5 files changed

Lines changed: 47 additions & 27 deletions

File tree

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@ GitHub Actions for running [CodSpeed](https://codspeed.io) in your CI.
1212
# Usage
1313

1414
```yaml
15-
- uses: CodSpeedHQ/action@v3
15+
- uses: CodSpeedHQ/action@v4
1616
with:
17+
# [REQUIRED]
18+
# The command used to run your CodSpeed benchmarks
19+
run: "<YOUR_COMMAND>"
20+
21+
# [REQUIRED]
22+
# The measurement mode to use, either: "instrumentation" or "walltime".
23+
# More details on the instruments at https://docs.codspeed.io/instruments/
24+
mode: "instrumentation"
25+
1726
# [REQUIRED for private repositories]
1827
# The CodSpeed upload token: can be found at https://codspeed.io/<org>/<repo>/settings
1928
# It's strongly recommended to use a secret for this value
2029
# If you're instrumenting a public repository, you can omit this value
2130
token: ""
2231

23-
# [REQUIRED]
24-
# The command used to run your codspeed benchmarks
25-
run: ""
26-
2732
# [OPTIONAL]
2833
# The directory where the `run` command will be executed.
2934
# ⚠️ WARNING: if you use `defaults.run.working-directory`, you must still set this parameter.
@@ -78,8 +83,9 @@ jobs:
7883
run: pip install -r requirements.txt
7984

8085
- name: Run benchmarks
81-
uses: CodSpeedHQ/action@v3
86+
uses: CodSpeedHQ/action@v4
8287
with:
88+
mode: instrumentation
8389
token: ${{ secrets.CODSPEED_TOKEN }}
8490
run: pytest tests/ --codspeed
8591
```
@@ -120,8 +126,9 @@ jobs:
120126
run: cargo codspeed build
121127

122128
- name: Run the benchmarks
123-
uses: CodSpeedHQ/action@v3
129+
uses: CodSpeedHQ/action@v4
124130
with:
131+
mode: instrumentation
125132
run: cargo codspeed run
126133
token: ${{ secrets.CODSPEED_TOKEN }}
127134
```
@@ -157,8 +164,9 @@ jobs:
157164
run: npm install
158165

159166
- name: Run benchmarks
160-
uses: CodSpeedHQ/action@v3
167+
uses: CodSpeedHQ/action@v4
161168
with:
169+
mode: instrumentation
162170
run: npx vitest bench
163171
token: ${{ secrets.CODSPEED_TOKEN }}
164172
```

action.yml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,33 @@ branding:
66

77
author: "Arthur Pastel"
88
inputs:
9-
token:
10-
description: "CodSpeed upload token"
11-
required: false
129
run:
1310
description: "The command to run the benchmarks"
1411
required: true
1512

13+
mode:
14+
description: |
15+
The mode to to run the benchmarks in. The following modes are available:
16+
- `instrumentation`: Run the benchmarks with CPU instrumentation measurements.
17+
- `walltime`: Run the benchmarks with walltime measurement.
18+
19+
We strongly recommend starting with the `instrumentation` mode.
20+
21+
Using the `walltime` mode on traditional VMs/Hosted Runners might lead to inconsistent data. For the best results, we recommend using CodSpeed Hosted Macro Runners, which are fine-tuned for performance measurement consistency.
22+
Check out the [Walltime Instrument Documentation](https://docs.codspeed.io/instruments/walltime/) for more details.
23+
required: true
24+
25+
token:
26+
description: |
27+
CodSpeed upload token. Only required for private repositories.
28+
required: false
29+
1630
working-directory:
1731
description: |
1832
The directory where the `run` command will be executed.
1933
Warning: if you use defaults.working-directory, you must still set this parameter.
2034
required: false
35+
2136
upload-url:
2237
description: "The upload endpoint (for on-premise deployments)"
2338
required: false
@@ -26,18 +41,6 @@ inputs:
2641
description: "The version of the runner to use. Use 'latest' to automatically fetch the latest release version from GitHub, or specify a version like '3.5.0' or 'v3.5.0'."
2742
required: false
2843

29-
mode:
30-
description: |
31-
The mode to to run the benchmarks in. The following modes are available:
32-
- `instrumentation` (default): Run the benchmarks with instrumentation enabled.
33-
- `walltime`: Run the benchmarks with walltime enabled.
34-
35-
We strongly recommend not changing this mode unless you know what you are doing.
36-
37-
Using the `walltime` mode on traditional VMs/Hosted Runners will lead to inconsistent data. For the best results, we recommend using CodSpeed Hosted Macro Runners, which are fine-tuned for performance measurement consistency.
38-
Check out the [Walltime Instrument Documentation](https://docs.codspeed.io/instruments/walltime/) for more details.
39-
required: false
40-
4144
instruments:
4245
description: |
4346
Comma separated list of instruments to enable. The following instruments are available:
@@ -57,6 +60,12 @@ runs:
5760
GH_MATRIX: "${{ toJson(matrix) }}"
5861
GH_STRATEGY: "${{ toJson(strategy) }}"
5962
run: |
63+
# Validate required inputs (custom message for smoother v4 migration)
64+
if [ -z "${{ inputs.mode }}" ]; then
65+
echo "::error title=Missing required input 'mode'::The 'mode' input is required as of CodSpeed Action v4. Please explicitly set 'mode' to 'instrumentation' or 'walltime'. Before, this variable was automatically set to instrumentation on every runner except for CodSpeed macro runners where it was set to walltime by default. See https://codspeed.io/docs/instruments for details."
66+
exit 1
67+
fi
68+
6069
# Configure and run codspeed-runner
6170
RUNNER_VERSION="${{ inputs.runner-version }}"
6271
if [ -z "$RUNNER_VERSION" ]; then

examples/nodejs-typescript-codspeed.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jobs:
2222
run: npm install
2323

2424
- name: Run benchmarks
25-
uses: CodSpeedHQ/action@v3
25+
uses: CodSpeedHQ/action@v4
2626
with:
27+
mode: instrumentation
2728
run: node -r esbuild-register benches/bench.ts
2829
token: ${{ secrets.CODSPEED_TOKEN }}

examples/python-pytest-codspeed.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ jobs:
2424
run: pip install -r requirements.txt
2525

2626
- name: Run benchmarks
27-
uses: CodSpeedHQ/action@v3
27+
uses: CodSpeedHQ/action@v4
2828
with:
29-
token: ${{ secrets.CODSPEED_TOKEN }}
29+
mode: instrumentation
3030
run: pytest tests/ --codspeed
31+
token: ${{ secrets.CODSPEED_TOKEN }}

examples/rust-cargo-codspeed.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ jobs:
2727
run: cargo codspeed build
2828

2929
- name: Run the benchmarks
30-
uses: CodSpeedHQ/action@v3
30+
uses: CodSpeedHQ/action@v4
3131
with:
32+
mode: instrumentation
3233
run: cargo codspeed run
3334
token: ${{ secrets.CODSPEED_TOKEN }}

0 commit comments

Comments
 (0)