-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Measure coverage for integration tests in CI (#1893)
This change adds additional steps to the CI system that: 1. Builds a version of SAW with HPC support enabled 2. Runs the integration tests with the binaries produced in (1) 3. Generates an HTML coverage report from the HPC data from (2) and uploads this as an artifact tagged with the appropriate PR number 4. Downloads all coverage artifacts from all PRs and generates a website containing all of them (much like the cryptol docs). 5. Uploads this website to github pages A few things to note: * The coverage reports are hosted at https://galoisinc.github.io/saw-script * Step (4) generates the `index.html` file there that links to all available reports * Coverage reports are available so long as the underlying artifact is available. This is determined by a combination of the expiration date of the artifact (90 days after it is generated), as well as our artifact storage limits. This should be sufficient for coverage reports of active PRs, as well as history going back a bit.
- Loading branch information
Showing
6 changed files
with
221 additions
and
36 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,30 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# This script generates an HTML index file for all coverage reports | ||
|
||
import glob | ||
|
||
HEADER = """ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>SAWScript Test Coverage Results</title> | ||
</head> | ||
<body> | ||
<h1>SAWScript Test Coverage Results</h1> | ||
<p>SAWScript coverage results by pull request number:</p> | ||
<ul> | ||
""" | ||
|
||
FOOTER = """ | ||
</ul> | ||
</body> | ||
""" | ||
|
||
if __name__ == "__main__": | ||
with open("index.html", "w") as f: | ||
f.write(HEADER) | ||
for dir in sorted(glob.glob("coverage-html-*")): | ||
pr_num = dir[14:] | ||
link_dest = f"{dir}/hpc_index.html" | ||
f.write(f" <li><a href={link_dest}>{pr_num}</a></li>") | ||
f.write(FOOTER) |
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,3 @@ | ||
-- concatenated with cabal.project when run in the CI HPC build | ||
package saw-script | ||
coverage: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuxo pipefail | ||
|
||
# This script generates an HTML coverage report for any tests run within the | ||
# saw-script repo. It uses HPC, which is a tool in the standard GHC | ||
# distribution. Follow these steps to use this script: | ||
# 1. Build with coverage enabled. One way to do this is to add "coverage: true" | ||
# to the saw-script package in cabal.project. | ||
# 2. Run whatever tests you want. It is important that you use the saw binary | ||
# built in step (1), and that your current working directory be somewhere at | ||
# or underneath this top level-directory. | ||
# 3. Run this script in the top-level directory (where this script is found). | ||
# 4. You'll find the HPC HTML report in the "hpc-html" directory beneath the | ||
# directory containing this script. | ||
|
||
# Combine .tix files | ||
SUM_TIX="all.tix" | ||
hpc sum --output=$SUM_TIX --union --exclude=Main --exclude=GitRev $(find . -name "*.tix") | ||
|
||
# Generate report | ||
HPC_ROOT=$(find dist-newstyle -name "hpc") | ||
HPC_ARGS="" | ||
for dir in ${HPC_ROOT}/vanilla/mix/*; do | ||
HPC_ARGS="${HPC_ARGS} --hpcdir=${dir}" | ||
done | ||
hpc markup --destdir=hpc-html ${HPC_ARGS} ${SUM_TIX} |
This file was deleted.
Oops, something went wrong.