diff --git a/.codspeed-runner-version b/.codspeed-runner-version index 6ed7776..2da4316 100644 --- a/.codspeed-runner-version +++ b/.codspeed-runner-version @@ -1 +1 @@ -4.9.0 +4.10.0 diff --git a/.github/test-codspeed.yml b/.github/test-codspeed.yml new file mode 100644 index 0000000..a6d1aa6 --- /dev/null +++ b/.github/test-codspeed.yml @@ -0,0 +1,5 @@ +benchmarks: + - name: "test" + exec: echo "Working!" + - name: "test2" + exec: echo "Also working!" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af69b24..4c6917d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: ./ @@ -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 diff --git a/README.md b/README.md index dda0933..263069b 100644 --- a/README.md +++ b/README.md @@ -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: "" # [REQUIRED] @@ -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: "" diff --git a/action.yml b/action.yml index 0ee33d7..c9f562d 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ author: "Arthur Pastel" inputs: run: description: "The command to run the benchmarks" - required: true + required: false mode: description: | @@ -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: @@ -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) @@ -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[@]}"