forked from rsksmart/rsk-powhsm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rsksmart:master' into master
- Loading branch information
Showing
32 changed files
with
363 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: "Code coverage" | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
coverage: | ||
name: Run tests and generate coverage reports | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout this repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build the middleware docker image | ||
run: docker/mware/build | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.CODECOVERAGE_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.CODECOVERAGE_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.CODECOVERAGE_AWS_REGION }} | ||
|
||
- name: Run middleware coverage script | ||
run: | | ||
middleware/test-all-coverage | ||
COVPCT=$(cat middleware/coverage/total) | ||
COVCOL=$(utils/coverage-color.sh $COVPCT) | ||
echo "{ \"schemaVersion\": 1, \"label\": \"Middleware coverage\", \"message\": \"$COVPCT%\", \"color\": \"$COVCOL\" }" > middleware/coverage/badge.json | ||
- name: "Upload middleware coverage report" | ||
run: | | ||
aws s3 sync \ | ||
middleware/coverage/ \ | ||
s3://${{ secrets.CODECOVERAGE_S3_BUCKET }}/powhsm_4.1.x/middleware_coverage_report \ | ||
--sse aws:kms --sse-kms-key-id ${{ secrets.CODECOVERAGE_KMS_KEY_ID }} \ | ||
--no-progress --follow-symlinks --delete --only-show-errors | ||
- name: Run firmware coverage script | ||
run: | | ||
ledger/coverage/gen-coverage | ||
COVPCT=$(cat ledger/coverage/output/total) | ||
COVCOL=$(utils/coverage-color.sh $COVPCT) | ||
echo "{ \"schemaVersion\": 1, \"label\": \"Firmware coverage\", \"message\": \"$COVPCT%\", \"color\": \"$COVCOL\" }" > ledger/coverage/output/badge.json | ||
- name: "Upload firmware coverage report" | ||
run: | | ||
aws s3 sync \ | ||
ledger/coverage/output/ \ | ||
s3://${{ secrets.CODECOVERAGE_S3_BUCKET }}/powhsm_4.1.x/firmware_coverage_report \ | ||
--sse aws:kms --sse-kms-key-id ${{ secrets.CODECOVERAGE_KMS_KEY_ID }} \ | ||
--no-progress --follow-symlinks --delete --only-show-errors | ||
- name: Invalidate CloudFront cache | ||
run: | | ||
aws cloudfront create-invalidation \ | ||
--distribution-id ${{ secrets.CODECOVERAGE_CLOUDFRONT_DIST_ID }} --paths "/*" |
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
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,2 @@ | ||
coverage.info | ||
output |
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,6 @@ | ||
ifeq ($(COVERAGE),y) | ||
COVFLAGS = --coverage | ||
else | ||
COVFLAGS = | ||
endif | ||
COVFILES = *.gcda *.gcno |
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,41 @@ | ||
#!/bin/bash | ||
|
||
if [[ $1 == "exec" ]]; then | ||
BASEDIR=$(realpath $(dirname $0)) | ||
SRCDIR=$(realpath $BASEDIR/../src) | ||
REPOROOT=$(realpath $BASEDIR/../..) | ||
|
||
# Remove any existing coverage data | ||
rm -rf $BASEDIR/coverage.info $BASEDIR/output | ||
find $REPOROOT/ledger -name "*.gcno" -o -name "*.gcda" | xargs rm -f | ||
|
||
# Run firmware unit tests with coverage generation | ||
COVERAGE=y $REPOROOT/ledger/src/signer/test/run-all.sh | ||
COVERAGE=y $REPOROOT/ledger/src/ui/test/run-all.sh | ||
|
||
# Run tcpsigner test suite | ||
pushd $REPOROOT/ledger/src/tcpsigner > /dev/null | ||
COVERAGE=y make clean all | ||
./tcpsigner --checkpoint 0xbdcb3c17c7aee714cec8ad900341bfd987b452280220dcbd6e7191f67ea4209b --difficulty 0x32 --network regtest > /dev/null & | ||
popd > /dev/null | ||
|
||
pushd $REPOROOT/ledger/test > /dev/null | ||
python run.py | ||
err_code=$? | ||
popd > /dev/null | ||
|
||
lcov --capture --directory $SRCDIR --list-full-path --output-file $BASEDIR/coverage.info | ||
genhtml $BASEDIR/coverage.info --output $BASEDIR/output -p $SRCDIR -t "powHSM firmware" | ||
lcov --summary $BASEDIR/coverage.info | grep lines | sed -e "s/.\+lines.\+: \([[:digit:].]\+\).\+/\1/g" > $BASEDIR/output/total | ||
mv $BASEDIR/coverage.info $BASEDIR/output | ||
else | ||
# Script directory | ||
REPOROOT=$(realpath $(dirname $0)/../..) | ||
SCRIPT=$(realpath $0 --relative-to=$REPOROOT) | ||
|
||
# Generate coverage report | ||
$REPOROOT/docker/mware/do-notty-nousb /hsm2 "./$SCRIPT exec" | ||
err_code=$? | ||
fi | ||
|
||
exit $err_code |
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 |
---|---|---|
|
@@ -13,3 +13,7 @@ tcpsigner/**/*.json | |
# Icons hex | ||
signer/icon.hex | ||
ui/icon.hex | ||
|
||
# Code coverage artifacts | ||
*.gcda | ||
*.gcno |
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
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
Oops, something went wrong.