gaelcolas / gaelcolas/Sampler

Merging code coverage, download artifacts to individual destination folders

Open
#360 0 comments 0 reactions 0 assignees View on GitHub
bug good first issue help wanted
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  MERGE CODECOVERAGE FILES
2022-04-18T13:42:40.3879113Z Merging several code coverage files together.
2022-04-18T13:42:40.3886134Z -------------------------------------------------------------------------------
2022-04-18T13:42:40.3894370Z  /merge/Merge_CodeCoverage_Files
2022-04-18T13:42:40.3903321Z  /home/vsts/work/1/s/output/RequiredModules/Sampler/0.112.3/tasks/JaCoCo.coverage.build.ps1:57
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 Processing folder: /home/vsts/work/1/s/output
2022-04-18T13:42:40.5906605Z ERROR: Found 1 code coverage file. Need at least two files to merge.
2022-04-18T13:42:40.5908089Z At /home/vsts/work/1/s/output/RequiredModules/Sampler/0.112.3/tasks/JaCoCo.coverage.build.ps1:157 char:13
2022-04-18T13:42:40.5911069Z + throw "Found $($codecovFiles.Count) code coverage file. N …
2022-04-18T13:42:40.5912113Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-04-18T13:42:40.5913316Z At /home/vsts/work/1/s/output/RequiredModules/Sampler/0.112.3/tasks/JaCoCo.coverage.build.ps1:57 char:1
2022-04-18T13:42:40.5914450Z + task Merge_CodeCoverage_Files {
2022-04-18T13:42:40.5915366Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-04-18T13:42:40.6292665Z Build FAILED. 2 tasks, 1 errors, 0 warnings 00:00:02.9573804
2022-04-18T13:42:40.7314301Z Exception: /home/vsts/work/1/s/output/RequiredModules/Sampler/0.112.3/tasks/JaCoCo.coverage.build.ps1:157
2022-04-18T13:42:40.7318541Z Line |
2022-04-18T13:42:40.7321789Z  157 |  throw "Found $($codecovFiles.Count) code coverage file. N …
2022-04-18T13:42:40.7324948Z  |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-04-18T13:42:40.7328474Z  | Found 1 code coverage file. Need at least two files to merge.
2022-04-18T13:42:40.7331745Z 
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.