mirror of
https://github.com/storytold/craft-common-actions.git
synced 2026-11-15 15:02:24 +00:00
sonarcloud: opt-in SQLX_OFFLINE and extra cargo features for the coverage build (#195)
This commit is contained in:
1 parent
0588474894
commit
91e2c76173
1 file changed
+38
-4
@@ -28,6 +28,20 @@ on:
|
||||
type: string
|
||||
required: false
|
||||
default: ""
|
||||
sqlx-offline:
|
||||
description: >-
|
||||
Build with SQLX_OFFLINE=true, so sqlx's query macros read the committed .sqlx metadata
|
||||
instead of connecting to the DATABASE_URL a repository's .env may name.
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
cargo-features:
|
||||
description: >-
|
||||
Extra cargo features for the coverage build, e.g. some-crate/skip_database_tests
|
||||
(comma separated; empty adds none).
|
||||
type: string
|
||||
required: false
|
||||
default: ""
|
||||
node-coverage-script:
|
||||
description: >-
|
||||
Optional npm script that runs the JavaScript/TypeScript tests with coverage (e.g. test:coverage),
|
||||
@@ -235,11 +249,21 @@ jobs:
|
||||
CARGO_TERM_COLOR: always
|
||||
# Coverage comes from instrumentation, not DWARF; debuginfo is most of target/.
|
||||
CARGO_PROFILE_DEV_DEBUG: "0"
|
||||
SQLX_OFFLINE_INPUT: ${{ inputs.sqlx-offline }}
|
||||
CARGO_FEATURES: ${{ inputs.cargo-features }}
|
||||
run: |
|
||||
# Opt-in build settings; validated because they reach the cargo command line.
|
||||
if [[ ! "$CARGO_FEATURES" =~ ^[A-Za-z0-9_/,-]*$ ]]; then
|
||||
echo "::error::cargo-features may only hold feature names, '/', '-', '_' and ',', got '$CARGO_FEATURES'"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$SQLX_OFFLINE_INPUT" = true ]; then export SQLX_OFFLINE=true; fi
|
||||
features=()
|
||||
if [ -n "$CARGO_FEATURES" ]; then features=(--features "$CARGO_FEATURES"); fi
|
||||
# show-env sets the instrumentation flags the same way the unsharded run gets them.
|
||||
# shellcheck disable=SC1090 # generated by cargo-llvm-cov at runtime
|
||||
source <(cargo llvm-cov show-env --sh)
|
||||
cargo nextest archive --workspace --archive-file nextest-archive.tar.zst
|
||||
cargo nextest archive --workspace "${features[@]}" --archive-file nextest-archive.tar.zst
|
||||
- name: Record the toolchain that built the archive
|
||||
run: |
|
||||
rustc -vV | sed -n 's/^release: //p' > rustc-release.txt
|
||||
@@ -501,9 +525,19 @@ jobs:
|
||||
CARGO_TERM_COLOR: always
|
||||
# Coverage comes from instrumentation, not DWARF; debuginfo is most of target/.
|
||||
CARGO_PROFILE_DEV_DEBUG: "0"
|
||||
run: >
|
||||
cargo llvm-cov --workspace --ignore-run-fail --lcov --output-path lcov.info
|
||||
--ignore-filename-regex "$COVERAGE_IGNORE"
|
||||
SQLX_OFFLINE_INPUT: ${{ inputs.sqlx-offline }}
|
||||
CARGO_FEATURES: ${{ inputs.cargo-features }}
|
||||
run: |
|
||||
# Opt-in build settings; validated because they reach the cargo command line.
|
||||
if [[ ! "$CARGO_FEATURES" =~ ^[A-Za-z0-9_/,-]*$ ]]; then
|
||||
echo "::error::cargo-features may only hold feature names, '/', '-', '_' and ',', got '$CARGO_FEATURES'"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$SQLX_OFFLINE_INPUT" = true ]; then export SQLX_OFFLINE=true; fi
|
||||
features=()
|
||||
if [ -n "$CARGO_FEATURES" ]; then features=(--features "$CARGO_FEATURES"); fi
|
||||
cargo llvm-cov --workspace "${features[@]}" --ignore-run-fail --lcov --output-path lcov.info \
|
||||
--ignore-filename-regex "$COVERAGE_IGNORE"
|
||||
- name: Download shard profiles and archive
|
||||
if: steps.token.outputs.available == 'true' && inputs.shards > 1 && hashFiles('Cargo.toml') != ''
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
|
||||
Reference in new issue
Block a user