Description
I am trying to set up a monorepo containing many separate publishable packages. My goal is to use flags to report the coverage percentage for each package separately. Even though I am using the carryforward
flag, the coverage becomes unknown
if a report is published that doesn’t contain that specific package. Often if something should be working, I’m just missing something small so I thought I’d see if anyone has any idea.
My goal is to support this type of table with coverage reporting per package:
- In
codecov.yml
I am defining all my flags:
flags:
autocomplete:
paths:
- libs/ui/autocomplete/
carryforward: true
autofocus:
paths:
- libs/ui/autofocus/
carryforward: true
# etc...
- In each CI run this custom upload script is used to only upload the packages that have generated coverage (see below in the
Uploader
section).
Repository
CI/CD
GitHub Actions
Example CI run that only generated coverage for a single package: https://github.com/GetTerminus/terminus-oss/runs/1211082149?check_suite_focus=true#step:16:1
Uploader
upload_coverage () {
FILES=$(find "$1" -name 'coverage-final.json')
PREFIX=$1
SUFFIX='/coverage-final.json'
for FILE in $FILES
do
# Remove the preceding file path
TAG=${FILE#"$PREFIX"}
# Remove the filename
TAG=${TAG%"$SUFFIX"}
# Remove the remaining slash prefix
TAG=${TAG//\/}
# Convert dash-case to camelCase
TAG=$(echo "$TAG" | perl -pe 's/-(.)/\u$1/g')
echo "Uploading coverage for \"$FILE\" tagged as \"$TAG\""
bash <(curl https://codecov.io/bash) -v -Z -f "$FILE" -F "$TAG" || echo "Codecov failed to upload coverage for $FILE"
done
}
LOCATIONS=('coverage/libs/ui' 'coverage/apps')
for L in "${LOCATIONS[@]}"; do
upload_coverage "$L"
done
Commit SHAs
Happens on basically every PR, but here is the latest at the moment: 77ace1f1099c093160867c2a017416b0eac442df
Codecov YAML
codecov:
notify:
require_ci_to_pass: yes
coverage:
range: 90..100
round: down
precision: 2
status:
project:
default: off
unit:
flags: unit
comment:
layout: "reach, diff, flags, files"
behavior: default
flags:
autocomplete:
paths:
- libs/ui/autocomplete/
carryforward: true
autofocus:
paths:
- libs/ui/autofocus/
carryforward: true
button:
paths:
- libs/ui/button/
carryforward: true
card:
paths:
- libs/ui/card/
carryforward: true
chart:
paths:
- libs/ui/chart/
carryforward: true
checkbox:
paths:
- libs/ui/checkbox/
carryforward: true
chip:
paths:
- libs/ui/chip/
carryforward: true
cohortDateRange:
paths:
- libs/ui/cohort-date-range/
carryforward: true
confirmation:
paths:
- libs/ui/confirmation/
carryforward: true
copy:
paths:
- libs/ui/copy/
carryforward: true
csvEntry:
paths:
- libs/ui/csv-entry/
carryforward: true
dateRange:
paths:
- libs/ui/date-range/
carryforward: true
drawer:
paths:
- libs/ui/drawer/
carryforward: true
expxansionPanel:
paths:
- libs/ui/expansion-panel/
carryforward: true
fileUpload:
paths:
- libs/ui/file-upload/
carryforward: true
formField:
paths:
- libs/ui/form-field/
carryforward: true
icon:
paths:
- libs/ui/icon/
carryforward: true
iconButton:
paths:
- libs/ui/icon-button/
carryforward: true
input:
paths:
- libs/ui/input/
carryforward: true
link:
paths:
- libs/ui/link/
carryforward: true
loadingOverlay:
paths:
- libs/ui/loading-overlay/
carryforward: true
loginForm:
paths:
- libs/ui/login-form/
carryforward: true
logo:
paths:
- libs/ui/logo/
carryforward: true
menu:
paths:
- libs/ui/menu/
carryforward: true
navigation:
paths:
- libs/ui/navigation/
carryforward: true
option:
paths:
- libs/ui/option/
carryforward: true
paginator:
paths:
- libs/ui/paginator/
carryforward: true
pipes:
paths:
- libs/ui/pipes/
carryforward: true
popover:
paths:
- libs/ui/popover/
carryforward: true
radioGroup:
paths:
- libs/ui/radio-group/
carryforward: true
scrollbars:
paths:
- libs/ui/scrollbars/
carryforward: true
seach:
paths:
- libs/ui/search/
carryforward: true
select:
paths:
- libs/ui/select/
carryforward: true
selectionList:
paths:
- libs/ui/selection-list/
carryforward: true
sort:
paths:
- libs/ui/sort/
carryforward: true
spacing:
paths:
- libs/ui/spacing/
carryforward: true
styles:
paths:
- libs/ui/styles/
carryforward: true
table:
paths:
- libs/ui/table/
carryforward: true
tabs:
paths:
- libs/ui/tabs/
carryforward: true
toggle:
paths:
- libs/ui/toggle/
carryforward: true
tooltip:
paths:
- libs/ui/tooltip/
carryforward: true
utilities:
paths:
- libs/ui/utilities/
carryforward: true
validationMessages:
paths:
- libs/ui/validation-messages/
carryforward: true
validators:
paths:
- libs/ui/validators/
carryforward: true
feUtilities:
paths:
- libs/fe-utilities/
carryforward: true
feJwt:
paths:
- libs/fe-jwt/
carryforward: true
feTesting:
paths:
- libs/fe-testing/
carryforward: true
ignore:
- "coverage"
- "dist"
- "docs"
- "node_modules"
- "out-tsc"
- "apps/vr"
- "tooling"
- "libs/**/*.spec.ts"
- "libs/**/*.mock.ts"
Codecov Output
My output was too long to include in this post, so I have uploaded the txt file here: 16_Upload coverage results ...