@@ -16,32 +16,43 @@ function Write-LogPassThru
16
16
Add-Content - Path $Path - Value $Message - PassThru - Force
17
17
}
18
18
19
- function Write-BashInvokerScript
19
+ function Push-CodeCovData
20
20
{
21
- param ($path )
22
-
23
- $scriptContent =
24
- @'
25
- @echo off
26
- setlocal
27
-
28
- if not exist "%~dpn0.sh" echo Script "%~dpn0.sh" not found & exit 2
29
-
30
- set _CYGBIN=C:\cygwin64\bin
31
- if not exist "%_CYGBIN%" echo Couldn't find Cygwin at "%_CYGBIN%" & exit 3
21
+ param (
22
+ [Parameter (Mandatory = $true )]$file ,
23
+ [Parameter (Mandatory = $true )]$CommitID ,
24
+ [Parameter (Mandatory = $false )]$token ,
25
+ [Parameter (Mandatory = $false )]$Branch = " master"
26
+ )
27
+ $VERSION = " 64c1150"
28
+ $url = " https://codecov.io"
32
29
33
- :: Resolve ___.sh to /cygdrive based *nix path and store in %_CYGSCRIPT%
34
- for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%~dpn0.sh"') do set _CYGSCRIPT=%%A
30
+ $query = " package=bash-${VERSION} &token=${token} &branch=${Branch} &commit=${CommitID} &build=&build_url=&tag=&slug=&yaml=&service=&flags=&pr=&job="
35
31
36
- :: Throw away temporary env vars and invoke script, passing any args that were passed to us
37
- endlocal & %_CYGBIN%\bash --login "%_CYGSCRIPT%" %*
38
- '@
32
+ $CodeCovHeader = @ { Accept = " text/plain" }
33
+ $uri = " $url /upload/v4?${query} "
34
+ $response = Invoke-WebRequest - Method POST - Uri $uri - Headers $CodeCovHeader
35
+ if ( $response.StatusCode -ne 200 )
36
+ {
37
+ Write-LogPassThru - Message " Could not get upload url for request $uri "
38
+ throw " Could not get upload url"
39
+ }
40
+ $uploaduri = $response.content.split (" `n " )[-1 ]
39
41
40
- $scriptContent | Out-File $path - Force - Encoding ascii
42
+ $UploadHeader = @ { " Content-Type" = " text/plain" ; " x-amz-acl" = " public-read" ; " x-amz-storage-class" = " REDUCED_REDUNDANCY" }
43
+ $response = Invoke-WebRequest - Method Put - Uri $uploaduri - InFile $file - Headers $UploadHeader
44
+ if ( $response.StatusCode -ne 200 )
45
+ {
46
+ Write-LogPassThru - Message " Upload failed for upload uri: $uploaduri "
47
+ throw " upload failed"
48
+ }
41
49
}
42
50
43
51
Write-LogPassThru - Message " ***** New Run *****"
44
52
53
+ Write-LogPassThru - Message " Forcing winrm quickconfig as it is required for remoting tests."
54
+ winrm quickconfig - force
55
+
45
56
$codeCoverageZip = ' https://ci.appveyor.com/api/projects/PowerShell/powershell-f975h/artifacts/CodeCoverage.zip'
46
57
$testContentZip = ' https://ci.appveyor.com/api/projects/PowerShell/powershell-f975h/artifacts/tests.zip'
47
58
$openCoverZip = ' https://ci.appveyor.com/api/projects/PowerShell/powershell-f975h/artifacts/OpenCover.zip'
@@ -150,64 +161,30 @@ try
150
161
Write-LogPassThru - Message " Uploading to CoverAlls"
151
162
& $coverallsExe " "" $coverallsParams "" "
152
163
153
- $bashScriptInvoker = " $PSScriptRoot \CodecovUploader.cmd"
154
- $bashScript = " $PSScriptRoot \CodecovUploader.sh"
155
- $cygwinLocation = " $env: SystemDrive \cygwin*"
156
-
157
- if ($bashScript )
158
- {
159
- Remove-Item $bashScript - Force - ErrorAction SilentlyContinue
160
- }
161
-
162
- Invoke-RestMethod ' https://codecov.io/bash' - OutFile $bashScript
163
- Write-BashInvokerScript - path $bashScriptInvoker
164
-
165
- if ((Test-Path $bashScriptInvoker ) -and
166
- (Test-Path $bashScript ) -and
167
- (Test-Path $cygwinLocation )
168
- )
169
- {
170
- Write-LogPassThru - Message " Uploading to CodeCov"
171
- $cygwinPath = " /cygdrive/" + $outputLog.Replace (" \" , " /" ).Replace(" :" , " " )
172
-
173
- $codecovParmeters = @ (
174
- " -f $cygwinPath "
175
- " -X gcov" ,
176
- " -B master" ,
177
- " -C $commitId " ,
178
- " -X network" )
179
-
180
- $codecovParmetersString = $codecovParmeters -join ' '
181
-
182
- & $bashScriptInvoker $codecovParmetersString
183
- }
184
- else
185
- {
186
- Write-LogPassThru - Message " BashScript: $bashScript "
187
- Write-LogPassThru - Message " BashScriptInvoke: $bashScriptInvoker "
188
- Write-LogPassThru - Message " CygwinPath : $cygwinPath "
189
- Write-LogPassThru - Message " Cannot upload to codecov as some paths are not existent"
190
- }
164
+ Write-LogPassThru - Message " Uploading to CodeCov"
165
+ Push-CodeCovData - file $outputLog - CommitID $commitId - token $codecovToken - Branch ' master'
191
166
192
167
Write-LogPassThru - Message " Upload complete."
193
168
}
194
169
catch
195
170
{
196
- $_
171
+ Write-LogPassThru - Message $_
197
172
}
198
173
finally
199
174
{
200
175
# # See if Azure log directory is mounted
201
176
if (Test-Path $azureLogDrive )
202
177
{
203
178
# #Create yyyy-dd folder
204
- $monthFolder = " {0:yyyy-mm }" -f [datetime ]::Now
179
+ $monthFolder = " {0:yyyy-MM }" -f [datetime ]::Now
205
180
$monthFolderFullPath = New-Item - Path (Join-Path $azureLogDrive $monthFolder ) - ItemType Directory - Force
206
181
$windowsFolderPath = New-Item (Join-Path $monthFolderFullPath " Windows" ) - ItemType Directory - Force
207
182
208
183
$destinationPath = Join-Path $env: Temp (" CodeCoverageLogs-{0:yyyy_MM_dd}-{0:hh_mm_ss}.zip" -f [datetime ]::Now)
209
184
Compress-Archive - Path $elevatedLogs , $unelevatedLogs , $outputLog - DestinationPath $destinationPath
210
185
Copy-Item $destinationPath $windowsFolderPath - Force - ErrorAction SilentlyContinue
186
+
187
+ Remove-Item - Path $destinationPath - Force - ErrorAction SilentlyContinue
211
188
}
212
189
213
190
# # Disable the cleanup till we stabilize.
0 commit comments