Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Code coverage automation script#2918

Merged
lzybkr merged 9 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
adityapatwardhan:CodeCoverageAutomationadityapatwardhan/PowerShell:CodeCoverageAutomationCopy head branch name to clipboard
Jan 5, 2017
Merged

Code coverage automation script#2918
lzybkr merged 9 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
adityapatwardhan:CodeCoverageAutomationadityapatwardhan/PowerShell:CodeCoverageAutomationCopy head branch name to clipboard

Conversation

@adityapatwardhan

Copy link
Copy Markdown
Member

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
$openCoverZip = 'https://ci.appveyor.com/api/projects/PowerShell/powershell-f975h/artifacts/OpenCover.zip'


New-Item "$PSScriptRoot\logs.txt" -Force

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@adityapatwardhan

Copy link
Copy Markdown
Member Author

@lzybkr Addressed CR comments

@PowerShellTeam PowerShellTeam added the Review - Needed The PR is being reviewed label Dec 22, 2016
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"

@JamesWTruher JamesWTruher Jan 3, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


In reply to: 94473993 [](ancestors = 94473993)

else
{
Add-Content -Path $Path -Value $Message -PassThru
}

@JamesWTruher JamesWTruher Jan 3, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would just add-content -force do the trick (add-content will create the file if it doesn't exist) #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


In reply to: 94474364 [](ancestors = 94474364)


Invoke-WebRequest -uri $codeCoverageZip -outfile "$outputBaseFolder\PSCodeCoverage.zip"
Invoke-WebRequest $testContentZip -outfile "$outputBaseFolder\tests.zip"
Invoke-WebRequest $openCoverZip -outfile "$outputBaseFolder\OpenCover.zip"

@JamesWTruher JamesWTruher Jan 3, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency - add -uri to these lines too? #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


In reply to: 94474590 [](ancestors = 94474590)

Write-LogPassThru -Message "openCoverZip: $openCoverZip"

$outputBaseFolder = "$env:Temp\CC"
$null = New-Item -ItemType Directory -Path $outputBaseFolder -Force

@JamesWTruher JamesWTruher Jan 3, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

@JamesWTruher JamesWTruher Jan 3, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$coverallsToolsUrl [](start = 22, length = 18)

-uri? #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


In reply to: 94474891 [](ancestors = 94474891)

Write-LogPassThru -Message $commitId

$coverallsPath = "$outputBaseFolder\coveralls"
$coverallsToken = 'SaRLabTUDNqaO2JT9uuYcR78a7kia044D'

@JamesWTruher JamesWTruher Jan 3, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secrets should probably be provided rather than embedded #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


In reply to: 94475097 [](ancestors = 94475097)


Write-LogPassThru -Message "Upload complete."
}
catch

@JamesWTruher JamesWTruher Jan 3, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if ErrorActionPreference should be set to STOP #Resolved

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


In reply to: 94475385 [](ancestors = 94475385)

@JamesWTruher

Copy link
Copy Markdown
Collaborator

:shipit:

@adityapatwardhan

Copy link
Copy Markdown
Member Author

@lzybkr Merge conflict is solved. Change is ready to merge.

@adityapatwardhan

Copy link
Copy Markdown
Member Author

@lzybkr All checks have passed. Is it ok to merge?

@lzybkr lzybkr merged commit 1264eed into PowerShell:master Jan 5, 2017
@adityapatwardhan adityapatwardhan deleted the CodeCoverageAutomation branch January 6, 2017 01:03
rjmholt pushed a commit to rjmholt/PowerShell that referenced this pull request Jan 9, 2017
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.