From ecd7a699fea0b6a9e5dafbf2cdeb89b77fa9ddb4 Mon Sep 17 00:00:00 2001 From: Leynos Date: Tue, 24 Jun 2025 19:25:40 +0100 Subject: [PATCH 1/3] refactor: unify coverage detection and validation --- .github/actions/generate-coverage/CHANGELOG.md | 14 +++++++++----- .github/actions/generate-coverage/action.yml | 13 ++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/actions/generate-coverage/CHANGELOG.md b/.github/actions/generate-coverage/CHANGELOG.md index 844a3858..f884314e 100644 --- a/.github/actions/generate-coverage/CHANGELOG.md +++ b/.github/actions/generate-coverage/CHANGELOG.md @@ -1,17 +1,21 @@ # Changelog -## v1.1.0 (2025-06-23) +## v1.1.2 (2025-06-25) -- Support Python projects by running `slipcover` when `pyproject.toml` is present. -- Expose `file` and `format` outputs. -- Default coverage format changed to `cobertura`. -- Fail fast if both `Cargo.toml` and `pyproject.toml` exist. +- Merge detection and validation into a single step to simplify the workflow. ## v1.1.1 (2025-06-24) - Automatically install `slipcover` and `pytest` using `setup-uv` when running Python coverage. +## v1.1.0 (2025-06-23) + +- Support Python projects by running `slipcover` when `pyproject.toml` is present. +- Expose `file` and `format` outputs. +- Default coverage format changed to `cobertura`. +- Fail fast if both `Cargo.toml` and `pyproject.toml` exist. + ## v1.0.0 (2025-06-20) - Initial version using `cargo llvm-cov` for Rust projects. diff --git a/.github/actions/generate-coverage/action.yml b/.github/actions/generate-coverage/action.yml index b6c8f64b..cf620a8a 100644 --- a/.github/actions/generate-coverage/action.yml +++ b/.github/actions/generate-coverage/action.yml @@ -36,17 +36,14 @@ runs: echo "Found both Cargo.toml and pyproject.toml; not supported" >&2 exit 1 elif [ -f Cargo.toml ]; then - echo "lang=rust" >> "$GITHUB_OUTPUT" + lang=rust elif [ -f pyproject.toml ]; then - echo "lang=python" >> "$GITHUB_OUTPUT" + lang=python else echo "Neither Cargo.toml nor pyproject.toml found" >&2 exit 1 fi - shell: bash - - id: validate - run: | - set -euo pipefail + case "${{ inputs.format }}" in lcov|cobertura|coveragepy) ;; *) @@ -54,7 +51,7 @@ runs: exit 1 ;; esac - lang='${{ steps.detect.outputs.lang }}' + if [[ "$lang" == 'rust' && "${{ inputs.format }}" == 'coveragepy' ]]; then echo "coveragepy format only supported for Python projects" >&2 exit 1 @@ -63,6 +60,8 @@ runs: echo "lcov format only supported for Rust projects" >&2 exit 1 fi + + echo "lang=$lang" >> "$GITHUB_OUTPUT" shell: bash - if: steps.detect.outputs.lang == 'rust' run: | From 1176665e290297f1e69737fa3cba3529709f2d31 Mon Sep 17 00:00:00 2001 From: Leynos Date: Tue, 24 Jun 2025 21:50:18 +0100 Subject: [PATCH 2/3] Improve coverage action lang handling --- .github/actions/generate-coverage/CHANGELOG.md | 2 +- .github/actions/generate-coverage/action.yml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/actions/generate-coverage/CHANGELOG.md b/.github/actions/generate-coverage/CHANGELOG.md index f884314e..b88c84df 100644 --- a/.github/actions/generate-coverage/CHANGELOG.md +++ b/.github/actions/generate-coverage/CHANGELOG.md @@ -2,7 +2,7 @@ ## v1.1.2 (2025-06-25) -- Merge detection and validation into a single step to simplify the workflow. +- Merge detection and validation into a single step and track the language in `LANG_DETECTED`. ## v1.1.1 (2025-06-24) diff --git a/.github/actions/generate-coverage/action.yml b/.github/actions/generate-coverage/action.yml index cf620a8a..92e7c393 100644 --- a/.github/actions/generate-coverage/action.yml +++ b/.github/actions/generate-coverage/action.yml @@ -61,9 +61,9 @@ runs: exit 1 fi - echo "lang=$lang" >> "$GITHUB_OUTPUT" + echo "LANG_DETECTED=$lang" >> "$GITHUB_ENV" shell: bash - - if: steps.detect.outputs.lang == 'rust' + - if: env.LANG_DETECTED == 'rust' run: | set -euo pipefail args=(--workspace) @@ -78,11 +78,11 @@ runs: cargo llvm-cov "${args[@]}" shell: bash - name: Install uv and set the python version - if: steps.detect.outputs.lang == 'python' + if: env.LANG_DETECTED == 'python' uses: astral-sh/setup-uv@v5 - name: Cache Python deps - if: steps.detect.outputs.lang == 'python' + if: env.LANG_DETECTED == 'python' uses: actions/cache@v4 with: path: ~/.cache/uv @@ -91,11 +91,11 @@ runs: ${{ runner.os }}-py-deps- - name: Install slipcover and pytest - if: steps.detect.outputs.lang == 'python' + if: env.LANG_DETECTED == 'python' run: uv pip install --system slipcover pytest shell: bash - - if: steps.detect.outputs.lang == 'python' + - if: env.LANG_DETECTED == 'python' run: | set -euo pipefail mkdir -p "$(dirname "${{ inputs.output-path }}")" @@ -118,5 +118,5 @@ runs: run: | echo "file=${{ inputs.output-path }}" >> "$GITHUB_OUTPUT" echo "format=${{ inputs.format }}" >> "$GITHUB_OUTPUT" - echo "lang=${{ steps.detect.outputs.lang }}" >> "$GITHUB_OUTPUT" + echo "lang=$LANG_DETECTED" >> "$GITHUB_OUTPUT" shell: bash From 0a8ef455fb589273b9105f206cf088d88cc4f318 Mon Sep 17 00:00:00 2001 From: Leynos Date: Tue, 24 Jun 2025 22:52:24 +0100 Subject: [PATCH 3/3] Address PR feedback --- .github/actions/generate-coverage/CHANGELOG.md | 2 +- .github/actions/generate-coverage/action.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/generate-coverage/CHANGELOG.md b/.github/actions/generate-coverage/CHANGELOG.md index b88c84df..f417a722 100644 --- a/.github/actions/generate-coverage/CHANGELOG.md +++ b/.github/actions/generate-coverage/CHANGELOG.md @@ -2,7 +2,7 @@ ## v1.1.2 (2025-06-25) -- Merge detection and validation into a single step and track the language in `LANG_DETECTED`. +- Merge detection and validation into a single step and track the language in the `LANG_DETECTED` environment variable. ## v1.1.1 (2025-06-24) diff --git a/.github/actions/generate-coverage/action.yml b/.github/actions/generate-coverage/action.yml index 92e7c393..23a4ac24 100644 --- a/.github/actions/generate-coverage/action.yml +++ b/.github/actions/generate-coverage/action.yml @@ -116,6 +116,7 @@ runs: shell: bash - id: out run: | + set -euo pipefail echo "file=${{ inputs.output-path }}" >> "$GITHUB_OUTPUT" echo "format=${{ inputs.format }}" >> "$GITHUB_OUTPUT" echo "lang=$LANG_DETECTED" >> "$GITHUB_OUTPUT"