Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codspeed-runner-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.9.0
4.10.0
5 changes: 5 additions & 0 deletions .github/test-codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
benchmarks:
- name: "test"
exec: echo "Working!"
- name: "test2"
exec: echo "Also working!"
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
if [ "$output" != "Hello" ]; then
echo "Assertion failed: Expected 'Hello' but got '$output'"
exit 1
else
echo "Environment variable check passed with $output."
fi
- name: Check action in a custom directory
uses: ./
Expand Down Expand Up @@ -111,3 +113,16 @@ jobs:
go-runner-version: ${{ matrix.version }}
mode: walltime
run: echo "Testing version format ${{ matrix.version }}!"

test-config-file:
runs-on: ubuntu-latest
env:
CODSPEED_SKIP_UPLOAD: true
steps:
- uses: actions/checkout@v4
- run: cat .github/test-codspeed.yml
- name: Check action with config file (no run input)
uses: ./
with:
mode: memory
config: .github/test-codspeed.yml
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ GitHub Actions for running [CodSpeed](https://codspeed.io) in your CI.
```yaml
- uses: CodSpeedHQ/action@v4
with:
# [REQUIRED]
# [OPTIONAL]
# The command used to run your CodSpeed benchmarks
#
# Leave empty to use targets defined in your project configuration (e.g `codspeed.yml`)
# https://codspeed.io/docs/cli#configuration
# ⚠️ WARNING: for action/runner versions lower than v4.9.0, this parameter is required.
run: "<YOUR_COMMAND>"

# [REQUIRED]
Expand All @@ -40,6 +44,11 @@ GitHub Actions for running [CodSpeed](https://codspeed.io) in your CI.
# ⚠️ WARNING: if you use `defaults.run.working-directory`, you must still set this parameter.
working-directory: ""

# [OPTIONAL]
# Path to a CodSpeed configuration file (codspeed.yml).
# If not specified, the runner will look for a codspeed.yml file in the repository root.
config: ""

# [OPTIONAL]
# Comma-separated list of instruments to enable. Possible values: mongodb.
instruments: ""
Expand Down
39 changes: 26 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ author: "Arthur Pastel"
inputs:
run:
description: "The command to run the benchmarks"
required: true
required: false

mode:
description: |
Expand Down Expand Up @@ -77,6 +77,10 @@ inputs:
description: "The version of the go-runner to use (e.g., 1.0.0, 1.0.0-beta.1). If not specified, the latest version will be installed"
required: false

config:
description: "Path to a CodSpeed configuration file (codspeed.yml). If not specified, the runner will look for a codspeed.yml file in the repository root."
required: false

runs:
using: "composite"
steps:
Expand Down Expand Up @@ -107,6 +111,8 @@ runs:
env:
GH_MATRIX: "${{ toJson(matrix) }}"
GH_STRATEGY: "${{ toJson(strategy) }}"
# This is needed to properly handle quotes and multiline commands in the 'run' input properly, rather than doing `RUN_INPUT_RUN=${{ inputs.run }}` in the script
CODSPEED_INPUT_RUN: ${{ inputs.run }}
run: |
# Validate required inputs
# (custom message for smoother v4 migration)
Expand Down Expand Up @@ -160,35 +166,42 @@ runs:
fi
fi

# Get the runner arguments
RUNNER_ARGS=""
# Build the runner arguments array
RUNNER_ARGS=()
if [ -n "${{ inputs.token }}" ]; then
RUNNER_ARGS="$RUNNER_ARGS --token ${{ inputs.token }}"
RUNNER_ARGS+=(--token "${{ inputs.token }}")
fi
if [ -n "${{ inputs.working-directory }}" ]; then
RUNNER_ARGS="$RUNNER_ARGS --working-directory=${{ inputs.working-directory }}"
RUNNER_ARGS+=(--working-directory="${{ inputs.working-directory }}")
fi
if [ -n "${{ inputs.upload-url }}" ]; then
RUNNER_ARGS="$RUNNER_ARGS --upload-url=${{ inputs.upload-url }}"
RUNNER_ARGS+=(--upload-url="${{ inputs.upload-url }}")
fi
if [ -n "${{ inputs.mode }}" ]; then
RUNNER_ARGS="$RUNNER_ARGS --mode=${{ inputs.mode }}"
RUNNER_ARGS+=(--mode="${{ inputs.mode }}")
fi
if [ -n "${{ inputs.instruments }}" ]; then
RUNNER_ARGS="$RUNNER_ARGS --instruments=${{ inputs.instruments }}"
RUNNER_ARGS+=(--instruments="${{ inputs.instruments }}")
fi
if [ -n "${{ inputs.mongo-uri-env-name }}" ]; then
RUNNER_ARGS="$RUNNER_ARGS --mongo-uri-env-name=${{ inputs.mongo-uri-env-name }}"
RUNNER_ARGS+=(--mongo-uri-env-name="${{ inputs.mongo-uri-env-name }}")
fi
if [ "${{ inputs.cache-instruments }}" = "true" ] && [ -n "${{ inputs.instruments-cache-dir }}" ]; then
RUNNER_ARGS="$RUNNER_ARGS --setup-cache-dir=${{ inputs.instruments-cache-dir }}"
RUNNER_ARGS+=(--setup-cache-dir="${{ inputs.instruments-cache-dir }}")
fi
if [ "${{ inputs.allow-empty }}" = "true" ]; then
RUNNER_ARGS="$RUNNER_ARGS --allow-empty"
RUNNER_ARGS+=(--allow-empty)
fi
if [ -n "${{ inputs.go-runner-version }}" ]; then
RUNNER_ARGS="$RUNNER_ARGS --go-runner-version=${{ inputs.go-runner-version }}"
RUNNER_ARGS+=(--go-runner-version="${{ inputs.go-runner-version }}")
fi
if [ -n "${{ inputs.config }}" ]; then
RUNNER_ARGS+=(--config="${{ inputs.config }}")
fi

if [ -n "$CODSPEED_INPUT_RUN" ]; then
RUNNER_ARGS+=(-- "$CODSPEED_INPUT_RUN")
fi

# Run the benchmarks
codspeed run $RUNNER_ARGS -- '${{ inputs.run }}'
codspeed run "${RUNNER_ARGS[@]}"
Loading