Commit 4049b3a
Enforce minimum code coverage threshold in CI pipeline (Azure#7188)
* Enforce minimum code coverage threshold in CI pipeline
Add a coverage gate to the CodeCoverage_Upload stage that fails the build
when total statement coverage drops below a configured minimum.
- New Test-CodeCoverageThreshold.ps1 script parses 'go tool cover -func'
output and fails if coverage is below the threshold
- New MinimumCoveragePercent parameter on code-coverage-upload.yml
(default 0 = disabled)
- Set threshold to 80% in release-cli.yml to validate the mechanism
(will be adjusted to the actual floor after verification)
Fixes Azure#7187
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix coverage threshold step to use PowerShell task directly
The previous approach nested 'pwsh -File' inside a pwsh inline step,
which caused $CoverageFile to be treated as a literal string instead
of the script parameter. Switch to PowerShell@2 task with targetType:
filePath so arguments are passed correctly.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix PowerShell variable interpolation in go tool cover argument
Double-quote the '-func=$CoverageFile' argument so PowerShell expands
the variable. Without quotes, PowerShell passes the literal string
'$CoverageFile' to the go command.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Set workingDirectory to cli/azd for go tool cover module resolution
go tool cover -func needs to resolve Go module paths from the coverage
file. Run the threshold check from cli/azd/ where go.mod lives, and
pass the absolute path to cover.out.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address PR review feedback
- Set threshold to 48% to match current baseline
- Add ValidateRange(0,100) on MinimumCoveragePercent parameter
- Find total line by 'total:' prefix instead of assuming last line
- Match both integer and decimal percentages with invariant culture parsing
- Add condition: succeededOrFailed() to PublishCodeCoverageResults so
coverage reports are still uploaded when the threshold check fails
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 2517925 commit 4049b3a
3 files changed
Lines changed: 82 additions & 0 deletions
File tree
- eng
- pipelines
- templates/stages
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
59 | 62 | | |
60 | 63 | | |
61 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
62 | 75 | | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments