Skip to content
Snippets Groups Projects
Verified Commit 6daa8915 authored by tusooa's avatar tusooa :mountain_snow:
Browse files

Add coverage report

Summary: Add a coverage report to the pipeline.

Test Plan: Verify that we can see a coverage report.

Differential Revision: https://iron.lily-is.land/D72
parent ae0ef916
No related branches found
No related merge requests found
Pipeline #4217 passed
......@@ -10,6 +10,8 @@ workflow:
stages:
- prepare
- build
- coverage-vis
- upload-coverage-to-phorge
- report
.report:
......@@ -22,14 +24,6 @@ stages:
before_script:
- pipelineUrl="$CI_PROJECT_URL"/-/pipelines/"$CI_PIPELINE_ID"
default:
after_script:
- touch status.env
- 'if [ "$CI_JOB_STATUS" != "success" ]; then echo FAILED=1 >> status.env; fi'
artifacts: &defaultArtifacts
reports:
dotenv: status.env
prepare-env:
stage: prepare
script: |
......@@ -46,46 +40,57 @@ report-start:
build-debug:
stage: build
image:
name: 'ubuntu:21.04'
script: |
./script.sh
name: 'reg.lily.kazv.moe/kazv/libkazv-deps/deps:servant'
script:
- mkdir build
- cd build
- g++ -fprofile-arcs -ftest-coverage -fPIC -O0 -o hello ../hello.cpp
- ./hello
- gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml -r "${CI_PROJECT_DIR}" --object-directory .
coverage: /^\s*lines:\s*\d+.\d+\%/
artifacts:
<<: *defaultArtifacts
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
paths:
- testfile
expire_in: 1 week
- build/coverage.xml
reports:
coverage_report:
coverage_format: cobertura
path: build/coverage.xml
build-other:
stage: build
image:
name: 'ubuntu:21.04'
script: |
./script.sh
false
'coverage-report':
stage: coverage-vis
image: 'reg.lily.kazv.moe/infra/phorge-ci-tools/pycobertura:servant'
script:
- pycobertura show ./build/coverage.xml --format html --output ./build/coverage.html --source .
- /tools/cobertura-to-phorge ./build/coverage.xml . > ./build/coverage.json
artifacts:
<<: *defaultArtifacts
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
paths:
- testfile
expire_in: 1 week
- build/coverage.html
- build/coverage.json
another:
stage: build
image:
name: 'ubuntu:21.04'
script: |
export VAR=foo
./script.sh
false
artifacts:
<<: *defaultArtifacts
paths:
- testfile
expire_in: 1 week
upload-coverage:
extends: .report
stage: upload-coverage-to-phorge
script:
- '{ echo "{\"receiver\": \"$TARGET_PHID\", \"type\": \"work\", \"unit\": [{\"name\": \"Test coverage\", \"result\": \"pass\", \"details\": \"$pipelineUrl\", \"format\": \"remarkup\", \"coverage\":"; cat build/coverage.json; echo "}]}"; } | /tools/arcanist/bin/arc call-conduit --conduit-uri https://iron.lily-is.land/ --conduit-token "$CONDUIT_TOKEN" -- harbormaster.sendmessage'
report-final:
report-success:
extends: .report
rules:
- if: $TARGET_PHID
when: on_success
- when: never
stage: report
script:
- 'echo "{\"receiver\": \"$TARGET_PHID\", \"type\": \"pass\"}" | /tools/arcanist/bin/arc call-conduit --conduit-uri https://iron.lily-is.land/ --conduit-token "$CONDUIT_TOKEN" -- harbormaster.sendmessage'
report-failure:
extends: .report
rules:
- if: $TARGET_PHID
when: on_failure
- when: never
stage: report
script:
- TYPE=pass
- if [ -n "$FAILED" ]; then TYPE=fail; fi
- 'echo "{\"receiver\": \"$TARGET_PHID\", \"type\": \"$TYPE\"}" | /tools/arcanist/bin/arc call-conduit --conduit-uri https://iron.lily-is.land/ --conduit-token "$CONDUIT_TOKEN" -- harbormaster.sendmessage'
- 'echo "{\"receiver\": \"$TARGET_PHID\", \"type\": \"fail\"}" | /tools/arcanist/bin/arc call-conduit --conduit-uri https://iron.lily-is.land/ --conduit-token "$CONDUIT_TOKEN" -- harbormaster.sendmessage'
#include <iostream>
#include <string>
int main(int argc, char *argv[])
{
if (argv[0] == std::string("hello")) {
std::cout << "hello\n";
} else {
std::cout << "not hello\n";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment