Code coverage automation script#2918
Code coverage automation script#2918lzybkr merged 9 commits intoPowerShell:masterPowerShell/PowerShell:masterfrom adityapatwardhan:CodeCoverageAutomationadityapatwardhan/PowerShell:CodeCoverageAutomationCopy head branch name to clipboard
Conversation
This script downloads the latest nightly build package and executes the tests on it. It also downloads all necessary tools and then uploads the results to Coveralls.io. The badge for coverage is posted on README.md
| $openCoverZip = 'https://ci.appveyor.com/api/projects/PowerShell/powershell-f975h/artifacts/OpenCover.zip' | ||
|
|
||
|
|
||
| New-Item "$PSScriptRoot\logs.txt" -Force |
There was a problem hiding this comment.
You might consider putting the log in some more typical output directory, or at least adding the file you create to .gitignore.
|
|
||
| try | ||
| { | ||
| "Starting downloads." | Tee-Object -FilePath "$PSScriptRoot\logs.txt" -Append |
There was a problem hiding this comment.
Maybe you should add a log helper function.
|
|
||
| "Test run done.!!" | Tee-Object -FilePath "$PSScriptRoot\logs.txt" -Append | ||
|
|
||
| $powershellVersionString = (Get-Content "$psBinPath\publish\powershell.version") |
There was a problem hiding this comment.
I expect this file to go away at some point - it would be better to get the string from PowerShell itself, e.g.
$powershellVersionString = & $psBinPath\publish\powershell.exe -noprofile -command '$PSVersionTable.GitCommitId'Addressed CR comments about log file location, logging function and usage of powershell.version file. Also added a README.md file explaining the process.
|
@lzybkr Addressed CR comments |
Fix the bug in invoking $PSversionTable. Added -force to expand-archive cmdlets.
| $Path = "$env:Temp\CodeCoverageRunLogs.txt" | ||
| ) | ||
|
|
||
| $message = "$([Datetime]::Now.ToShortDateString()) - $([datetime]::Now.ToShortTimeString()) : $message" |
There was a problem hiding this comment.
$message = "$ ([Datetime]::Now.ToShortDateString()) - $([datetime]::Now.ToShortTimeString()) : $message" [](start = 4, length = 103)
this can also be done as:
"{0:d} - {0:t} : {1}" -f ([datetime]::now),$message
or even:
"{0} : {1}" -f ([datetime]::now),$message
although this last changes the string a bit #Resolved
There was a problem hiding this comment.
| else | ||
| { | ||
| Add-Content -Path $Path -Value $Message -PassThru | ||
| } |
There was a problem hiding this comment.
would just add-content -force do the trick (add-content will create the file if it doesn't exist) #Resolved
There was a problem hiding this comment.
|
|
||
| Invoke-WebRequest -uri $codeCoverageZip -outfile "$outputBaseFolder\PSCodeCoverage.zip" | ||
| Invoke-WebRequest $testContentZip -outfile "$outputBaseFolder\tests.zip" | ||
| Invoke-WebRequest $openCoverZip -outfile "$outputBaseFolder\OpenCover.zip" |
There was a problem hiding this comment.
for consistency - add -uri to these lines too? #Resolved
There was a problem hiding this comment.
| Write-LogPassThru -Message "openCoverZip: $openCoverZip" | ||
|
|
||
| $outputBaseFolder = "$env:Temp\CC" | ||
| $null = New-Item -ItemType Directory -Path $outputBaseFolder -Force |
There was a problem hiding this comment.
this path may already exist with contents. Would it be a good thing to delete the directory (recursively) if it exists before starting?
ah - i see, it's removed as part of finally, perhaps it's not needed #WontFix
| $coverallsPath = "$outputBaseFolder\coveralls" | ||
|
|
||
| ## Saving the nupkg as zip so we can expand it. | ||
| Invoke-WebRequest $coverallsToolsUrl -outfile "$outputBaseFolder\coveralls.zip" |
There was a problem hiding this comment.
$coverallsToolsUrl [](start = 22, length = 18)
-uri? #Resolved
There was a problem hiding this comment.
| Write-LogPassThru -Message $commitId | ||
|
|
||
| $coverallsPath = "$outputBaseFolder\coveralls" | ||
| $coverallsToken = 'SaRLabTUDNqaO2JT9uuYcR78a7kia044D' |
There was a problem hiding this comment.
secrets should probably be provided rather than embedded #Resolved
There was a problem hiding this comment.
|
|
||
| Write-LogPassThru -Message "Upload complete." | ||
| } | ||
| catch |
There was a problem hiding this comment.
I wonder if ErrorActionPreference should be set to STOP #Resolved
There was a problem hiding this comment.
|
|
|
@lzybkr Merge conflict is solved. Change is ready to merge. |
|
@lzybkr All checks have passed. Is it ok to merge? |
This script downloads the latest nightly build package and executes the tests on it. It also downloads all necessary tools and then uploads the results to Coveralls.io. The badge for coverage is posted on README.md
This script downloads the latest nightly build package and executes the
tests on it. It also downloads all necessary tools and then uploads the
results to Coveralls.io. The badge for coverage is posted on README.md