Merging code coverage, download artifacts to individual destination folders
- Dominant language
- PowerShell
- Stars
- 243
- Forks
- 46
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 1
Description
### Problem description
When merging code coverage from several jobs the task to download pipeline artifacts must specify individual destination folder. This in necessary if each test job is generating the same filename for the code coverage output.
### Verbose logs
```text
2022-04-18T13:42:40.3476818Z ===============================================================================
2022-04-18T13:42:40.3512329Z [96m MERGE CODECOVERAGE FILES[0m
2022-04-18T13:42:40.3879113Z [90mMerging several code coverage files together.[0m
2022-04-18T13:42:40.3886134Z -------------------------------------------------------------------------------
2022-04-18T13:42:40.3894370Z [90m /merge/Merge_CodeCoverage_Files[0m
2022-04-18T13:42:40.3903321Z [90m /home/vsts/work/1/s/output/RequiredModules/Sampler/0.112.3/tasks/JaCoCo.coverage.build.ps1:57[0m
2022-04-18T13:42:40.3907722Z
2022-04-18T13:42:40.4342262Z Project Name = 'DscResource.Test'
2022-04-18T13:42:40.4569695Z Source Path = '/home/vsts/work/1/s/source'
2022-04-18T13:42:40.4628993Z Output Directory = '/home/vsts/work/1/s/output'
2022-04-18T13:42:40.4634106Z Release Notes path = '/home/vsts/work/1/s/output/ReleaseNotes.md'
2022-04-18T13:42:40.4650331Z Built Module Subdirectory = '/home/vsts/work/1/s/output/'
2022-04-18T13:42:40.4658750Z Module Manifest Path (src) = '/home/vsts/work/1/s/source/DscResource.Test.psd1'
2022-04-18T13:42:40.4706043Z Versioned Output Directory = 'True'
2022-04-18T13:42:40.5022383Z Built Module Manifest = '/home/vsts/work/1/s/output/DscResource.Test/0.16.1/DscResource.Test.psd1'
2022-04-18T13:42:40.5065609Z Built Module Base = '/home/vsts/work/1/s/output/DscResource.Test/0.16.1'
2022-04-18T13:42:40.5239117Z Module Version = '0.16.1-pr0123'
2022-04-18T13:42:40.5250489Z Module Version Folder = '0.16.1'
2022-04-18T13:42:40.5258583Z Pre-release Tag = 'pr0123'
2022-04-18T13:42:40.5340955Z Built Module Root Script = '/home/vsts/work/1/s/output/DscResource.Test/0.16.1/DscResource.Test.psm1'
2022-04-18T13:42:40.5341626Z
2022-04-18T13:42:40.5352926Z Pester Output Folder = '/home/vsts/work/1/s/output/testResults'
2022-04-18T13:42:40.5434750Z Code Coverage Threshold = '50'
2022-04-18T13:42:40.5546839Z Code Coverage Output File = /home/vsts/work/1/s/output/testResults/JaCoCo_Merge.xml
2022-04-18T13:42:40.5585304Z Code Coverage Merge Output File = /home/vsts/work/1/s/output/testResults/JaCoCo_coverage.xml
2022-04-18T13:42:40.5588101Z Code Coverage File Pattern = JaCoCo_Merge.xml
2022-04-18T13:42:40.5589551Z Merging Code Coverage Files = '/home/vsts/work/1/s/output/testResults/JaCoCo_Merge.xml'
2022-04-18T13:42:40.5590150Z
2022-04-18T13:42:40.5590903Z [97mProcessing folder: /home/vsts/work/1/s/output[0m
2022-04-18T13:42:40.5906605Z [91mERROR: Found 1 code coverage file. Need at least two files to merge.[0m
2022-04-18T13:42:40.5908089Z [91mAt /home/vsts/work/1/s/output/RequiredModules/Sampler/0.112.3/tasks/JaCoCo.coverage.build.ps1:157 char:13[0m
2022-04-18T13:42:40.5911069Z [91m+ throw "Found $($codecovFiles.Count) code coverage file. N …[0m
2022-04-18T13:42:40.5912113Z [91m+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
2022-04-18T13:42:40.5913316Z [90mAt /home/vsts/work/1/s/output/RequiredModules/Sampler/0.112.3/tasks/JaCoCo.coverage.build.ps1:57 char:1[0m
2022-04-18T13:42:40.5914450Z [90m+ task Merge_CodeCoverage_Files {[0m
2022-04-18T13:42:40.5915366Z [90m+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
2022-04-18T13:42:40.6292665Z [91mBuild FAILED. 2 tasks, 1 errors, 0 warnings 00:00:02.9573804[0m
2022-04-18T13:42:40.7314301Z [91mException: [0m/home/vsts/work/1/s/output/RequiredModules/Sampler/0.112.3/tasks/JaCoCo.coverage.build.ps1:157
2022-04-18T13:42:40.7318541Z [96mLine |
2022-04-18T13:42:40.7321789Z [96m 157 | [0m [96mthrow "Found $($codecovFiles.Count) code coverage file. N[0m …
2022-04-18T13:42:40.7324948Z [96m | [91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-04-18T13:42:40.7328474Z [91m[96m | [91mFound 1 code coverage file. Need at least two files to merge.
2022-04-18T13:42:40.7331745Z [0m
2022-04-18T13:42:40.8717339Z ##[error]PowerShell exited with code '1'.
2022-04-18T13:42:40.8787799Z ##[section]Finishing: Merge Code Coverage files
```
### How to reproduce
Use the path as the template suggest, and the file will be overwritten if there are more than 2 test jobs.
### Expected behavior
Should not overwrite files when downloading artifacts.
### Current behavior
Will overwrite the filename for each downloaded artifact.
### Suggested solution
This:
https://github.com/gaelcolas/Sampler/blob/d19ef072498ac9df81a3839b0b7a502a066f2235/Sampler/Templates/Sampler/azure-pipelines_dsccommunity.yml.template#L227
Must be suffixed with a uniqe folder :
```
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)/CodeCoverageLinux'
```
### Operating system the target node is running
```text
n/a
```
### PowerShell version and build the target node is running
```text
n/a
```
### Module version used
```text
n/a
```
Contributor guide
Research direction
Start at Sampler/Templates/Sampler/azure-pipelines_dsccommunity.yml.template around line 227 and inspect the artifact download targetPath. Update the destination so downloads from separate test jobs do not overwrite identical coverage filenames, then verify the pipeline preserves each artifact and allows the merge step to find them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- ci-cd
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100