-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
170 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: llvm coverage | ||
description: Sets up everything that is needed for coverage. Makes artifacts available for processing later, prefixed with cov- | ||
inputs: | ||
name: | ||
description: 'the name of the artifact' | ||
required: true | ||
outputs: | ||
artifact-name: | ||
description: 'the name of the artifact' | ||
value: ${{ steps.cov.outputs.artifact-name }} | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Install cargo-llvm-cov | ||
uses: taiki-e/install-action@v1 | ||
with: | ||
tool: cargo-llvm-cov | ||
- run: rustup component add llvm-tools-preview | ||
shell: bash | ||
- name: llvm coverage | ||
id: cov | ||
uses: ./.github/actions/post | ||
if: always() | ||
with: | ||
main: | | ||
pwd=$(pwd) | ||
if which cygpath; then | ||
pwd="$(cygpath -w "$(pwd)")" | ||
fi | ||
echo RUSTFLAGS=" -C instrument-coverage --remap-path-prefix ${pwd}=" >> $GITHUB_ENV | ||
echo LLVM_PROFILE_FILE="${pwd}/target/cross-%m.profraw" >> $GITHUB_ENV | ||
echo CARGO_INCREMENTAL="0" >> $GITHUB_ENV | ||
echo RUST_TEST_THREADS="1" >> $GITHUB_ENV | ||
echo "::set-output name=artifact-name::coverage-${name}" | ||
post: | | ||
# TODO: Only run on success? | ||
# No pwd needed here, we're in the root | ||
export LLVM_PROFILE_FILE="target/cross-%m.profraw" | ||
export CARGO_LLVM_COV_TARGET_DIR="target" | ||
mkdir coverage | ||
echo $(ls target) | ||
cargo llvm-cov --no-run --remap-path-prefix --lcov --output-path "coverage/lcov.${name}.info" -vv || ( echo "::error title=Coverage failed::" && exit 0 ) | ||
cargo llvm-cov --no-run --remap-path-prefix --json --output-path "coverage/${name}.json" -vv || true | ||
rm target/*.profraw | ||
npm install @actions/artifact | ||
npm install glob | ||
cat <<-EOT | node - || ( echo "::error title=Coverage upload failed::" && exit 0 ) | ||
(async function main() { | ||
var artifact = require('@actions/artifact'); | ||
var glob = require('glob') | ||
const artifactClient = artifact.create(); | ||
const artifactName = 'coverage-' + process.env.name; | ||
const files = glob.sync("coverage/*"); | ||
if (!files.length) { | ||
process.exit(0); | ||
} | ||
console.log("${files}") | ||
const options = { retentionDays: 2 }; | ||
const upload = await artifactClient.uploadArtifact(artifactName, files, "coverage", options); | ||
})() | ||
EOT | ||
env: | ||
name: ${{ inputs.name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# adapted from https://github.com/actions/runner/issues/1478 | ||
name: With post step | ||
description: 'Generic JS Action to execute a main command and set a command in a post step.' | ||
inputs: | ||
main: | ||
description: 'Main command/script.' | ||
required: true | ||
post: | ||
description: 'Post command/script.' | ||
required: true | ||
runs: | ||
using: 'node16' | ||
main: 'main.js' | ||
post: 'main.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// adapted from https://github.com/actions/runner/issues/1478 | ||
const { exec } = require("child_process"); | ||
|
||
function run(cmd) { | ||
exec(cmd, { shell: "bash" }, (error, stdout, stderr) => { | ||
if (stdout.length != 0) { | ||
console.log(`${stdout}`); | ||
} | ||
if (stderr.length != 0) { | ||
console.error(`${stderr}`); | ||
} | ||
if (error) { | ||
process.exitCode = error.code; | ||
console.error(`${error}`); | ||
} | ||
}); | ||
} | ||
|
||
if (process.env[`STATE_POST`] != undefined) { | ||
// Are we in the 'post' step? | ||
run(process.env.INPUT_POST); | ||
} else { | ||
// Otherwise, this is the main step | ||
console.log(`::save-state name=POST::true`); | ||
run(process.env.INPUT_MAIN); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
comment: false | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
informational: true | ||
patch: | ||
default: | ||
informational: true | ||
flag_management: | ||
default_rules: # the rules that will be followed for any flag added, generally | ||
carryforward: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters