mirror of
https://github.com/actions/runner.git
synced 2025-12-12 15:13:30 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1413297394 | ||
|
|
6a063ae7be | ||
|
|
76bb4961fb | ||
|
|
bf3d32e631 | ||
|
|
11aa006d30 | ||
|
|
586c8a7fa5 |
32
.github/workflows/build.yml
vendored
32
.github/workflows/build.yml
vendored
@@ -13,33 +13,14 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
runtime: [ linux-x64, linux-arm64, linux-arm, win-x64, osx-x64 ]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
# runtime: [ linux-x64, linux-arm64, linux-arm, win-x64, win-x86, osx-x64 ]
|
|
||||||
include:
|
include:
|
||||||
- runtime: linux-x64
|
- os: ubuntu-latest
|
||||||
os: ubuntu-latest
|
|
||||||
devScript: ./dev.sh
|
devScript: ./dev.sh
|
||||||
|
- os: macOS-latest
|
||||||
- runtime: linux-arm64
|
|
||||||
os: ubuntu-latest
|
|
||||||
devScript: ./dev.sh
|
devScript: ./dev.sh
|
||||||
|
- os: windows-latest
|
||||||
- runtime: linux-arm
|
|
||||||
os: ubuntu-latest
|
|
||||||
devScript: ./dev.sh
|
|
||||||
|
|
||||||
- runtime: osx-x64
|
|
||||||
os: macOS-latest
|
|
||||||
devScript: ./dev.sh
|
|
||||||
|
|
||||||
- runtime: win-x64
|
|
||||||
os: windows-latest
|
|
||||||
devScript: ./dev
|
devScript: ./dev
|
||||||
|
|
||||||
# - runtime: win-x86
|
|
||||||
# os: windows-latest
|
|
||||||
# devScript: ./dev
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
@@ -47,7 +28,7 @@ jobs:
|
|||||||
# Build runner layout
|
# Build runner layout
|
||||||
- name: Build & Layout Release
|
- name: Build & Layout Release
|
||||||
run: |
|
run: |
|
||||||
${{ matrix.devScript }} layout Release ${{ matrix.runtime }}
|
${{ matrix.devScript }} layout Release
|
||||||
working-directory: src
|
working-directory: src
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
@@ -55,7 +36,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
${{ matrix.devScript }} test
|
${{ matrix.devScript }} test
|
||||||
working-directory: src
|
working-directory: src
|
||||||
if: matrix.runtime != 'linux-arm64' && matrix.runtime != 'linux-arm'
|
|
||||||
|
|
||||||
# Create runner package tar.gz/zip
|
# Create runner package tar.gz/zip
|
||||||
- name: Package Release
|
- name: Package Release
|
||||||
@@ -69,5 +49,5 @@ jobs:
|
|||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: runner-package-${{ matrix.runtime }}
|
name: runner-package-${{ matrix.os }}
|
||||||
path: _package
|
path: _package
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@
|
|||||||
**/libs
|
**/libs
|
||||||
**/*.xproj
|
**/*.xproj
|
||||||
**/*.xproj.user
|
**/*.xproj.user
|
||||||
|
**/*.sln
|
||||||
**/.vs
|
**/.vs
|
||||||
**/.vscode
|
**/.vscode
|
||||||
**/*.error
|
**/*.error
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 16
|
|
||||||
VisualStudioVersion = 16.0.29411.138
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Runner.Common", "src\Runner.Common\Runner.Common.csproj", "{084289A3-CD7A-42E0-9219-4348B4B7E19B}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Runner.Listener", "src\Runner.Listener\Runner.Listener.csproj", "{7D461AEE-BF2A-4855-BD96-56921160B36A}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Runner.PluginHost", "src\Runner.PluginHost\Runner.PluginHost.csproj", "{D0320EB1-CB6D-4179-BFDC-2F2B664A370C}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Runner.Plugins", "src\Runner.Plugins\Runner.Plugins.csproj", "{C23AFD6F-4DCD-4243-BC61-865BE31B9168}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Runner.Sdk", "src\Runner.Sdk\Runner.Sdk.csproj", "{D0484633-DA97-4C34-8E47-1DADE212A57A}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunnerService", "src\Runner.Service\Windows\RunnerService.csproj", "{D12EBD71-0464-46D0-8394-40BCFBA0A6F2}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Runner.Worker", "src\Runner.Worker\Runner.Worker.csproj", "{C2F5B9FA-2621-411F-8EB2-273ED276F503}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sdk", "src\Sdk\Sdk.csproj", "{D2EE812B-E4DF-49BB-AE87-12BC49949B5F}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "src\Test\Test.csproj", "{C932061F-F6A1-4F1E-B854-A6C6B30DC3EF}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{084289A3-CD7A-42E0-9219-4348B4B7E19B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{084289A3-CD7A-42E0-9219-4348B4B7E19B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{084289A3-CD7A-42E0-9219-4348B4B7E19B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{084289A3-CD7A-42E0-9219-4348B4B7E19B}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{7D461AEE-BF2A-4855-BD96-56921160B36A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{7D461AEE-BF2A-4855-BD96-56921160B36A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{7D461AEE-BF2A-4855-BD96-56921160B36A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{7D461AEE-BF2A-4855-BD96-56921160B36A}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{D0320EB1-CB6D-4179-BFDC-2F2B664A370C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{D0320EB1-CB6D-4179-BFDC-2F2B664A370C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{D0320EB1-CB6D-4179-BFDC-2F2B664A370C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{D0320EB1-CB6D-4179-BFDC-2F2B664A370C}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{C23AFD6F-4DCD-4243-BC61-865BE31B9168}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C23AFD6F-4DCD-4243-BC61-865BE31B9168}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C23AFD6F-4DCD-4243-BC61-865BE31B9168}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C23AFD6F-4DCD-4243-BC61-865BE31B9168}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{D0484633-DA97-4C34-8E47-1DADE212A57A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{D0484633-DA97-4C34-8E47-1DADE212A57A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{D0484633-DA97-4C34-8E47-1DADE212A57A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{D0484633-DA97-4C34-8E47-1DADE212A57A}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{D12EBD71-0464-46D0-8394-40BCFBA0A6F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{D12EBD71-0464-46D0-8394-40BCFBA0A6F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{D12EBD71-0464-46D0-8394-40BCFBA0A6F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{D12EBD71-0464-46D0-8394-40BCFBA0A6F2}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{C2F5B9FA-2621-411F-8EB2-273ED276F503}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C2F5B9FA-2621-411F-8EB2-273ED276F503}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C2F5B9FA-2621-411F-8EB2-273ED276F503}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C2F5B9FA-2621-411F-8EB2-273ED276F503}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{D2EE812B-E4DF-49BB-AE87-12BC49949B5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{D2EE812B-E4DF-49BB-AE87-12BC49949B5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{D2EE812B-E4DF-49BB-AE87-12BC49949B5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{D2EE812B-E4DF-49BB-AE87-12BC49949B5F}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{C932061F-F6A1-4F1E-B854-A6C6B30DC3EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C932061F-F6A1-4F1E-B854-A6C6B30DC3EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C932061F-F6A1-4F1E-B854-A6C6B30DC3EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C932061F-F6A1-4F1E-B854-A6C6B30DC3EF}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {4A831DDA-3860-45E5-930E-BB3A7833AE80}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
12
assets.json
12
assets.json
@@ -16,17 +16,5 @@
|
|||||||
"platform": "linux-x64",
|
"platform": "linux-x64",
|
||||||
"version": "<RUNNER_VERSION>",
|
"version": "<RUNNER_VERSION>",
|
||||||
"downloadUrl": "https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-linux-x64-<RUNNER_VERSION>.tar.gz"
|
"downloadUrl": "https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-linux-x64-<RUNNER_VERSION>.tar.gz"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "actions-runner-linux-arm64-<RUNNER_VERSION>.tar.gz",
|
|
||||||
"platform": "linux-arm64",
|
|
||||||
"version": "<RUNNER_VERSION>",
|
|
||||||
"downloadUrl": "https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-linux-arm64-<RUNNER_VERSION>.tar.gz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "actions-runner-linux-arm-<RUNNER_VERSION>.tar.gz",
|
|
||||||
"platform": "linux-arm",
|
|
||||||
"version": "<RUNNER_VERSION>",
|
|
||||||
"downloadUrl": "https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-linux-arm-<RUNNER_VERSION>.tar.gz"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -11,8 +11,6 @@ stages:
|
|||||||
|
|
||||||
# Steps template for windows platform
|
# Steps template for windows platform
|
||||||
- template: windows.template.yml
|
- template: windows.template.yml
|
||||||
parameters:
|
|
||||||
targetRuntime: win-x64
|
|
||||||
|
|
||||||
# Package dotnet core windows dependency (VC++ Redistributable)
|
# Package dotnet core windows dependency (VC++ Redistributable)
|
||||||
- powershell: |
|
- powershell: |
|
||||||
@@ -30,7 +28,7 @@ stages:
|
|||||||
displayName: Package UCRT
|
displayName: Package UCRT
|
||||||
|
|
||||||
# Create agent package zip
|
# Create agent package zip
|
||||||
- script: dev.cmd package Release win-x64
|
- script: dev.cmd package Release
|
||||||
workingDirectory: src
|
workingDirectory: src
|
||||||
displayName: Package Release
|
displayName: Package Release
|
||||||
|
|
||||||
@@ -42,47 +40,6 @@ stages:
|
|||||||
artifactName: runners
|
artifactName: runners
|
||||||
artifactType: container
|
artifactType: container
|
||||||
|
|
||||||
# ################################################################################
|
|
||||||
# - job: build_windows_agent_x86
|
|
||||||
# ################################################################################
|
|
||||||
# displayName: Windows Agent (x86)
|
|
||||||
# pool:
|
|
||||||
# vmImage: vs2017-win2016
|
|
||||||
# steps:
|
|
||||||
|
|
||||||
# # Steps template for windows platform
|
|
||||||
# - template: windows.template.yml
|
|
||||||
# parameters:
|
|
||||||
# targetRuntime: win-x86
|
|
||||||
|
|
||||||
# # Package dotnet core windows dependency (VC++ Redistributable)
|
|
||||||
# - powershell: |
|
|
||||||
# Write-Host "Downloading 'VC++ Redistributable' package."
|
|
||||||
# $outDir = Join-Path -Path $env:TMP -ChildPath ([Guid]::NewGuid())
|
|
||||||
# New-Item -Path $outDir -ItemType directory
|
|
||||||
# $outFile = Join-Path -Path $outDir -ChildPath "ucrt.zip"
|
|
||||||
# Invoke-WebRequest -Uri https://vstsagenttools.blob.core.windows.net/tools/ucrt/ucrt_x86.zip -OutFile $outFile
|
|
||||||
# Write-Host "Unzipping 'VC++ Redistributable' package to agent layout."
|
|
||||||
# $unzipDir = Join-Path -Path $outDir -ChildPath "unzip"
|
|
||||||
# Add-Type -AssemblyName System.IO.Compression.FileSystem
|
|
||||||
# [System.IO.Compression.ZipFile]::ExtractToDirectory($outFile, $unzipDir)
|
|
||||||
# $agentLayoutBin = Join-Path -Path $(Build.SourcesDirectory) -ChildPath "_layout\bin"
|
|
||||||
# Copy-Item -Path $unzipDir -Destination $agentLayoutBin -Force
|
|
||||||
# displayName: Package UCRT
|
|
||||||
|
|
||||||
# # Create agent package zip
|
|
||||||
# - script: dev.cmd package Release win-x86
|
|
||||||
# workingDirectory: src
|
|
||||||
# displayName: Package Release
|
|
||||||
|
|
||||||
# # Upload agent package zip as build artifact
|
|
||||||
# - task: PublishBuildArtifacts@1
|
|
||||||
# displayName: Publish Artifact (Windows)
|
|
||||||
# inputs:
|
|
||||||
# pathToPublish: _package
|
|
||||||
# artifactName: runners
|
|
||||||
# artifactType: container
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
- job: build_linux_agent_x64
|
- job: build_linux_agent_x64
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -93,11 +50,9 @@ stages:
|
|||||||
|
|
||||||
# Steps template for non-windows platform
|
# Steps template for non-windows platform
|
||||||
- template: nonwindows.template.yml
|
- template: nonwindows.template.yml
|
||||||
parameters:
|
|
||||||
targetRuntime: linux-x64
|
|
||||||
|
|
||||||
# Create agent package zip
|
# Create agent package zip
|
||||||
- script: ./dev.sh package Release linux-x64
|
- script: ./dev.sh package Release
|
||||||
workingDirectory: src
|
workingDirectory: src
|
||||||
displayName: Package Release
|
displayName: Package Release
|
||||||
|
|
||||||
@@ -110,59 +65,7 @@ stages:
|
|||||||
artifactType: container
|
artifactType: container
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
- job: build_linux_agent_arm64
|
- job: build_osx_agent
|
||||||
################################################################################
|
|
||||||
displayName: Linux Agent (arm64)
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-16.04
|
|
||||||
steps:
|
|
||||||
|
|
||||||
# Steps template for non-windows platform
|
|
||||||
- template: nonwindows.template.yml
|
|
||||||
parameters:
|
|
||||||
targetRuntime: linux-arm64
|
|
||||||
|
|
||||||
# Create agent package zip
|
|
||||||
- script: ./dev.sh package Release linux-arm64
|
|
||||||
workingDirectory: src
|
|
||||||
displayName: Package Release
|
|
||||||
|
|
||||||
# Upload agent package zip as build artifact
|
|
||||||
- task: PublishBuildArtifacts@1
|
|
||||||
displayName: Publish Artifact (Linux)
|
|
||||||
inputs:
|
|
||||||
pathToPublish: _package
|
|
||||||
artifactName: runners
|
|
||||||
artifactType: container
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
- job: build_linux_agent_arm
|
|
||||||
################################################################################
|
|
||||||
displayName: Linux Agent (arm)
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-16.04
|
|
||||||
steps:
|
|
||||||
|
|
||||||
# Steps template for non-windows platform
|
|
||||||
- template: nonwindows.template.yml
|
|
||||||
parameters:
|
|
||||||
targetRuntime: linux-arm
|
|
||||||
|
|
||||||
# Create agent package zip
|
|
||||||
- script: ./dev.sh package Release linux-arm
|
|
||||||
workingDirectory: src
|
|
||||||
displayName: Package Release
|
|
||||||
|
|
||||||
# Upload agent package zip as build artifact
|
|
||||||
- task: PublishBuildArtifacts@1
|
|
||||||
displayName: Publish Artifact (Linux)
|
|
||||||
inputs:
|
|
||||||
pathToPublish: _package
|
|
||||||
artifactName: runners
|
|
||||||
artifactType: container
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
- job: build_osx_agent_x64
|
|
||||||
################################################################################
|
################################################################################
|
||||||
displayName: macOS Agent (x64)
|
displayName: macOS Agent (x64)
|
||||||
pool:
|
pool:
|
||||||
@@ -171,11 +74,9 @@ stages:
|
|||||||
|
|
||||||
# Steps template for non-windows platform
|
# Steps template for non-windows platform
|
||||||
- template: nonwindows.template.yml
|
- template: nonwindows.template.yml
|
||||||
parameters:
|
|
||||||
targetRuntime: osx-x64
|
|
||||||
|
|
||||||
# Create agent package zip
|
# Create agent package zip
|
||||||
- script: ./dev.sh package Release osx-x64
|
- script: ./dev.sh package Release
|
||||||
workingDirectory: src
|
workingDirectory: src
|
||||||
displayName: Package Release
|
displayName: Package Release
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# Contribution guide for developers
|
# Contribute (Dev)
|
||||||
|
|
||||||
## Required Dev Dependencies
|
## Dev Dependencies
|
||||||
|
|
||||||
 Git for Windows [Install Here](https://git-scm.com/downloads) (needed for dev sh script)
|
 Git for Windows [Install Here](https://git-scm.com/downloads) (needed for dev sh script)
|
||||||
|
|
||||||
## To Build, Test, Layout
|
## Build, Test, Layout
|
||||||
|
|
||||||
Navigate to the `src` directory and run the following command:
|
From src:
|
||||||
|
|
||||||
 `dev {command}`
|
 `dev {command}`
|
||||||
|
|
||||||
@@ -14,12 +14,13 @@ Navigate to the `src` directory and run the following command:
|
|||||||
|
|
||||||
**Commands:**
|
**Commands:**
|
||||||
|
|
||||||
* `layout` (`l`): Run first time to create a full agent layout in `{root}/_layout`
|
`layout` (`l`): Run first time to create a full agent layout in {root}/_layout
|
||||||
* `build` (`b`): Build everything and update agent layout folder
|
|
||||||
* `test` (`t`): Build agent binaries and run unit tests
|
|
||||||
|
|
||||||
Sample developer flow:
|
`build` (`b`): build everything and update agent layout folder
|
||||||
|
|
||||||
|
`test` (`t`): build agent binaries and run unit tests
|
||||||
|
|
||||||
|
Normal dev flow:
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/actions/runner
|
git clone https://github.com/actions/runner
|
||||||
cd ./src
|
cd ./src
|
||||||
@@ -36,5 +37,5 @@ cd ./src
|
|||||||
|
|
||||||
## Styling
|
## Styling
|
||||||
|
|
||||||
We use the .NET Foundation and CoreCLR style guidelines [located here](
|
We use the dotnet foundation and CoreCLR style guidelines [located here](
|
||||||
https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md)
|
https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
## Supported Versions
|
## Supported Versions
|
||||||
|
|
||||||
- macOS High Sierra (10.13) and later versions
|
- macOS Sierra (10.12) and later versions
|
||||||
|
|
||||||
|
|
||||||
## [More .Net Core Prerequisites Information](https://docs.microsoft.com/en-us/dotnet/core/macos-prerequisites?tabs=netcore30)
|
## [More .Net Core Prerequisites Information](https://docs.microsoft.com/en-us/dotnet/core/macos-prerequisites?tabs=netcore2x)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
- Windows 7 64-bit
|
- Windows 7 64-bit
|
||||||
- Windows 8.1 64-bit
|
- Windows 8.1 64-bit
|
||||||
- Windows 10 64-bit
|
- Windows 10 64-bit
|
||||||
|
- Windows Server 2008 R2 SP1 64-bit
|
||||||
- Windows Server 2012 R2 64-bit
|
- Windows Server 2012 R2 64-bit
|
||||||
- Windows Server 2016 64-bit
|
- Windows Server 2016 64-bit
|
||||||
- Windows Server 2019 64-bit
|
|
||||||
|
|
||||||
## [More .Net Core Prerequisites Information](https://docs.microsoft.com/en-us/dotnet/core/windows-prerequisites?tabs=netcore30)
|
## [More .Net Core Prerequisites Information](https://docs.microsoft.com/en-us/dotnet/core/windows-prerequisites?tabs=netcore2x)
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
parameters:
|
|
||||||
targetRuntime: ''
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
# Build agent layout
|
# Build agent layout
|
||||||
- script: ./dev.sh layout Release ${{ parameters.targetRuntime }}
|
- script: ./dev.sh layout Release
|
||||||
workingDirectory: src
|
workingDirectory: src
|
||||||
displayName: Build & Layout Release ${{ parameters.targetRuntime }}
|
displayName: Build & Layout Release
|
||||||
|
|
||||||
# Run test
|
# Run test
|
||||||
- script: ./dev.sh test
|
- script: ./dev.sh test
|
||||||
workingDirectory: src
|
workingDirectory: src
|
||||||
displayName: Test
|
displayName: Test
|
||||||
condition: and(ne('${{ parameters.targetRuntime }}', 'linux-arm64'), ne('${{ parameters.targetRuntime }}', 'linux-arm'))
|
|
||||||
|
|
||||||
# # Publish test results
|
# # Publish test results
|
||||||
# - task: PublishTestResults@2
|
# - task: PublishTestResults@2
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
## Features
|
## Features
|
||||||
- Add packages for Windows x86 (win-x6), Linux ARM32 (linux-arm), Linux ARM64 (linux-arm64)
|
- N/A
|
||||||
|
|
||||||
## Bugs
|
## Bugs
|
||||||
- N/A
|
- Reverted removal of additional fields error and warning fields (#147)
|
||||||
|
- Actions cache would incorrectly cache the action if the tag was updated (#148)
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
- N/A
|
- Updated to .NET Core 3.0 (#127)
|
||||||
|
|
||||||
## Agent Downloads
|
## Agent Downloads
|
||||||
|
|
||||||
@@ -14,8 +15,6 @@
|
|||||||
| Windows x64 | [actions-runner-win-x64-<RUNNER_VERSION>.zip](https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-win-x64-<RUNNER_VERSION>.zip) |
|
| Windows x64 | [actions-runner-win-x64-<RUNNER_VERSION>.zip](https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-win-x64-<RUNNER_VERSION>.zip) |
|
||||||
| macOS | [actions-runner-osx-x64-<RUNNER_VERSION>.tar.gz](https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-osx-x64-<RUNNER_VERSION>.tar.gz) |
|
| macOS | [actions-runner-osx-x64-<RUNNER_VERSION>.tar.gz](https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-osx-x64-<RUNNER_VERSION>.tar.gz) |
|
||||||
| Linux x64 | [actions-runner-linux-x64-<RUNNER_VERSION>.tar.gz](https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-linux-x64-<RUNNER_VERSION>.tar.gz) |
|
| Linux x64 | [actions-runner-linux-x64-<RUNNER_VERSION>.tar.gz](https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-linux-x64-<RUNNER_VERSION>.tar.gz) |
|
||||||
| Linux arm64 | [actions-runner-linux-arm64-<RUNNER_VERSION>.tar.gz](https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-linux-arm64-<RUNNER_VERSION>.tar.gz) |
|
|
||||||
| Linux arm | [actions-runner-linux-arm-<RUNNER_VERSION>.tar.gz](https://githubassets.azureedge.net/runners/<RUNNER_VERSION>/actions-runner-linux-arm-<RUNNER_VERSION>.tar.gz) |
|
|
||||||
|
|
||||||
After Download:
|
After Download:
|
||||||
|
|
||||||
@@ -39,17 +38,3 @@ C:\myagent> Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO
|
|||||||
~/$ mkdir myagent && cd myagent
|
~/$ mkdir myagent && cd myagent
|
||||||
~/myagent$ tar xzf ~/Downloads/actions-runner-linux-x64-<RUNNER_VERSION>.tar.gz
|
~/myagent$ tar xzf ~/Downloads/actions-runner-linux-x64-<RUNNER_VERSION>.tar.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
## Linux arm64
|
|
||||||
|
|
||||||
``` bash
|
|
||||||
~/$ mkdir myagent && cd myagent
|
|
||||||
~/myagent$ tar xzf ~/Downloads/actions-runner-linux-arm64-<RUNNER_VERSION>.tar.gz
|
|
||||||
```
|
|
||||||
|
|
||||||
## Linux arm
|
|
||||||
|
|
||||||
``` bash
|
|
||||||
~/$ mkdir myagent && cd myagent
|
|
||||||
~/myagent$ tar xzf ~/Downloads/actions-runner-linux-arm-<RUNNER_VERSION>.tar.gz
|
|
||||||
```
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<!-- Detect OS for build -->
|
|
||||||
<PropertyGroup>
|
|
||||||
<BUILD_OS Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">Windows</BUILD_OS>
|
|
||||||
<BUILD_OS Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">OSX</BUILD_OS>
|
|
||||||
<BUILD_OS Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">Linux</BUILD_OS>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!-- Set OS vars -->
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'Windows'">
|
|
||||||
<DefineConstants>$(DefineConstants);OS_WINDOWS</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'OSX'">
|
|
||||||
<DefineConstants>$(DefineConstants);OS_OSX</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'Linux'">
|
|
||||||
<DefineConstants>$(DefineConstants);OS_LINUX</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'Linux' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
|
||||||
<DefineConstants>$(DefineConstants);OS_RHEL6</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!-- Set Platform/bitness vars -->
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'Windows' AND ('$(PackageRuntime)' == 'win-x64' OR '$(PackageRuntime)' == '')">
|
|
||||||
<DefineConstants>$(DefineConstants);X64</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'Windows' AND '$(PackageRuntime)' == 'win-x86'">
|
|
||||||
<DefineConstants>$(DefineConstants);X86</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'OSX'">
|
|
||||||
<DefineConstants>$(DefineConstants);X64</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'Linux' AND ('$(PackageRuntime)' == 'linux-x64' OR '$(PackageRuntime)' == '')">
|
|
||||||
<DefineConstants>$(DefineConstants);X64</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'Linux' AND '$(PackageRuntime)' == 'linux-arm'">
|
|
||||||
<DefineConstants>$(DefineConstants);ARM</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(BUILD_OS)' == 'Linux' AND '$(PackageRuntime)' == 'linux-arm64'">
|
|
||||||
<DefineConstants>$(DefineConstants);ARM64</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<!-- Set TRACE/DEBUG vars -->
|
|
||||||
<PropertyGroup>
|
|
||||||
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
|
||||||
<DefineConstants>$(DefineConstants);DEBUG</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
91
src/Misc/dotnet-install.ps1
vendored
91
src/Misc/dotnet-install.ps1
vendored
@@ -37,7 +37,10 @@
|
|||||||
.PARAMETER SharedRuntime
|
.PARAMETER SharedRuntime
|
||||||
This parameter is obsolete and may be removed in a future version of this script.
|
This parameter is obsolete and may be removed in a future version of this script.
|
||||||
The recommended alternative is '-Runtime dotnet'.
|
The recommended alternative is '-Runtime dotnet'.
|
||||||
|
|
||||||
|
Default: false
|
||||||
Installs just the shared runtime bits, not the entire SDK.
|
Installs just the shared runtime bits, not the entire SDK.
|
||||||
|
This is equivalent to specifying `-Runtime dotnet`.
|
||||||
.PARAMETER Runtime
|
.PARAMETER Runtime
|
||||||
Installs just a shared runtime, not the entire SDK.
|
Installs just a shared runtime, not the entire SDK.
|
||||||
Possible values:
|
Possible values:
|
||||||
@@ -74,15 +77,11 @@
|
|||||||
Skips installing non-versioned files if they already exist, such as dotnet.exe.
|
Skips installing non-versioned files if they already exist, such as dotnet.exe.
|
||||||
.PARAMETER NoCdn
|
.PARAMETER NoCdn
|
||||||
Disable downloading from the Azure CDN, and use the uncached feed directly.
|
Disable downloading from the Azure CDN, and use the uncached feed directly.
|
||||||
.PARAMETER JSonFile
|
|
||||||
Determines the SDK version from a user specified global.json file
|
|
||||||
Note: global.json must have a value for 'SDK:Version'
|
|
||||||
#>
|
#>
|
||||||
[cmdletbinding()]
|
[cmdletbinding()]
|
||||||
param(
|
param(
|
||||||
[string]$Channel="LTS",
|
[string]$Channel="LTS",
|
||||||
[string]$Version="Latest",
|
[string]$Version="Latest",
|
||||||
[string]$JSonFile,
|
|
||||||
[string]$InstallDir="<auto>",
|
[string]$InstallDir="<auto>",
|
||||||
[string]$Architecture="<auto>",
|
[string]$Architecture="<auto>",
|
||||||
[ValidateSet("dotnet", "aspnetcore", "windowsdesktop", IgnoreCase = $false)]
|
[ValidateSet("dotnet", "aspnetcore", "windowsdesktop", IgnoreCase = $false)]
|
||||||
@@ -259,6 +258,7 @@ function GetHTTPResponse([Uri] $Uri)
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Coherent) {
|
function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Coherent) {
|
||||||
Say-Invocation $MyInvocation
|
Say-Invocation $MyInvocation
|
||||||
|
|
||||||
@@ -304,64 +304,20 @@ function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Co
|
|||||||
return $VersionInfo
|
return $VersionInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
function Parse-Jsonfile-For-Version([string]$JSonFile) {
|
|
||||||
|
function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel, [string]$Version) {
|
||||||
Say-Invocation $MyInvocation
|
Say-Invocation $MyInvocation
|
||||||
|
|
||||||
If (-Not (Test-Path $JSonFile)) {
|
switch ($Version.ToLower()) {
|
||||||
throw "Unable to find '$JSonFile'"
|
{ $_ -eq "latest" } {
|
||||||
exit 0
|
$LatestVersionInfo = Get-Latest-Version-Info -AzureFeed $AzureFeed -Channel $Channel -Coherent $False
|
||||||
}
|
return $LatestVersionInfo.Version
|
||||||
try {
|
|
||||||
$JSonContent = Get-Content($JSonFile) -Raw | ConvertFrom-Json | Select-Object -expand "sdk" -ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
throw "Json file unreadable: '$JSonFile'"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
if ($JSonContent) {
|
|
||||||
try {
|
|
||||||
$JSonContent.PSObject.Properties | ForEach-Object {
|
|
||||||
$PropertyName = $_.Name
|
|
||||||
if ($PropertyName -eq "version") {
|
|
||||||
$Version = $_.Value
|
|
||||||
Say-Verbose "Version = $Version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch {
|
{ $_ -eq "coherent" } {
|
||||||
throw "Unable to parse the SDK node in '$JSonFile'"
|
$LatestVersionInfo = Get-Latest-Version-Info -AzureFeed $AzureFeed -Channel $Channel -Coherent $True
|
||||||
exit 0
|
return $LatestVersionInfo.Version
|
||||||
}
|
}
|
||||||
}
|
default { return $Version }
|
||||||
else {
|
|
||||||
throw "Unable to find the SDK node in '$JSonFile'"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
If ($Version -eq $null) {
|
|
||||||
throw "Unable to find the SDK:version node in '$JSonFile'"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
return $Version
|
|
||||||
}
|
|
||||||
|
|
||||||
function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel, [string]$Version, [string]$JSonFile) {
|
|
||||||
Say-Invocation $MyInvocation
|
|
||||||
|
|
||||||
if (-not $JSonFile) {
|
|
||||||
switch ($Version.ToLower()) {
|
|
||||||
{ $_ -eq "latest" } {
|
|
||||||
$LatestVersionInfo = Get-Latest-Version-Info -AzureFeed $AzureFeed -Channel $Channel -Coherent $False
|
|
||||||
return $LatestVersionInfo.Version
|
|
||||||
}
|
|
||||||
{ $_ -eq "coherent" } {
|
|
||||||
$LatestVersionInfo = Get-Latest-Version-Info -AzureFeed $AzureFeed -Channel $Channel -Coherent $True
|
|
||||||
return $LatestVersionInfo.Version
|
|
||||||
}
|
|
||||||
default { return $Version }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Parse-Jsonfile-For-Version $JSonFile
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,6 +382,23 @@ function Resolve-Installation-Path([string]$InstallDir) {
|
|||||||
return $InstallDir
|
return $InstallDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$RelativePathToVersionFile) {
|
||||||
|
Say-Invocation $MyInvocation
|
||||||
|
|
||||||
|
$VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile
|
||||||
|
Say-Verbose "Local version file: $VersionFile"
|
||||||
|
|
||||||
|
if (Test-Path $VersionFile) {
|
||||||
|
$VersionText = cat $VersionFile
|
||||||
|
Say-Verbose "Local version file text: $VersionText"
|
||||||
|
return Get-Version-Info-From-Version-Text $VersionText
|
||||||
|
}
|
||||||
|
|
||||||
|
Say-Verbose "Local version file not found."
|
||||||
|
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) {
|
function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) {
|
||||||
Say-Invocation $MyInvocation
|
Say-Invocation $MyInvocation
|
||||||
|
|
||||||
@@ -561,7 +534,7 @@ function Prepend-Sdk-InstallRoot-To-Path([string]$InstallRoot, [string]$BinFolde
|
|||||||
}
|
}
|
||||||
|
|
||||||
$CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture
|
$CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture
|
||||||
$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version -JSonFile $JSonFile
|
$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version
|
||||||
$DownloadLink = Get-Download-Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
|
$DownloadLink = Get-Download-Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
|
||||||
$LegacyDownloadLink = Get-LegacyDownload-Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
|
$LegacyDownloadLink = Get-LegacyDownload-Link -AzureFeed $AzureFeed -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
|
||||||
|
|
||||||
|
|||||||
125
src/Misc/dotnet-install.sh
vendored
125
src/Misc/dotnet-install.sh
vendored
@@ -435,52 +435,11 @@ get_latest_version_info() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
# args:
|
|
||||||
# json_file - $1
|
|
||||||
parse_jsonfile_for_version() {
|
|
||||||
eval $invocation
|
|
||||||
|
|
||||||
local json_file="$1"
|
|
||||||
if [ ! -f "$json_file" ]; then
|
|
||||||
say_err "Unable to find \`$json_file\`"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sdk_section=$(cat $json_file | awk '/"sdk"/,/}/')
|
|
||||||
if [ -z "$sdk_section" ]; then
|
|
||||||
say_err "Unable to parse the SDK node in \`$json_file\`"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sdk_list=$(echo $sdk_section | awk -F"[{}]" '{print $2}')
|
|
||||||
sdk_list=${sdk_list//[\" ]/}
|
|
||||||
sdk_list=${sdk_list//,/$'\n'}
|
|
||||||
sdk_list="$(echo -e "${sdk_list}" | tr -d '[[:space:]]')"
|
|
||||||
|
|
||||||
local version_info=""
|
|
||||||
while read -r line; do
|
|
||||||
IFS=:
|
|
||||||
while read -r key value; do
|
|
||||||
if [[ "$key" == "version" ]]; then
|
|
||||||
version_info=$value
|
|
||||||
fi
|
|
||||||
done <<< "$line"
|
|
||||||
done <<< "$sdk_list"
|
|
||||||
if [ -z "$version_info" ]; then
|
|
||||||
say_err "Unable to find the SDK:version node in \`$json_file\`"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$version_info"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
# azure_feed - $1
|
# azure_feed - $1
|
||||||
# channel - $2
|
# channel - $2
|
||||||
# normalized_architecture - $3
|
# normalized_architecture - $3
|
||||||
# version - $4
|
# version - $4
|
||||||
# json_file - $5
|
|
||||||
get_specific_version_from_version() {
|
get_specific_version_from_version() {
|
||||||
eval $invocation
|
eval $invocation
|
||||||
|
|
||||||
@@ -488,35 +447,27 @@ get_specific_version_from_version() {
|
|||||||
local channel="$2"
|
local channel="$2"
|
||||||
local normalized_architecture="$3"
|
local normalized_architecture="$3"
|
||||||
local version="$(to_lowercase "$4")"
|
local version="$(to_lowercase "$4")"
|
||||||
local json_file="$5"
|
|
||||||
|
|
||||||
if [ -z "$json_file" ]; then
|
case "$version" in
|
||||||
case "$version" in
|
latest)
|
||||||
latest)
|
local version_info
|
||||||
local version_info
|
version_info="$(get_latest_version_info "$azure_feed" "$channel" "$normalized_architecture" false)" || return 1
|
||||||
version_info="$(get_latest_version_info "$azure_feed" "$channel" "$normalized_architecture" false)" || return 1
|
say_verbose "get_specific_version_from_version: version_info=$version_info"
|
||||||
say_verbose "get_specific_version_from_version: version_info=$version_info"
|
echo "$version_info" | get_version_from_version_info
|
||||||
echo "$version_info" | get_version_from_version_info
|
return 0
|
||||||
return 0
|
;;
|
||||||
;;
|
coherent)
|
||||||
coherent)
|
local version_info
|
||||||
local version_info
|
version_info="$(get_latest_version_info "$azure_feed" "$channel" "$normalized_architecture" true)" || return 1
|
||||||
version_info="$(get_latest_version_info "$azure_feed" "$channel" "$normalized_architecture" true)" || return 1
|
say_verbose "get_specific_version_from_version: version_info=$version_info"
|
||||||
say_verbose "get_specific_version_from_version: version_info=$version_info"
|
echo "$version_info" | get_version_from_version_info
|
||||||
echo "$version_info" | get_version_from_version_info
|
return 0
|
||||||
return 0
|
;;
|
||||||
;;
|
*)
|
||||||
*)
|
echo "$version"
|
||||||
echo "$version"
|
return 0
|
||||||
return 0
|
;;
|
||||||
;;
|
esac
|
||||||
esac
|
|
||||||
else
|
|
||||||
local version_info
|
|
||||||
version_info="$(parse_jsonfile_for_version "$json_file")" || return 1
|
|
||||||
echo "$version_info"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
@@ -607,6 +558,24 @@ resolve_installation_path() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# args:
|
||||||
|
# install_root - $1
|
||||||
|
get_installed_version_info() {
|
||||||
|
eval $invocation
|
||||||
|
|
||||||
|
local install_root="$1"
|
||||||
|
local version_file="$(combine_paths "$install_root" "$local_version_file_relative_path")"
|
||||||
|
say_verbose "Local version file: $version_file"
|
||||||
|
if [ ! -z "$version_file" ] | [ -r "$version_file" ]; then
|
||||||
|
local version_info="$(cat "$version_file")"
|
||||||
|
echo "$version_info"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
say_verbose "Local version file not found."
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# args:
|
# args:
|
||||||
# relative_or_absolute_path - $1
|
# relative_or_absolute_path - $1
|
||||||
get_absolute_path() {
|
get_absolute_path() {
|
||||||
@@ -755,7 +724,7 @@ calculate_vars() {
|
|||||||
normalized_architecture="$(get_normalized_architecture_from_architecture "$architecture")"
|
normalized_architecture="$(get_normalized_architecture_from_architecture "$architecture")"
|
||||||
say_verbose "normalized_architecture=$normalized_architecture"
|
say_verbose "normalized_architecture=$normalized_architecture"
|
||||||
|
|
||||||
specific_version="$(get_specific_version_from_version "$azure_feed" "$channel" "$normalized_architecture" "$version" "$json_file")"
|
specific_version="$(get_specific_version_from_version "$azure_feed" "$channel" "$normalized_architecture" "$version")"
|
||||||
say_verbose "specific_version=$specific_version"
|
say_verbose "specific_version=$specific_version"
|
||||||
if [ -z "$specific_version" ]; then
|
if [ -z "$specific_version" ]; then
|
||||||
say_err "Could not resolve version information."
|
say_err "Could not resolve version information."
|
||||||
@@ -857,7 +826,6 @@ temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX"
|
|||||||
|
|
||||||
channel="LTS"
|
channel="LTS"
|
||||||
version="Latest"
|
version="Latest"
|
||||||
json_file=""
|
|
||||||
install_dir="<auto>"
|
install_dir="<auto>"
|
||||||
architecture="<auto>"
|
architecture="<auto>"
|
||||||
dry_run=false
|
dry_run=false
|
||||||
@@ -944,10 +912,6 @@ do
|
|||||||
runtime_id="$1"
|
runtime_id="$1"
|
||||||
non_dynamic_parameters+=" $name "\""$1"\"""
|
non_dynamic_parameters+=" $name "\""$1"\"""
|
||||||
;;
|
;;
|
||||||
--jsonfile|-[Jj][Ss]on[Ff]ile)
|
|
||||||
shift
|
|
||||||
json_file="$1"
|
|
||||||
;;
|
|
||||||
--skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles)
|
--skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles)
|
||||||
override_non_versioned_files=false
|
override_non_versioned_files=false
|
||||||
non_dynamic_parameters+=" $name"
|
non_dynamic_parameters+=" $name"
|
||||||
@@ -989,25 +953,22 @@ do
|
|||||||
echo " Possible values:"
|
echo " Possible values:"
|
||||||
echo " - dotnet - the Microsoft.NETCore.App shared runtime"
|
echo " - dotnet - the Microsoft.NETCore.App shared runtime"
|
||||||
echo " - aspnetcore - the Microsoft.AspNetCore.App shared runtime"
|
echo " - aspnetcore - the Microsoft.AspNetCore.App shared runtime"
|
||||||
|
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
|
||||||
|
echo " -SkipNonVersionedFiles"
|
||||||
echo " --dry-run,-DryRun Do not perform installation. Display download link."
|
echo " --dry-run,-DryRun Do not perform installation. Display download link."
|
||||||
echo " --no-path, -NoPath Do not set PATH for the current process."
|
echo " --no-path, -NoPath Do not set PATH for the current process."
|
||||||
echo " --verbose,-Verbose Display diagnostics information."
|
echo " --verbose,-Verbose Display diagnostics information."
|
||||||
echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user."
|
echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user."
|
||||||
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user."
|
echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user."
|
||||||
echo " --feed-credential,-FeedCredential Azure feed shared access token. This parameter typically is not specified."
|
|
||||||
echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
|
|
||||||
echo " -SkipNonVersionedFiles"
|
|
||||||
echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly."
|
echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly."
|
||||||
echo " --jsonfile <JSONFILE> Determines the SDK version from a user specified global.json file."
|
echo " --feed-credential,-FeedCredential Azure feed shared access token. This parameter typically is not specified."
|
||||||
echo " Note: global.json must have a value for 'SDK:Version'"
|
|
||||||
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
|
echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)."
|
||||||
echo " -RuntimeId"
|
echo " -RuntimeId"
|
||||||
echo " -?,--?,-h,--help,-Help Shows this help message"
|
echo " -?,--?,-h,--help,-Help Shows this help message"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Obsolete parameters:"
|
echo "Obsolete parameters:"
|
||||||
echo " --shared-runtime The recommended alternative is '--runtime dotnet'."
|
echo " --shared-runtime The recommended alternative is '--runtime dotnet'."
|
||||||
echo " This parameter is obsolete and may be removed in a future version of this script."
|
echo " -SharedRuntime Installs just the shared runtime bits, not the entire SDK."
|
||||||
echo " Installs just the shared runtime bits, not the entire SDK."
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Install Location:"
|
echo "Install Location:"
|
||||||
echo " Location is chosen in following order:"
|
echo " Location is chosen in following order:"
|
||||||
|
|||||||
@@ -123,9 +123,9 @@ function acquireExternalTool() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Download the external tools only for Windows.
|
# Download the external tools only for Windows.
|
||||||
if [[ "$PACKAGERUNTIME" == "win-x64" || "$PACKAGERUNTIME" == "win-x86" ]]; then
|
if [[ "$PACKAGERUNTIME" == "win-x64" ]]; then
|
||||||
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/$PACKAGERUNTIME/node.exe" node12/bin
|
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/win-x64/node.exe" node12/bin
|
||||||
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/$PACKAGERUNTIME/node.lib" node12/bin
|
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/win-x64/node.lib" node12/bin
|
||||||
if [[ "$PRECACHE" != "" ]]; then
|
if [[ "$PRECACHE" != "" ]]; then
|
||||||
acquireExternalTool "https://github.com/microsoft/vswhere/releases/download/2.6.7/vswhere.exe" vswhere
|
acquireExternalTool "https://github.com/microsoft/vswhere/releases/download/2.6.7/vswhere.exe" vswhere
|
||||||
fi
|
fi
|
||||||
@@ -136,23 +136,13 @@ if [[ "$PACKAGERUNTIME" == "osx-x64" ]]; then
|
|||||||
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-darwin-x64.tar.gz" node12 fix_nested_dir
|
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-darwin-x64.tar.gz" node12 fix_nested_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download the external tools for Linux PACKAGERUNTIMEs.
|
# Download the external tools common across Linux PACKAGERUNTIMEs (excluding OSX).
|
||||||
if [[ "$PACKAGERUNTIME" == "linux-x64" || "$PACKAGERUNTIME" == "rhel.6-x64" ]]; then
|
if [[ "$PACKAGERUNTIME" == "linux-x64" || "$PACKAGERUNTIME" == "rhel.6-x64" ]]; then
|
||||||
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-x64.tar.gz" node12 fix_nested_dir
|
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-x64.tar.gz" node12 fix_nested_dir
|
||||||
# TODO: Repath this blob to use a consistent version format (_ vs .)
|
# TODO: Repath this blob to use a consistent version format (_ vs .)
|
||||||
acquireExternalTool "https://vstsagenttools.blob.core.windows.net/tools/nodejs/12_4_0/alpine/node-v${NODE12_VERSION}-alpine.tar.gz" node12_alpine
|
acquireExternalTool "https://vstsagenttools.blob.core.windows.net/tools/nodejs/12_4_0/alpine/node-v${NODE12_VERSION}-alpine.tar.gz" node12_alpine
|
||||||
# acquireExternalTool "https://vstsagenttools.blob.core.windows.net/tools/nodejs/12.13.0/alpine/x64/node-v${NODE12_VERSION}-alpine-x64.tar.gz" node12_alpine
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$PACKAGERUNTIME" == "linux-arm64" ]]; then
|
|
||||||
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-arm64.tar.gz" node12 fix_nested_dir
|
|
||||||
# TODO: alpine node runtime for arm64(8)
|
|
||||||
# acquireExternalTool "https://vstsagenttools.blob.core.windows.net/tools/nodejs/12.13.0/alpine/arm64/node-v${NODE12_VERSION}-alpine-arm64.tar.gz" node12_alpine
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$PACKAGERUNTIME" == "linux-arm" ]]; then
|
if [[ "$PACKAGERUNTIME" == "linux-arm" ]]; then
|
||||||
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-armv7l.tar.gz" node12 fix_nested_dir
|
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-armv7l.tar.gz" node12 fix_nested_dir
|
||||||
# TODO: alpine node runtime for arm32(7)
|
|
||||||
# Need to set up custom gcc toolchain to cross compile on x64 ubuntu for armv7 (per https://github.com/nodejs/node/blob/master/BUILDING.md)
|
|
||||||
# acquireExternalTool "https://vstsagenttools.blob.core.windows.net/tools/nodejs/12.13.0/alpine/arm/node-v${NODE12_VERSION}-alpine-arm.tar.gz" node12_alpine
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ namespace GitHub.Runner.Common
|
|||||||
Add<T>(extensions, "GitHub.Runner.Worker.DebugCommandExtension, Runner.Worker");
|
Add<T>(extensions, "GitHub.Runner.Worker.DebugCommandExtension, Runner.Worker");
|
||||||
Add<T>(extensions, "GitHub.Runner.Worker.GroupCommandExtension, Runner.Worker");
|
Add<T>(extensions, "GitHub.Runner.Worker.GroupCommandExtension, Runner.Worker");
|
||||||
Add<T>(extensions, "GitHub.Runner.Worker.EndGroupCommandExtension, Runner.Worker");
|
Add<T>(extensions, "GitHub.Runner.Worker.EndGroupCommandExtension, Runner.Worker");
|
||||||
Add<T>(extensions, "GitHub.Runner.Worker.EchoCommandExtension, Runner.Worker");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// This should never happen.
|
// This should never happen.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
||||||
<NoWarn>NU1701;NU1603</NoWarn>
|
<NoWarn>NU1701;NU1603</NoWarn>
|
||||||
@@ -28,4 +28,42 @@
|
|||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
|
||||||
|
<DefineConstants>OS_OSX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' AND '$(Configuration)' == 'Debug'">
|
||||||
|
<DefineConstants>OS_OSX;DEBUG;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ namespace GitHub.Runner.Common.Util
|
|||||||
return "X64";
|
return "X64";
|
||||||
case Constants.Architecture.Arm:
|
case Constants.Architecture.Arm:
|
||||||
return "ARM";
|
return "ARM";
|
||||||
case Constants.Architecture.Arm64:
|
|
||||||
return "ARM64";
|
|
||||||
default:
|
default:
|
||||||
throw new NotSupportedException(); // Should never reach here.
|
throw new NotSupportedException(); // Should never reach here.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
||||||
<NoWarn>NU1701;NU1603</NoWarn>
|
<NoWarn>NU1701;NU1603</NoWarn>
|
||||||
@@ -31,4 +31,42 @@
|
|||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
|
||||||
|
<DefineConstants>OS_OSX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' AND '$(Configuration)' == 'Debug'">
|
||||||
|
<DefineConstants>OS_OSX;DEBUG;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
||||||
<NoWarn>NU1701;NU1603</NoWarn>
|
<NoWarn>NU1701;NU1603</NoWarn>
|
||||||
@@ -24,4 +24,42 @@
|
|||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
|
||||||
|
<DefineConstants>OS_OSX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' AND '$(Configuration)' == 'Debug'">
|
||||||
|
<DefineConstants>OS_OSX;DEBUG;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -236,15 +236,15 @@ namespace GitHub.Runner.Plugins.Artifact
|
|||||||
// try upload all files for the first time.
|
// try upload all files for the first time.
|
||||||
UploadResult uploadResult = await ParallelUploadAsync(context, files, maxConcurrentUploads, _uploadCancellationTokenSource.Token);
|
UploadResult uploadResult = await ParallelUploadAsync(context, files, maxConcurrentUploads, _uploadCancellationTokenSource.Token);
|
||||||
|
|
||||||
if (uploadResult.RetryFiles.Count == 0)
|
if (uploadResult.FailedFiles.Count == 0)
|
||||||
{
|
{
|
||||||
// all files have been upload succeed.
|
// all files have been upload succeed.
|
||||||
context.Output("File upload complete.");
|
context.Output("File upload succeed.");
|
||||||
return uploadResult.TotalFileSizeUploaded;
|
return uploadResult.TotalFileSizeUploaded;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
context.Output($"{uploadResult.RetryFiles.Count} files failed to upload, retry these files after a minute.");
|
context.Output($"{uploadResult.FailedFiles.Count} files failed to upload, retry these files after a minute.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay 1 min then retry failed files.
|
// Delay 1 min then retry failed files.
|
||||||
@@ -255,13 +255,13 @@ namespace GitHub.Runner.Plugins.Artifact
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retry upload all failed files.
|
// Retry upload all failed files.
|
||||||
context.Output($"Start retry {uploadResult.RetryFiles.Count} failed files upload.");
|
context.Output($"Start retry {uploadResult.FailedFiles.Count} failed files upload.");
|
||||||
UploadResult retryUploadResult = await ParallelUploadAsync(context, uploadResult.RetryFiles, maxConcurrentUploads, _uploadCancellationTokenSource.Token);
|
UploadResult retryUploadResult = await ParallelUploadAsync(context, uploadResult.FailedFiles, maxConcurrentUploads, _uploadCancellationTokenSource.Token);
|
||||||
|
|
||||||
if (retryUploadResult.RetryFiles.Count == 0)
|
if (retryUploadResult.FailedFiles.Count == 0)
|
||||||
{
|
{
|
||||||
// all files have been upload succeed after retry.
|
// all files have been upload succeed after retry.
|
||||||
context.Output("File upload complete after retry.");
|
context.Output("File upload succeed after retry.");
|
||||||
return uploadResult.TotalFileSizeUploaded + retryUploadResult.TotalFileSizeUploaded;
|
return uploadResult.TotalFileSizeUploaded + retryUploadResult.TotalFileSizeUploaded;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -465,61 +465,75 @@ namespace GitHub.Runner.Plugins.Artifact
|
|||||||
using (FileStream fs = File.Open(fileToUpload, FileMode.Open, FileAccess.Read, FileShare.Read))
|
using (FileStream fs = File.Open(fileToUpload, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
{
|
{
|
||||||
string itemPath = (_containerPath.TrimEnd('/') + "/" + fileToUpload.Remove(0, _sourceParentDirectory.Length + 1)).Replace('\\', '/');
|
string itemPath = (_containerPath.TrimEnd('/') + "/" + fileToUpload.Remove(0, _sourceParentDirectory.Length + 1)).Replace('\\', '/');
|
||||||
bool failAndExit = false;
|
uploadTimer.Restart();
|
||||||
|
bool catchExceptionDuringUpload = false;
|
||||||
|
HttpResponseMessage response = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uploadTimer.Restart();
|
response = await _fileContainerHttpClient.UploadFileAsync(_containerId, itemPath, fs, _projectId, cancellationToken: token, chunkSize: 4 * 1024 * 1024);
|
||||||
using (HttpResponseMessage response = await _fileContainerHttpClient.UploadFileAsync(_containerId, itemPath, fs, _projectId, cancellationToken: token, chunkSize: 4 * 1024 * 1024))
|
|
||||||
{
|
|
||||||
if (response == null || response.StatusCode != HttpStatusCode.Created)
|
|
||||||
{
|
|
||||||
context.Output($"Unable to copy file to server StatusCode={response?.StatusCode}: {response?.ReasonPhrase}. Source file path: {fileToUpload}. Target server path: {itemPath}");
|
|
||||||
|
|
||||||
if (response?.StatusCode == HttpStatusCode.Conflict)
|
|
||||||
{
|
|
||||||
// fail upload task but continue with any other files
|
|
||||||
context.Error($"Error '{fileToUpload}' has already been uploaded.");
|
|
||||||
}
|
|
||||||
else if (_fileContainerHttpClient.IsFastFailResponse(response))
|
|
||||||
{
|
|
||||||
// Fast fail: we received an http status code where we should abandon our efforts
|
|
||||||
context.Output($"Cannot continue uploading files, so draining upload queue of {_fileUploadQueue.Count} items.");
|
|
||||||
DrainUploadQueue(context);
|
|
||||||
failedFiles.Clear();
|
|
||||||
failAndExit = true;
|
|
||||||
throw new UploadFailedException($"Critical failure uploading '{fileToUpload}'");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
context.Debug($"Adding '{fileToUpload}' to retry list.");
|
|
||||||
failedFiles.Add(fileToUpload);
|
|
||||||
}
|
|
||||||
throw new UploadFailedException($"Http failure response '{response?.StatusCode}': '{response?.ReasonPhrase}' while uploading '{fileToUpload}'");
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadTimer.Stop();
|
|
||||||
context.Debug($"File: '{fileToUpload}' took {uploadTimer.ElapsedMilliseconds} milliseconds to finish upload");
|
|
||||||
uploadedSize += fs.Length;
|
|
||||||
OutputLogForFile(context, fileToUpload, $"Detail upload trace for file: {itemPath}", context.Debug);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException) when (token.IsCancellationRequested)
|
catch (OperationCanceledException) when (token.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
context.Output($"File upload has been cancelled during upload file: '{fileToUpload}'.");
|
context.Output($"File upload has been cancelled during upload file: '{fileToUpload}'.");
|
||||||
|
if (response != null)
|
||||||
|
{
|
||||||
|
response.Dispose();
|
||||||
|
response = null;
|
||||||
|
}
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
catchExceptionDuringUpload = true;
|
||||||
context.Output($"Fail to upload '{fileToUpload}' due to '{ex.Message}'.");
|
context.Output($"Fail to upload '{fileToUpload}' due to '{ex.Message}'.");
|
||||||
context.Output(ex.ToString());
|
context.Output(ex.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
OutputLogForFile(context, fileToUpload, $"Detail upload trace for file that fail to upload: {itemPath}", context.Output);
|
uploadTimer.Stop();
|
||||||
|
if (catchExceptionDuringUpload || (response != null && response.StatusCode != HttpStatusCode.Created))
|
||||||
if (failAndExit)
|
{
|
||||||
|
if (response != null)
|
||||||
{
|
{
|
||||||
context.Debug("Exiting upload.");
|
context.Output($"Unable to copy file to server StatusCode={response.StatusCode}: {response.ReasonPhrase}. Source file path: {fileToUpload}. Target server path: {itemPath}");
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// output detail upload trace for the file.
|
||||||
|
ConcurrentQueue<string> logQueue;
|
||||||
|
if (_fileUploadTraceLog.TryGetValue(itemPath, out logQueue))
|
||||||
|
{
|
||||||
|
context.Output($"Detail upload trace for file that fail to upload: {itemPath}");
|
||||||
|
string message;
|
||||||
|
while (logQueue.TryDequeue(out message))
|
||||||
|
{
|
||||||
|
context.Output(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// tracking file that failed to upload.
|
||||||
|
failedFiles.Add(fileToUpload);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Debug($"File: '{fileToUpload}' took {uploadTimer.ElapsedMilliseconds} milliseconds to finish upload");
|
||||||
|
uploadedSize += fs.Length;
|
||||||
|
// debug detail upload trace for the file.
|
||||||
|
ConcurrentQueue<string> logQueue;
|
||||||
|
if (_fileUploadTraceLog.TryGetValue(itemPath, out logQueue))
|
||||||
|
{
|
||||||
|
context.Debug($"Detail upload trace for file: {itemPath}");
|
||||||
|
string message;
|
||||||
|
while (logQueue.TryDequeue(out message))
|
||||||
|
{
|
||||||
|
context.Debug(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response != null)
|
||||||
|
{
|
||||||
|
response.Dispose();
|
||||||
|
response = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,30 +590,6 @@ namespace GitHub.Runner.Plugins.Artifact
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrainUploadQueue(RunnerActionPluginExecutionContext context)
|
|
||||||
{
|
|
||||||
while (_fileUploadQueue.TryDequeue(out string fileToUpload))
|
|
||||||
{
|
|
||||||
context.Debug($"Clearing upload queue: '{fileToUpload}'");
|
|
||||||
Interlocked.Increment(ref _uploadFilesProcessed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OutputLogForFile(RunnerActionPluginExecutionContext context, string itemPath, string logDescription, Action<string> log)
|
|
||||||
{
|
|
||||||
// output detail upload trace for the file.
|
|
||||||
ConcurrentQueue<string> logQueue;
|
|
||||||
if (_fileUploadTraceLog.TryGetValue(itemPath, out logQueue))
|
|
||||||
{
|
|
||||||
log(logDescription);
|
|
||||||
string message;
|
|
||||||
while (logQueue.TryDequeue(out message))
|
|
||||||
{
|
|
||||||
log(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UploadFileTraceReportReceived(object sender, ReportTraceEventArgs e)
|
private void UploadFileTraceReportReceived(object sender, ReportTraceEventArgs e)
|
||||||
{
|
{
|
||||||
ConcurrentQueue<string> logQueue = _fileUploadTraceLog.GetOrAdd(e.File, new ConcurrentQueue<string>());
|
ConcurrentQueue<string> logQueue = _fileUploadTraceLog.GetOrAdd(e.File, new ConcurrentQueue<string>());
|
||||||
@@ -617,22 +607,22 @@ namespace GitHub.Runner.Plugins.Artifact
|
|||||||
{
|
{
|
||||||
public UploadResult()
|
public UploadResult()
|
||||||
{
|
{
|
||||||
RetryFiles = new List<string>();
|
FailedFiles = new List<string>();
|
||||||
TotalFileSizeUploaded = 0;
|
TotalFileSizeUploaded = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UploadResult(List<string> retryFiles, long totalFileSizeUploaded)
|
public UploadResult(List<string> failedFiles, long totalFileSizeUploaded)
|
||||||
{
|
{
|
||||||
RetryFiles = retryFiles ?? new List<string>();
|
FailedFiles = failedFiles;
|
||||||
TotalFileSizeUploaded = totalFileSizeUploaded;
|
TotalFileSizeUploaded = totalFileSizeUploaded;
|
||||||
}
|
}
|
||||||
public List<string> RetryFiles { get; set; }
|
public List<string> FailedFiles { get; set; }
|
||||||
|
|
||||||
public long TotalFileSizeUploaded { get; set; }
|
public long TotalFileSizeUploaded { get; set; }
|
||||||
|
|
||||||
public void AddUploadResult(UploadResult resultToAdd)
|
public void AddUploadResult(UploadResult resultToAdd)
|
||||||
{
|
{
|
||||||
this.RetryFiles.AddRange(resultToAdd.RetryFiles);
|
this.FailedFiles.AddRange(resultToAdd.FailedFiles);
|
||||||
this.TotalFileSizeUploaded += resultToAdd.TotalFileSizeUploaded;
|
this.TotalFileSizeUploaded += resultToAdd.TotalFileSizeUploaded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -667,19 +657,4 @@ namespace GitHub.Runner.Plugins.Artifact
|
|||||||
this.FailedFiles.AddRange(resultToAdd.FailedFiles);
|
this.FailedFiles.AddRange(resultToAdd.FailedFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UploadFailedException : Exception
|
|
||||||
{
|
|
||||||
public UploadFailedException()
|
|
||||||
: base()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public UploadFailedException(string message)
|
|
||||||
: base(message)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public UploadFailedException(string message, Exception inner)
|
|
||||||
: base(message, inner)
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -74,22 +74,17 @@ namespace GitHub.Runner.Plugins.Artifact
|
|||||||
context.Output($"Uploading artifact '{artifactName}' from '{fullPath}' for run #{buildId}");
|
context.Output($"Uploading artifact '{artifactName}' from '{fullPath}' for run #{buildId}");
|
||||||
|
|
||||||
FileContainerServer fileContainerHelper = new FileContainerServer(context.VssConnection, projectId, containerId, artifactName);
|
FileContainerServer fileContainerHelper = new FileContainerServer(context.VssConnection, projectId, containerId, artifactName);
|
||||||
|
long size = await fileContainerHelper.CopyToContainerAsync(context, fullPath, token);
|
||||||
var propertiesDictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
var propertiesDictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
try
|
propertiesDictionary.Add("artifactsize", size.ToString());
|
||||||
{
|
|
||||||
long size = await fileContainerHelper.CopyToContainerAsync(context, fullPath, token);
|
string fileContainerFullPath = StringUtil.Format($"#/{containerId}/{artifactName}");
|
||||||
propertiesDictionary.Add("artifactsize", size.ToString());
|
context.Output($"Uploaded '{fullPath}' to server");
|
||||||
context.Output($"Uploaded '{size}' bytes from '{fullPath}' to server");
|
|
||||||
}
|
BuildServer buildHelper = new BuildServer(context.VssConnection);
|
||||||
// if any of the results were successful, make sure to attach them to the build
|
string jobId = context.Variables.GetValueOrDefault(WellKnownDistributedTaskVariables.JobId).Value ?? string.Empty;
|
||||||
finally
|
var artifact = await buildHelper.AssociateArtifact(projectId, buildId, jobId, artifactName, ArtifactResourceTypes.Container, fileContainerFullPath, propertiesDictionary, token);
|
||||||
{
|
context.Output($"Associated artifact {artifactName} ({artifact.Id}) with run #{buildId}");
|
||||||
string fileContainerFullPath = StringUtil.Format($"#/{containerId}/{artifactName}");
|
|
||||||
BuildServer buildHelper = new BuildServer(context.VssConnection);
|
|
||||||
string jobId = context.Variables.GetValueOrDefault(WellKnownDistributedTaskVariables.JobId).Value ?? string.Empty;
|
|
||||||
var artifact = await buildHelper.AssociateArtifact(projectId, buildId, jobId, artifactName, ArtifactResourceTypes.Container, fileContainerFullPath, propertiesDictionary, token);
|
|
||||||
context.Output($"Associated artifact {artifactName} ({artifact.Id}) with run #{buildId}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
||||||
<NoWarn>NU1701;NU1603</NoWarn>
|
<NoWarn>NU1701;NU1603</NoWarn>
|
||||||
@@ -20,4 +20,42 @@
|
|||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
|
||||||
|
<DefineConstants>OS_OSX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' AND '$(Configuration)' == 'Debug'">
|
||||||
|
<DefineConstants>OS_OSX;DEBUG;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
||||||
<NoWarn>NU1701;NU1603</NoWarn>
|
<NoWarn>NU1701;NU1603</NoWarn>
|
||||||
@@ -25,4 +25,42 @@
|
|||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
|
||||||
|
<DefineConstants>OS_OSX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' AND '$(Configuration)' == 'Debug'">
|
||||||
|
<DefineConstants>OS_OSX;DEBUG;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
BIN
src/Runner.Service/Windows/FinalPublicKey.snk
Normal file
BIN
src/Runner.Service/Windows/FinalPublicKey.snk
Normal file
Binary file not shown.
@@ -9,8 +9,9 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>RunnerService</RootNamespace>
|
<RootNamespace>RunnerService</RootNamespace>
|
||||||
<AssemblyName>RunnerService</AssemblyName>
|
<AssemblyName>RunnerService</AssemblyName>
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<DelaySign>false</DelaySign>
|
<AssemblyOriginatorKeyFile>FinalPublicKey.snk</AssemblyOriginatorKeyFile>
|
||||||
|
<DelaySign>true</DelaySign>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
|
<None Include="FinalPublicKey.snk" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resource.resx">
|
<EmbeddedResource Include="Resource.resx">
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace GitHub.Runner.Worker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// process action command in serialize order.
|
// process action command in serialize oreder.
|
||||||
lock (_commandSerializeLock)
|
lock (_commandSerializeLock)
|
||||||
{
|
{
|
||||||
if (_stopProcessCommand)
|
if (_stopProcessCommand)
|
||||||
@@ -107,22 +107,26 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
else if (_commandExtensions.TryGetValue(actionCommand.Command, out IActionCommandExtension extension))
|
else if (_commandExtensions.TryGetValue(actionCommand.Command, out IActionCommandExtension extension))
|
||||||
{
|
{
|
||||||
if (context.EchoOnActionCommand && !extension.OmitEcho)
|
bool omitEcho;
|
||||||
{
|
|
||||||
context.Output(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
extension.ProcessCommand(context, input, actionCommand);
|
extension.ProcessCommand(context, input, actionCommand, out omitEcho);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var commandInformation = extension.OmitEcho ? extension.Command : input;
|
omitEcho = true;
|
||||||
context.Error($"Unable to process command '{commandInformation}' successfully.");
|
context.Output(input);
|
||||||
|
context.Error($"Unable to process command '{input}' successfully.");
|
||||||
context.Error(ex);
|
context.Error(ex);
|
||||||
context.CommandResult = TaskResult.Failed;
|
context.CommandResult = TaskResult.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!omitEcho)
|
||||||
|
{
|
||||||
|
context.Output(input);
|
||||||
|
context.Debug($"Processed command");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -138,19 +142,17 @@ namespace GitHub.Runner.Worker
|
|||||||
public interface IActionCommandExtension : IExtension
|
public interface IActionCommandExtension : IExtension
|
||||||
{
|
{
|
||||||
string Command { get; }
|
string Command { get; }
|
||||||
bool OmitEcho { get; }
|
|
||||||
|
|
||||||
void ProcessCommand(IExecutionContext context, string line, ActionCommand command);
|
void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho);
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class InternalPluginSetRepoPathCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class InternalPluginSetRepoPathCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "internal-set-repo-path";
|
public string Command => "internal-set-repo-path";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
if (!command.Properties.TryGetValue(SetRepoPathCommandProperties.repoFullName, out string repoFullName) || string.IsNullOrEmpty(repoFullName))
|
if (!command.Properties.TryGetValue(SetRepoPathCommandProperties.repoFullName, out string repoFullName) || string.IsNullOrEmpty(repoFullName))
|
||||||
{
|
{
|
||||||
@@ -164,6 +166,8 @@ namespace GitHub.Runner.Worker
|
|||||||
|
|
||||||
var directoryManager = HostContext.GetService<IPipelineDirectoryManager>();
|
var directoryManager = HostContext.GetService<IPipelineDirectoryManager>();
|
||||||
var trackingConfig = directoryManager.UpdateRepositoryDirectory(context, repoFullName, command.Data, StringUtil.ConvertToBoolean(workspaceRepo));
|
var trackingConfig = directoryManager.UpdateRepositoryDirectory(context, repoFullName, command.Data, StringUtil.ConvertToBoolean(workspaceRepo));
|
||||||
|
|
||||||
|
omitEcho = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SetRepoPathCommandProperties
|
private static class SetRepoPathCommandProperties
|
||||||
@@ -176,11 +180,10 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class SetEnvCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class SetEnvCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "set-env";
|
public string Command => "set-env";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
if (!command.Properties.TryGetValue(SetEnvCommandProperties.Name, out string envName) || string.IsNullOrEmpty(envName))
|
if (!command.Properties.TryGetValue(SetEnvCommandProperties.Name, out string envName) || string.IsNullOrEmpty(envName))
|
||||||
{
|
{
|
||||||
@@ -189,7 +192,9 @@ namespace GitHub.Runner.Worker
|
|||||||
|
|
||||||
context.EnvironmentVariables[envName] = command.Data;
|
context.EnvironmentVariables[envName] = command.Data;
|
||||||
context.SetEnvContext(envName, command.Data);
|
context.SetEnvContext(envName, command.Data);
|
||||||
|
context.Output(line);
|
||||||
context.Debug($"{envName}='{command.Data}'");
|
context.Debug($"{envName}='{command.Data}'");
|
||||||
|
omitEcho = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SetEnvCommandProperties
|
private static class SetEnvCommandProperties
|
||||||
@@ -201,11 +206,10 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class SetOutputCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class SetOutputCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "set-output";
|
public string Command => "set-output";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
if (!command.Properties.TryGetValue(SetOutputCommandProperties.Name, out string outputName) || string.IsNullOrEmpty(outputName))
|
if (!command.Properties.TryGetValue(SetOutputCommandProperties.Name, out string outputName) || string.IsNullOrEmpty(outputName))
|
||||||
{
|
{
|
||||||
@@ -213,7 +217,9 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.SetOutput(outputName, command.Data, out var reference);
|
context.SetOutput(outputName, command.Data, out var reference);
|
||||||
|
context.Output(line);
|
||||||
context.Debug($"{reference}='{command.Data}'");
|
context.Debug($"{reference}='{command.Data}'");
|
||||||
|
omitEcho = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SetOutputCommandProperties
|
private static class SetOutputCommandProperties
|
||||||
@@ -225,11 +231,10 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class SaveStateCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class SaveStateCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "save-state";
|
public string Command => "save-state";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
if (!command.Properties.TryGetValue(SaveStateCommandProperties.Name, out string stateName) || string.IsNullOrEmpty(stateName))
|
if (!command.Properties.TryGetValue(SaveStateCommandProperties.Name, out string stateName) || string.IsNullOrEmpty(stateName))
|
||||||
{
|
{
|
||||||
@@ -238,6 +243,7 @@ namespace GitHub.Runner.Worker
|
|||||||
|
|
||||||
context.IntraActionState[stateName] = command.Data;
|
context.IntraActionState[stateName] = command.Data;
|
||||||
context.Debug($"Save intra-action state {stateName} = {command.Data}");
|
context.Debug($"Save intra-action state {stateName} = {command.Data}");
|
||||||
|
omitEcho = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SaveStateCommandProperties
|
private static class SaveStateCommandProperties
|
||||||
@@ -249,53 +255,49 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class AddMaskCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class AddMaskCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "add-mask";
|
public string Command => "add-mask";
|
||||||
public bool OmitEcho => true;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(command.Data))
|
if (string.IsNullOrWhiteSpace(command.Data))
|
||||||
{
|
{
|
||||||
context.Warning("Can't add secret mask for empty string in ##[add-mask] command.");
|
context.Warning("Can't add secret mask for empty string.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (context.EchoOnActionCommand)
|
|
||||||
{
|
|
||||||
context.Output($"::{Command}::***");
|
|
||||||
}
|
|
||||||
|
|
||||||
HostContext.SecretMasker.AddValue(command.Data);
|
HostContext.SecretMasker.AddValue(command.Data);
|
||||||
Trace.Info($"Add new secret mask with length of {command.Data.Length}");
|
Trace.Info($"Add new secret mask with length of {command.Data.Length}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
omitEcho = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class AddPathCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class AddPathCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "add-path";
|
public string Command => "add-path";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
ArgUtil.NotNullOrEmpty(command.Data, "path");
|
ArgUtil.NotNullOrEmpty(command.Data, "path");
|
||||||
context.PrependPath.RemoveAll(x => string.Equals(x, command.Data, StringComparison.CurrentCulture));
|
context.PrependPath.RemoveAll(x => string.Equals(x, command.Data, StringComparison.CurrentCulture));
|
||||||
context.PrependPath.Add(command.Data);
|
context.PrependPath.Add(command.Data);
|
||||||
|
omitEcho = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class AddMatcherCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class AddMatcherCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "add-matcher";
|
public string Command => "add-matcher";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
|
omitEcho = false;
|
||||||
var file = command.Data;
|
var file = command.Data;
|
||||||
|
|
||||||
// File is required
|
// File is required
|
||||||
@@ -337,26 +339,26 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class RemoveMatcherCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class RemoveMatcherCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "remove-matcher";
|
public string Command => "remove-matcher";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
|
omitEcho = false;
|
||||||
command.Properties.TryGetValue(RemoveMatcherCommandProperties.Owner, out string owner);
|
command.Properties.TryGetValue(RemoveMatcherCommandProperties.Owner, out string owner);
|
||||||
var file = command.Data;
|
var file = command.Data;
|
||||||
|
|
||||||
// Owner and file are mutually exclusive
|
// Owner and file are mutually exclusive
|
||||||
if (!string.IsNullOrEmpty(owner) && !string.IsNullOrEmpty(file))
|
if (!string.IsNullOrEmpty(owner) && !string.IsNullOrEmpty(file))
|
||||||
{
|
{
|
||||||
context.Warning("Either specify an owner name or a file path in ##[remove-matcher] command. Both values cannot be set.");
|
context.Warning("Either specify a matcher owner name or a file path. Both values cannot be set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Owner or file is required
|
// Owner or file is required
|
||||||
if (string.IsNullOrEmpty(owner) && string.IsNullOrEmpty(file))
|
if (string.IsNullOrEmpty(owner) && string.IsNullOrEmpty(file))
|
||||||
{
|
{
|
||||||
context.Warning("Either an owner name or a file path must be specified in ##[remove-matcher] command.");
|
context.Warning("Either a matcher owner name or a file path must be specified.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,12 +407,12 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class DebugCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class DebugCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "debug";
|
public string Command => "debug";
|
||||||
public bool OmitEcho => true;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string inputLine, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string inputLine, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
|
omitEcho = true;
|
||||||
context.Debug(command.Data);
|
context.Debug(command.Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,12 +435,12 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
public abstract IssueType Type { get; }
|
public abstract IssueType Type { get; }
|
||||||
public abstract string Command { get; }
|
public abstract string Command { get; }
|
||||||
public bool OmitEcho => true;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string inputLine, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string inputLine, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
|
omitEcho = true;
|
||||||
command.Properties.TryGetValue(IssueCommandProperties.File, out string file);
|
command.Properties.TryGetValue(IssueCommandProperties.File, out string file);
|
||||||
command.Properties.TryGetValue(IssueCommandProperties.Line, out string line);
|
command.Properties.TryGetValue(IssueCommandProperties.Line, out string line);
|
||||||
command.Properties.TryGetValue(IssueCommandProperties.Column, out string column);
|
command.Properties.TryGetValue(IssueCommandProperties.Column, out string column);
|
||||||
@@ -513,41 +515,13 @@ namespace GitHub.Runner.Worker
|
|||||||
public abstract class GroupingCommandExtension : RunnerService, IActionCommandExtension
|
public abstract class GroupingCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public abstract string Command { get; }
|
public abstract string Command { get; }
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, out bool omitEcho)
|
||||||
{
|
{
|
||||||
var data = this is GroupCommandExtension ? command.Data : string.Empty;
|
var data = this is GroupCommandExtension ? command.Data : string.Empty;
|
||||||
context.Output($"##[{Command}]{data}");
|
context.Output($"##[{Command}]{data}");
|
||||||
}
|
omitEcho = true;
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class EchoCommandExtension : RunnerService, IActionCommandExtension
|
|
||||||
{
|
|
||||||
public string Command => "echo";
|
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
|
||||||
{
|
|
||||||
ArgUtil.NotNullOrEmpty(command.Data, "value");
|
|
||||||
|
|
||||||
switch (command.Data.Trim().ToUpperInvariant())
|
|
||||||
{
|
|
||||||
case "ON":
|
|
||||||
context.EchoOnActionCommand = true;
|
|
||||||
context.Debug("Setting echo command value to 'on'");
|
|
||||||
break;
|
|
||||||
case "OFF":
|
|
||||||
context.EchoOnActionCommand = false;
|
|
||||||
context.Debug("Setting echo command value to 'off'");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Exception($"Invalid echo command value. Possible values can be: 'on', 'off'. Current value is: '{command.Data}'.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,21 +94,7 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
postDisplayName = $"Post {this.DisplayName}";
|
postDisplayName = $"Post {this.DisplayName}";
|
||||||
}
|
}
|
||||||
|
ExecutionContext.RegisterPostJobAction(postDisplayName, handlerData.CleanupCondition, Action);
|
||||||
var repositoryReference = Action.Reference as RepositoryPathReference;
|
|
||||||
var pathString = string.IsNullOrEmpty(repositoryReference.Path) ? string.Empty : $"/{repositoryReference.Path}";
|
|
||||||
var repoString = string.IsNullOrEmpty(repositoryReference.Ref) ? $"{repositoryReference.Name}{pathString}" :
|
|
||||||
$"{repositoryReference.Name}{pathString}@{repositoryReference.Ref}";
|
|
||||||
|
|
||||||
ExecutionContext.Debug($"Register post job cleanup for action: {repoString}");
|
|
||||||
|
|
||||||
var actionRunner = HostContext.CreateService<IActionRunner>();
|
|
||||||
actionRunner.Action = Action;
|
|
||||||
actionRunner.Stage = ActionRunStage.Post;
|
|
||||||
actionRunner.Condition = handlerData.CleanupCondition;
|
|
||||||
actionRunner.DisplayName = postDisplayName;
|
|
||||||
|
|
||||||
ExecutionContext.RegisterPostJobStep($"{actionRunner.Action.Name}_post", actionRunner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IStepHost stepHost = HostContext.CreateService<IDefaultStepHost>();
|
IStepHost stepHost = HostContext.CreateService<IDefaultStepHost>();
|
||||||
|
|||||||
@@ -276,9 +276,7 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
return await ExecuteDockerCommandAsync(context, "exec", $"{options} {containerId} {command}", context.CancellationToken);
|
return await ExecuteDockerCommandAsync(context, "exec", $"{options} {containerId} {command}", context.CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously (method has async logic on only certain platforms)
|
|
||||||
public async Task<int> DockerExec(IExecutionContext context, string containerId, string options, string command, List<string> output)
|
public async Task<int> DockerExec(IExecutionContext context, string containerId, string options, string command, List<string> output)
|
||||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
|
||||||
{
|
{
|
||||||
ArgUtil.NotNull(output, nameof(output));
|
ArgUtil.NotNull(output, nameof(output));
|
||||||
|
|
||||||
@@ -339,9 +337,7 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
return ExecuteDockerCommandAsync(context, command, options, null, cancellationToken);
|
return ExecuteDockerCommandAsync(context, command, options, null, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously (method has async logic on only certain platforms)
|
|
||||||
private async Task<int> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options, IDictionary<string, string> environment, EventHandler<ProcessDataReceivedEventArgs> stdoutDataReceived, EventHandler<ProcessDataReceivedEventArgs> stderrDataReceived, CancellationToken cancellationToken = default(CancellationToken))
|
private async Task<int> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options, IDictionary<string, string> environment, EventHandler<ProcessDataReceivedEventArgs> stdoutDataReceived, EventHandler<ProcessDataReceivedEventArgs> stderrDataReceived, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
|
||||||
{
|
{
|
||||||
string arg = $"{command} {options}".Trim();
|
string arg = $"{command} {options}".Trim();
|
||||||
context.Command($"{DockerPath} {arg}");
|
context.Command($"{DockerPath} {arg}");
|
||||||
@@ -366,9 +362,7 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously (method has async logic on only certain platforms)
|
|
||||||
private async Task<int> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options, string workingDirectory, CancellationToken cancellationToken = default(CancellationToken))
|
private async Task<int> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options, string workingDirectory, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
|
||||||
{
|
{
|
||||||
string arg = $"{command} {options}".Trim();
|
string arg = $"{command} {options}".Trim();
|
||||||
context.Command($"{DockerPath} {arg}");
|
context.Command($"{DockerPath} {arg}");
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ using GitHub.Runner.Common;
|
|||||||
using GitHub.Runner.Sdk;
|
using GitHub.Runner.Sdk;
|
||||||
using GitHub.DistributedTask.Pipelines.ContextData;
|
using GitHub.DistributedTask.Pipelines.ContextData;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using GitHub.DistributedTask.Pipelines.ObjectTemplating;
|
|
||||||
|
|
||||||
namespace GitHub.Runner.Worker
|
namespace GitHub.Runner.Worker
|
||||||
{
|
{
|
||||||
@@ -39,14 +38,6 @@ namespace GitHub.Runner.Worker
|
|||||||
List<ContainerInfo> containers = data as List<ContainerInfo>;
|
List<ContainerInfo> containers = data as List<ContainerInfo>;
|
||||||
ArgUtil.NotNull(containers, nameof(containers));
|
ArgUtil.NotNull(containers, nameof(containers));
|
||||||
|
|
||||||
var postJobStep = new JobExtensionRunner(runAsync: this.StopContainersAsync,
|
|
||||||
condition: $"{PipelineTemplateConstants.Always}()",
|
|
||||||
displayName: "Stop containers",
|
|
||||||
data: data);
|
|
||||||
|
|
||||||
executionContext.Debug($"Register post job cleanup for stoping/deleting containers.");
|
|
||||||
executionContext.RegisterPostJobStep(nameof(StopContainersAsync), postJobStep);
|
|
||||||
|
|
||||||
// Check whether we are inside a container.
|
// Check whether we are inside a container.
|
||||||
// Our container feature requires to map working directory from host to the container.
|
// Our container feature requires to map working directory from host to the container.
|
||||||
// If we are already inside a container, we will not able to find out the real working direcotry path on the host.
|
// If we are already inside a container, we will not able to find out the real working direcotry path on the host.
|
||||||
|
|||||||
@@ -31,9 +31,7 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class DiagnosticLogManager : RunnerService, IDiagnosticLogManager
|
public sealed class DiagnosticLogManager : RunnerService, IDiagnosticLogManager
|
||||||
{
|
{
|
||||||
private static string DateTimeFormat = "yyyyMMdd-HHmmss";
|
private static string DateTimeFormat = "yyyyMMdd-HHmmss";
|
||||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously (method has async logic on only certain platforms)
|
|
||||||
public async Task UploadDiagnosticLogsAsync(IExecutionContext executionContext,
|
public async Task UploadDiagnosticLogsAsync(IExecutionContext executionContext,
|
||||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
|
||||||
IExecutionContext parentContext,
|
IExecutionContext parentContext,
|
||||||
Pipelines.AgentJobRequestMessage message,
|
Pipelines.AgentJobRequestMessage message,
|
||||||
DateTime jobStartTimeUtc)
|
DateTime jobStartTimeUtc)
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ using GitHub.Services.WebApi;
|
|||||||
using GitHub.DistributedTask.Pipelines;
|
using GitHub.DistributedTask.Pipelines;
|
||||||
using GitHub.DistributedTask.Pipelines.ContextData;
|
using GitHub.DistributedTask.Pipelines.ContextData;
|
||||||
using GitHub.DistributedTask.WebApi;
|
using GitHub.DistributedTask.WebApi;
|
||||||
|
using Pipelines = GitHub.DistributedTask.Pipelines;
|
||||||
|
using ObjectTemplating = GitHub.DistributedTask.ObjectTemplating;
|
||||||
using GitHub.Runner.Common.Util;
|
using GitHub.Runner.Common.Util;
|
||||||
using GitHub.Runner.Common;
|
using GitHub.Runner.Common;
|
||||||
using GitHub.Runner.Sdk;
|
using GitHub.Runner.Sdk;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using ObjectTemplating = GitHub.DistributedTask.ObjectTemplating;
|
|
||||||
using Pipelines = GitHub.DistributedTask.Pipelines;
|
|
||||||
|
|
||||||
namespace GitHub.Runner.Worker
|
namespace GitHub.Runner.Worker
|
||||||
{
|
{
|
||||||
@@ -62,8 +62,6 @@ namespace GitHub.Runner.Worker
|
|||||||
// Only job level ExecutionContext has PostJobSteps
|
// Only job level ExecutionContext has PostJobSteps
|
||||||
Stack<IStep> PostJobSteps { get; }
|
Stack<IStep> PostJobSteps { get; }
|
||||||
|
|
||||||
bool EchoOnActionCommand { get; set; }
|
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
void InitializeJob(Pipelines.AgentJobRequestMessage message, CancellationToken token);
|
void InitializeJob(Pipelines.AgentJobRequestMessage message, CancellationToken token);
|
||||||
void CancelToken();
|
void CancelToken();
|
||||||
@@ -98,7 +96,7 @@ namespace GitHub.Runner.Worker
|
|||||||
|
|
||||||
// others
|
// others
|
||||||
void ForceTaskComplete();
|
void ForceTaskComplete();
|
||||||
void RegisterPostJobStep(string refName, IStep step);
|
void RegisterPostJobAction(string displayName, string condition, Pipelines.ActionStep action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ExecutionContext : RunnerService, IExecutionContext
|
public sealed class ExecutionContext : RunnerService, IExecutionContext
|
||||||
@@ -155,8 +153,6 @@ namespace GitHub.Runner.Worker
|
|||||||
// Only job level ExecutionContext has PostJobSteps
|
// Only job level ExecutionContext has PostJobSteps
|
||||||
public Stack<IStep> PostJobSteps { get; private set; }
|
public Stack<IStep> PostJobSteps { get; private set; }
|
||||||
|
|
||||||
public bool EchoOnActionCommand { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public TaskResult? Result
|
public TaskResult? Result
|
||||||
{
|
{
|
||||||
@@ -240,10 +236,27 @@ namespace GitHub.Runner.Worker
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterPostJobStep(string refName, IStep step)
|
public void RegisterPostJobAction(string displayName, string condition, Pipelines.ActionStep action)
|
||||||
{
|
{
|
||||||
step.ExecutionContext = Root.CreatePostChild(step.DisplayName, refName, IntraActionState);
|
if (action.Reference.Type != ActionSourceType.Repository)
|
||||||
Root.PostJobSteps.Push(step);
|
{
|
||||||
|
throw new NotSupportedException("Only action that has `action.yml` can define post job execution.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var repositoryReference = action.Reference as RepositoryPathReference;
|
||||||
|
var pathString = string.IsNullOrEmpty(repositoryReference.Path) ? string.Empty : $"/{repositoryReference.Path}";
|
||||||
|
var repoString = string.IsNullOrEmpty(repositoryReference.Ref) ? $"{repositoryReference.Name}{pathString}" :
|
||||||
|
$"{repositoryReference.Name}{pathString}@{repositoryReference.Ref}";
|
||||||
|
|
||||||
|
this.Debug($"Register post job cleanup for action: {repoString}");
|
||||||
|
|
||||||
|
var actionRunner = HostContext.CreateService<IActionRunner>();
|
||||||
|
actionRunner.Action = action;
|
||||||
|
actionRunner.Stage = ActionRunStage.Post;
|
||||||
|
actionRunner.Condition = condition;
|
||||||
|
actionRunner.DisplayName = displayName;
|
||||||
|
actionRunner.ExecutionContext = Root.CreatePostChild(displayName, $"{actionRunner.Action.Name}_post", IntraActionState);
|
||||||
|
Root.PostJobSteps.Push(actionRunner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IExecutionContext CreateChild(Guid recordId, string displayName, string refName, string scopeName, string contextName, Dictionary<string, string> intraActionState = null, int? recordOrder = null)
|
public IExecutionContext CreateChild(Guid recordId, string displayName, string refName, string scopeName, string contextName, Dictionary<string, string> intraActionState = null, int? recordOrder = null)
|
||||||
@@ -279,7 +292,6 @@ namespace GitHub.Runner.Worker
|
|||||||
child.PrependPath = PrependPath;
|
child.PrependPath = PrependPath;
|
||||||
child.Container = Container;
|
child.Container = Container;
|
||||||
child.ServiceContainers = ServiceContainers;
|
child.ServiceContainers = ServiceContainers;
|
||||||
child.EchoOnActionCommand = EchoOnActionCommand;
|
|
||||||
|
|
||||||
if (recordOrder != null)
|
if (recordOrder != null)
|
||||||
{
|
{
|
||||||
@@ -692,9 +704,6 @@ namespace GitHub.Runner.Worker
|
|||||||
_logger = HostContext.CreateService<IPagingLogger>();
|
_logger = HostContext.CreateService<IPagingLogger>();
|
||||||
_logger.Setup(_mainTimelineId, _record.Id);
|
_logger.Setup(_mainTimelineId, _record.Id);
|
||||||
|
|
||||||
// Initialize 'echo on action command success' property, default to false, unless Step_Debug is set
|
|
||||||
EchoOnActionCommand = Variables.Step_Debug ?? false;
|
|
||||||
|
|
||||||
// Verbosity (from GitHub.Step_Debug).
|
// Verbosity (from GitHub.Step_Debug).
|
||||||
WriteDebug = Variables.Step_Debug ?? false;
|
WriteDebug = Variables.Step_Debug ?? false;
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,7 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
{
|
{
|
||||||
public ContainerActionExecutionData Data { get; set; }
|
public ContainerActionExecutionData Data { get; set; }
|
||||||
|
|
||||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously (method has async logic on only certain platforms)
|
|
||||||
public async Task RunAsync(ActionRunStage stage)
|
public async Task RunAsync(ActionRunStage stage)
|
||||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
|
||||||
{
|
{
|
||||||
// Validate args.
|
// Validate args.
|
||||||
Trace.Entering();
|
Trace.Entering();
|
||||||
|
|||||||
@@ -263,17 +263,15 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
// Root using fromPath
|
// Root using fromPath
|
||||||
if (!string.IsNullOrWhiteSpace(match.FromPath) && !Path.IsPathRooted(file))
|
if (!string.IsNullOrWhiteSpace(match.FromPath) && !Path.IsPathRooted(file))
|
||||||
{
|
{
|
||||||
var fromDirectory = Path.GetDirectoryName(match.FromPath);
|
file = Path.Combine(match.FromPath, file);
|
||||||
if (!string.IsNullOrWhiteSpace(fromDirectory))
|
|
||||||
{
|
|
||||||
file = Path.Combine(fromDirectory, file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Root using workspace
|
// Root using system.defaultWorkingDirectory
|
||||||
if (!Path.IsPathRooted(file))
|
if (!Path.IsPathRooted(file))
|
||||||
{
|
{
|
||||||
var workspace = _executionContext.GetGitHubContext("workspace");
|
var githubContext = _executionContext.ExpressionValues["github"] as GitHubContext;
|
||||||
|
ArgUtil.NotNull(githubContext, nameof(githubContext));
|
||||||
|
var workspace = githubContext["workspace"].ToString();
|
||||||
ArgUtil.NotNullOrEmpty(workspace, "workspace");
|
ArgUtil.NotNullOrEmpty(workspace, "workspace");
|
||||||
|
|
||||||
file = Path.Combine(workspace, file);
|
file = Path.Combine(workspace, file);
|
||||||
@@ -299,7 +297,7 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Prefer `/` on all platforms
|
// prefer `/` on all platforms
|
||||||
issue.Data["file"] = file.Substring(repositoryPath.Length).TrimStart(Path.DirectorySeparatorChar).Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
issue.Data["file"] = file.Substring(repositoryPath.Length).TrimStart(Path.DirectorySeparatorChar).Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,9 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build up 2 lists of steps, pre-job, job
|
// Build up 3 lists of steps, pre-job, job, post-job
|
||||||
|
var postJobStepsBuilder = new Stack<IStep>();
|
||||||
|
|
||||||
// Download actions not already in the cache
|
// Download actions not already in the cache
|
||||||
Trace.Info("Downloading actions");
|
Trace.Info("Downloading actions");
|
||||||
var actionManager = HostContext.GetService<IActionManager>();
|
var actionManager = HostContext.GetService<IActionManager>();
|
||||||
@@ -132,6 +134,10 @@ namespace GitHub.Runner.Worker
|
|||||||
condition: $"{PipelineTemplateConstants.Success}()",
|
condition: $"{PipelineTemplateConstants.Success}()",
|
||||||
displayName: "Initialize containers",
|
displayName: "Initialize containers",
|
||||||
data: (object)containers));
|
data: (object)containers));
|
||||||
|
postJobStepsBuilder.Push(new JobExtensionRunner(runAsync: containerProvider.StopContainersAsync,
|
||||||
|
condition: $"{PipelineTemplateConstants.Always}()",
|
||||||
|
displayName: "Stop containers",
|
||||||
|
data: (object)containers));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add action steps
|
// Add action steps
|
||||||
@@ -181,9 +187,33 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add post-job steps
|
||||||
|
Trace.Info("Adding post-job steps");
|
||||||
|
while (postJobStepsBuilder.Count > 0)
|
||||||
|
{
|
||||||
|
postJobSteps.Add(postJobStepsBuilder.Pop());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create execution context for post-job steps
|
||||||
|
foreach (var step in postJobSteps)
|
||||||
|
{
|
||||||
|
if (step is JobExtensionRunner)
|
||||||
|
{
|
||||||
|
JobExtensionRunner extensionStep = step as JobExtensionRunner;
|
||||||
|
ArgUtil.NotNull(extensionStep, extensionStep.DisplayName);
|
||||||
|
Guid stepId = Guid.NewGuid();
|
||||||
|
extensionStep.ExecutionContext = jobContext.CreateChild(stepId, extensionStep.DisplayName, stepId.ToString("N"), null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<IStep> steps = new List<IStep>();
|
List<IStep> steps = new List<IStep>();
|
||||||
steps.AddRange(preJobSteps);
|
steps.AddRange(preJobSteps);
|
||||||
steps.AddRange(jobSteps);
|
steps.AddRange(jobSteps);
|
||||||
|
steps.AddRange(postJobSteps);
|
||||||
|
|
||||||
|
// Start agent log plugin host process
|
||||||
|
// var logPlugin = HostContext.GetService<IAgentLogPlugin>();
|
||||||
|
// await logPlugin.StartAsync(context, steps, jobContext.CancellationToken);
|
||||||
|
|
||||||
// Prepare for orphan process cleanup
|
// Prepare for orphan process cleanup
|
||||||
_processCleanup = jobContext.Variables.GetBoolean("process.clean") ?? true;
|
_processCleanup = jobContext.Variables.GetBoolean("process.clean") ?? true;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
||||||
<NoWarn>NU1701;NU1603</NoWarn>
|
<NoWarn>NU1701;NU1603</NoWarn>
|
||||||
@@ -35,4 +35,42 @@
|
|||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
|
||||||
|
<DefineConstants>OS_OSX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' AND '$(Configuration)' == 'Debug'">
|
||||||
|
<DefineConstants>OS_OSX;DEBUG;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Text;
|
|||||||
using Minimatch;
|
using Minimatch;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using GitHub.DistributedTask.Expressions2.Sdk;
|
|
||||||
using GitHub.DistributedTask.Pipelines.ContextData;
|
using GitHub.DistributedTask.Pipelines.ContextData;
|
||||||
using GitHub.DistributedTask.Pipelines.ObjectTemplating;
|
using GitHub.DistributedTask.Pipelines.ObjectTemplating;
|
||||||
namespace GitHub.DistributedTask.Expressions2.Sdk.Functions
|
namespace GitHub.DistributedTask.Expressions2.Sdk.Functions
|
||||||
@@ -29,50 +28,29 @@ namespace GitHub.DistributedTask.Expressions2.Sdk.Functions
|
|||||||
string searchRoot = workspaceData.Value;
|
string searchRoot = workspaceData.Value;
|
||||||
string pattern = Parameters[0].Evaluate(context).ConvertToString();
|
string pattern = Parameters[0].Evaluate(context).ConvertToString();
|
||||||
|
|
||||||
// Convert slashes on Windows
|
|
||||||
if (s_isWindows)
|
|
||||||
{
|
|
||||||
pattern = pattern.Replace('\\', '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Root the pattern
|
|
||||||
if (!Path.IsPathRooted(pattern))
|
|
||||||
{
|
|
||||||
var patternRoot = s_isWindows ? searchRoot.Replace('\\', '/').TrimEnd('/') : searchRoot.TrimEnd('/');
|
|
||||||
pattern = string.Concat(patternRoot, "/", pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all files
|
|
||||||
context.Trace.Info($"Search root directory: '{searchRoot}'");
|
context.Trace.Info($"Search root directory: '{searchRoot}'");
|
||||||
context.Trace.Info($"Search pattern: '{pattern}'");
|
context.Trace.Info($"Search pattern: '{pattern}'");
|
||||||
var files = Directory.GetFiles(searchRoot, "*", SearchOption.AllDirectories)
|
var files = Directory.GetFiles(searchRoot, "*", SearchOption.AllDirectories).OrderBy(x => x).ToList();
|
||||||
.Select(x => s_isWindows ? x.Replace('\\', '/') : x)
|
|
||||||
.OrderBy(x => x, StringComparer.Ordinal)
|
|
||||||
.ToList();
|
|
||||||
if (files.Count == 0)
|
if (files.Count == 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"hashFiles('{ExpressionUtility.StringEscape(pattern)}') failed. Directory '{searchRoot}' is empty");
|
throw new ArgumentException($"'hashFiles({pattern})' failed. Directory '{searchRoot}' is empty");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
context.Trace.Info($"Found {files.Count} files");
|
context.Trace.Info($"Found {files.Count} files");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match
|
|
||||||
var matcher = new Minimatcher(pattern, s_minimatchOptions);
|
var matcher = new Minimatcher(pattern, s_minimatchOptions);
|
||||||
files = matcher.Filter(files)
|
files = matcher.Filter(files).ToList();
|
||||||
.Select(x => s_isWindows ? x.Replace('/', '\\') : x)
|
|
||||||
.ToList();
|
|
||||||
if (files.Count == 0)
|
if (files.Count == 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"hashFiles('{ExpressionUtility.StringEscape(pattern)}') failed. Search pattern '{pattern}' doesn't match any file under '{searchRoot}'");
|
throw new ArgumentException($"'hashFiles({pattern})' failed. Search pattern '{pattern}' doesn't match any file under '{searchRoot}'");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
context.Trace.Info($"{files.Count} matches to hash");
|
context.Trace.Info($"{files.Count} matches to hash");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash each file
|
|
||||||
List<byte> filesSha256 = new List<byte>();
|
List<byte> filesSha256 = new List<byte>();
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
@@ -86,7 +64,6 @@ namespace GitHub.DistributedTask.Expressions2.Sdk.Functions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash the hashes
|
|
||||||
using (SHA256 sha256hash = SHA256.Create())
|
using (SHA256 sha256hash = SHA256.Create())
|
||||||
{
|
{
|
||||||
var hashBytes = sha256hash.ComputeHash(filesSha256.ToArray());
|
var hashBytes = sha256hash.ComputeHash(filesSha256.ToArray());
|
||||||
@@ -106,17 +83,11 @@ namespace GitHub.DistributedTask.Expressions2.Sdk.Functions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly bool s_isWindows = Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX;
|
|
||||||
|
|
||||||
// Only support basic globbing (* ? and []) and globstar (**)
|
|
||||||
private static readonly Options s_minimatchOptions = new Options
|
private static readonly Options s_minimatchOptions = new Options
|
||||||
{
|
{
|
||||||
Dot = true,
|
Dot = true,
|
||||||
NoBrace = true,
|
NoBrace = true,
|
||||||
NoCase = s_isWindows,
|
NoCase = Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX
|
||||||
NoComment = true,
|
|
||||||
NoExt = true,
|
|
||||||
NoNegate = true,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
||||||
<NoWarn>NU1701;NU1603</NoWarn>
|
<NoWarn>NU1701;NU1603</NoWarn>
|
||||||
|
|||||||
@@ -397,11 +397,6 @@ namespace GitHub.Services.FileContainer.Client
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (IsFastFailResponse(response))
|
|
||||||
{
|
|
||||||
FileUploadTrace(itemPath, $"Chunk '{currentChunk}' attempt '{attempt}' of file '{itemPath}' received non-success status code {response.StatusCode} for sending request and cannot continue.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FileUploadTrace(itemPath, $"Chunk '{currentChunk}' attempt '{attempt}' of file '{itemPath}' received non-success status code {response.StatusCode} for sending request.");
|
FileUploadTrace(itemPath, $"Chunk '{currentChunk}' attempt '{attempt}' of file '{itemPath}' received non-success status code {response.StatusCode} for sending request.");
|
||||||
@@ -543,17 +538,6 @@ namespace GitHub.Services.FileContainer.Client
|
|||||||
cancellationToken);
|
cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsFastFailResponse(HttpResponseMessage response)
|
|
||||||
{
|
|
||||||
int statusCode = (int)response?.StatusCode;
|
|
||||||
return statusCode >= 400 && statusCode <= 499;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool ShouldThrowError(HttpResponseMessage response)
|
|
||||||
{
|
|
||||||
return !response.IsSuccessStatusCode && !IsFastFailResponse(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<HttpResponseMessage> ContainerGetRequestAsync(
|
private async Task<HttpResponseMessage> ContainerGetRequestAsync(
|
||||||
Int64 containerId,
|
Int64 containerId,
|
||||||
String itemPath,
|
String itemPath,
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Assert.
|
// Assert.
|
||||||
Assert.Equal("***", hc.SecretMasker.MaskSecrets("secret value 1"));
|
Assert.Equal(hc.SecretMasker.MaskSecrets("secret value 1"), "***");
|
||||||
Assert.Equal("***", hc.SecretMasker.MaskSecrets("secret value 2"));
|
Assert.Equal(hc.SecretMasker.MaskSecrets("secret value 2"), "***");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,9 +90,9 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
trace.Info("Args: {0}", clp.Args.Count);
|
trace.Info("Args: {0}", clp.Args.Count);
|
||||||
Assert.True(clp.Args.Count == 2);
|
Assert.True(clp.Args.Count == 2);
|
||||||
Assert.True(clp.Args.ContainsKey("arg1"));
|
Assert.True(clp.Args.ContainsKey("arg1"));
|
||||||
Assert.Equal("arg1val", clp.Args["arg1"]);
|
Assert.Equal(clp.Args["arg1"], "arg1val");
|
||||||
Assert.True(clp.Args.ContainsKey("arg2"));
|
Assert.True(clp.Args.ContainsKey("arg2"));
|
||||||
Assert.Equal("arg2val", clp.Args["arg2"]);
|
Assert.Equal(clp.Args["arg2"], "arg2val");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,8 +113,8 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
|
|
||||||
trace.Info("Args: {0}", clp.Flags.Count);
|
trace.Info("Args: {0}", clp.Flags.Count);
|
||||||
Assert.True(clp.Flags.Count == 2);
|
Assert.True(clp.Flags.Count == 2);
|
||||||
Assert.Contains("flag1", clp.Flags);
|
Assert.True(clp.Flags.Contains("flag1"));
|
||||||
Assert.Contains("flag2", clp.Flags);
|
Assert.True(clp.Flags.Contains("flag2"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
"win-x86",
|
"win-x86",
|
||||||
"linux-x64",
|
"linux-x64",
|
||||||
"linux-arm",
|
"linux-arm",
|
||||||
"linux-arm64",
|
|
||||||
"rhel.6-x64",
|
"rhel.6-x64",
|
||||||
"osx-x64"
|
"osx-x64"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ namespace GitHub.Runner.Common.Tests.Worker.Container
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(result0);
|
Assert.NotNull(result0);
|
||||||
Assert.Equal(0, result0.Count);
|
Assert.Equal(result0.Count, 0);
|
||||||
|
|
||||||
Assert.NotNull(result1);
|
Assert.NotNull(result1);
|
||||||
Assert.Equal(1, result1.Count);
|
Assert.Equal(result1.Count, 1);
|
||||||
var result1Port80Mapping = result1.Find(pm =>
|
var result1Port80Mapping = result1.Find(pm =>
|
||||||
string.Equals(pm.ContainerPort, "80") &&
|
string.Equals(pm.ContainerPort, "80") &&
|
||||||
string.Equals(pm.HostPort, "32881") &&
|
string.Equals(pm.HostPort, "32881") &&
|
||||||
@@ -48,10 +48,10 @@ namespace GitHub.Runner.Common.Tests.Worker.Container
|
|||||||
Assert.NotNull(result1Port80Mapping);
|
Assert.NotNull(result1Port80Mapping);
|
||||||
|
|
||||||
Assert.NotNull(result1Empty);
|
Assert.NotNull(result1Empty);
|
||||||
Assert.Equal(0, result1Empty.Count);
|
Assert.Equal(result1Empty.Count, 0);
|
||||||
|
|
||||||
Assert.NotNull(result2);
|
Assert.NotNull(result2);
|
||||||
Assert.Equal(2, result2.Count);
|
Assert.Equal(result2.Count, 2);
|
||||||
var result2Port80Mapping = result2.Find(pm =>
|
var result2Port80Mapping = result2.Find(pm =>
|
||||||
string.Equals(pm.ContainerPort, "80") &&
|
string.Equals(pm.ContainerPort, "80") &&
|
||||||
string.Equals(pm.HostPort, "32881") &&
|
string.Equals(pm.HostPort, "32881") &&
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Setup([CallerMemberName] string testName = "")
|
public void Setup([CallerMemberName] string testName = "")
|
||||||
{
|
{
|
||||||
_tokenSource = new CancellationTokenSource();
|
_tokenSource = new CancellationTokenSource();
|
||||||
_hc = new HostContext(
|
_hc = new HostContext(
|
||||||
@@ -115,7 +115,7 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
logFile: Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), $"trace_{nameof(HostContextL0)}_{testName}.log"));
|
logFile: Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), $"trace_{nameof(HostContextL0)}_{testName}.log"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Teardown()
|
public void Teardown()
|
||||||
{
|
{
|
||||||
_hc?.Dispose();
|
_hc?.Dispose();
|
||||||
_tokenSource?.Dispose();
|
_tokenSource?.Dispose();
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
// Assert.
|
// Assert.
|
||||||
Assert.Equal("some agent", actual);
|
Assert.Equal("some agent", actual);
|
||||||
Assert.Equal(string.Empty, Environment.GetEnvironmentVariable("ACTIONS_RUNNER_INPUT_AGENT") ?? string.Empty); // Should remove.
|
Assert.Equal(string.Empty, Environment.GetEnvironmentVariable("ACTIONS_RUNNER_INPUT_AGENT") ?? string.Empty); // Should remove.
|
||||||
Assert.Equal("some agent", hc.SecretMasker.MaskSecrets("some agent"));
|
Assert.Equal(hc.SecretMasker.MaskSecrets("some agent"), "some agent");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -80,7 +80,7 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
// Assert.
|
// Assert.
|
||||||
Assert.Equal("some secret token value", actual);
|
Assert.Equal("some secret token value", actual);
|
||||||
Assert.Equal(string.Empty, Environment.GetEnvironmentVariable("ACTIONS_RUNNER_INPUT_TOKEN") ?? string.Empty); // Should remove.
|
Assert.Equal(string.Empty, Environment.GetEnvironmentVariable("ACTIONS_RUNNER_INPUT_TOKEN") ?? string.Empty); // Should remove.
|
||||||
Assert.Equal("***", hc.SecretMasker.MaskSecrets("some secret token value"));
|
Assert.Equal(hc.SecretMasker.MaskSecrets("some secret token value"), "***");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -250,7 +250,7 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
bool actual = command.Unattended;
|
bool actual = command.Unattended;
|
||||||
|
|
||||||
// Assert.
|
// Assert.
|
||||||
Assert.True(actual);
|
Assert.Equal(true, actual);
|
||||||
Assert.Equal(string.Empty, Environment.GetEnvironmentVariable("ACTIONS_RUNNER_INPUT_UNATTENDED") ?? string.Empty); // Should remove.
|
Assert.Equal(string.Empty, Environment.GetEnvironmentVariable("ACTIONS_RUNNER_INPUT_UNATTENDED") ?? string.Empty); // Should remove.
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -720,7 +720,7 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
var command = new CommandSettings(hc, args: new string[] { "badcommand" });
|
var command = new CommandSettings(hc, args: new string[] { "badcommand" });
|
||||||
|
|
||||||
// Assert.
|
// Assert.
|
||||||
Assert.Contains("badcommand", command.Validate());
|
Assert.True(command.Validate().Contains("badcommand"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,7 +735,7 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
var command = new CommandSettings(hc, args: new string[] { "--badflag" });
|
var command = new CommandSettings(hc, args: new string[] { "--badflag" });
|
||||||
|
|
||||||
// Assert.
|
// Assert.
|
||||||
Assert.Contains("badflag", command.Validate());
|
Assert.True(command.Validate().Contains("badflag"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,7 +750,7 @@ namespace GitHub.Runner.Common.Tests
|
|||||||
var command = new CommandSettings(hc, args: new string[] { "--badargname", "bad arg value" });
|
var command = new CommandSettings(hc, args: new string[] { "--badargname", "bad arg value" });
|
||||||
|
|
||||||
// Assert.
|
// Assert.
|
||||||
Assert.Contains("badargname", command.Validate());
|
Assert.True(command.Validate().Contains("badargname"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
|
|||||||
private string _expectedServerUrl = "https://localhost";
|
private string _expectedServerUrl = "https://localhost";
|
||||||
private string _expectedAgentName = "expectedAgentName";
|
private string _expectedAgentName = "expectedAgentName";
|
||||||
private string _expectedPoolName = "poolName";
|
private string _expectedPoolName = "poolName";
|
||||||
|
private string _expectedCollectionName = "testCollectionName";
|
||||||
|
private string _expectedProjectName = "testProjectName";
|
||||||
|
private string _expectedProjectId = "edf3f94e-d251-49df-bfce-602d6c967409";
|
||||||
|
private string _expectedMachineGroupName = "testMachineGroupName";
|
||||||
private string _expectedAuthType = "pat";
|
private string _expectedAuthType = "pat";
|
||||||
private string _expectedWorkFolder = "_work";
|
private string _expectedWorkFolder = "_work";
|
||||||
private int _expectedPoolId = 1;
|
private int _expectedPoolId = 1;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace GitHub.Runner.Common.Tests.Listener
|
|||||||
string line;
|
string line;
|
||||||
while ((line = freader.ReadLine()) != null)
|
while ((line = freader.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
Assert.EndsWith(LogData, line);
|
Assert.True(line.EndsWith(LogData));
|
||||||
bytesWritten += logDataSize;
|
bytesWritten += logDataSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ namespace GitHub.Runner.Common.Tests.Util
|
|||||||
var connect = VssUtil.CreateConnection(new Uri("https://github.com/actions/runner"), new VssCredentials());
|
var connect = VssUtil.CreateConnection(new Uri("https://github.com/actions/runner"), new VssCredentials());
|
||||||
|
|
||||||
// Assert.
|
// Assert.
|
||||||
Assert.Equal("10", connect.Settings.MaxRetryRequest.ToString());
|
Assert.Equal(connect.Settings.MaxRetryRequest.ToString(), "10");
|
||||||
Assert.Equal("360", connect.Settings.SendTimeout.TotalSeconds.ToString());
|
Assert.Equal(connect.Settings.SendTimeout.TotalSeconds.ToString(), "360");
|
||||||
|
|
||||||
trace.Info("Set httpretry to 100.");
|
trace.Info("Set httpretry to 100.");
|
||||||
Environment.SetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_HTTP_RETRY", "100");
|
Environment.SetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_HTTP_RETRY", "100");
|
||||||
@@ -42,8 +42,8 @@ namespace GitHub.Runner.Common.Tests.Util
|
|||||||
connect = VssUtil.CreateConnection(new Uri("https://github.com/actions/runner"), new VssCredentials());
|
connect = VssUtil.CreateConnection(new Uri("https://github.com/actions/runner"), new VssCredentials());
|
||||||
|
|
||||||
// Assert.
|
// Assert.
|
||||||
Assert.Equal("10", connect.Settings.MaxRetryRequest.ToString());
|
Assert.Equal(connect.Settings.MaxRetryRequest.ToString(), "10");
|
||||||
Assert.Equal("1200", connect.Settings.SendTimeout.TotalSeconds.ToString());
|
Assert.Equal(connect.Settings.SendTimeout.TotalSeconds.ToString(), "1200");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using GitHub.DistributedTask.WebApi;
|
|||||||
using GitHub.Runner.Worker;
|
using GitHub.Runner.Worker;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Pipelines = GitHub.DistributedTask.Pipelines;
|
|
||||||
|
|
||||||
namespace GitHub.Runner.Common.Tests.Worker
|
namespace GitHub.Runner.Common.Tests.Worker
|
||||||
{
|
{
|
||||||
@@ -147,159 +146,5 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
Assert.True(commandManager.TryProcessCommand(_ec.Object, "##[set-env name=foo]bar"));
|
Assert.True(commandManager.TryProcessCommand(_ec.Object, "##[set-env name=foo]bar"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void EchoProcessCommand()
|
|
||||||
{
|
|
||||||
using (TestHostContext _hc = new TestHostContext(this))
|
|
||||||
{
|
|
||||||
var extensionManager = new Mock<IExtensionManager>();
|
|
||||||
var echoCommand = new EchoCommandExtension();
|
|
||||||
echoCommand.Initialize(_hc);
|
|
||||||
|
|
||||||
extensionManager.Setup(x => x.GetExtensions<IActionCommandExtension>())
|
|
||||||
.Returns(new List<IActionCommandExtension>() { echoCommand });
|
|
||||||
_hc.SetSingleton<IExtensionManager>(extensionManager.Object);
|
|
||||||
|
|
||||||
Mock<IExecutionContext> _ec = new Mock<IExecutionContext>();
|
|
||||||
_ec.Setup(x => x.Write(It.IsAny<string>(), It.IsAny<string>()))
|
|
||||||
.Returns((string tag, string line) =>
|
|
||||||
{
|
|
||||||
_hc.GetTrace().Info($"{tag} {line}");
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
_ec.SetupAllProperties();
|
|
||||||
|
|
||||||
ActionCommandManager commandManager = new ActionCommandManager();
|
|
||||||
commandManager.Initialize(_hc);
|
|
||||||
|
|
||||||
Assert.False(_ec.Object.EchoOnActionCommand);
|
|
||||||
|
|
||||||
Assert.True(commandManager.TryProcessCommand(_ec.Object, "::echo::on"));
|
|
||||||
Assert.True(_ec.Object.EchoOnActionCommand);
|
|
||||||
|
|
||||||
Assert.True(commandManager.TryProcessCommand(_ec.Object, "::echo::off"));
|
|
||||||
Assert.False(_ec.Object.EchoOnActionCommand);
|
|
||||||
|
|
||||||
Assert.True(commandManager.TryProcessCommand(_ec.Object, "::echo::ON"));
|
|
||||||
Assert.True(_ec.Object.EchoOnActionCommand);
|
|
||||||
|
|
||||||
Assert.True(commandManager.TryProcessCommand(_ec.Object, "::echo::Off "));
|
|
||||||
Assert.False(_ec.Object.EchoOnActionCommand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void EchoProcessCommandDebugOn()
|
|
||||||
{
|
|
||||||
using (TestHostContext _hc = new TestHostContext(this))
|
|
||||||
{
|
|
||||||
// Set up a few things
|
|
||||||
// 1. Job request message (with ACTIONS_STEP_DEBUG = true)
|
|
||||||
TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference();
|
|
||||||
TimelineReference timeline = new TimelineReference();
|
|
||||||
JobEnvironment environment = new JobEnvironment();
|
|
||||||
environment.SystemConnection = new ServiceEndpoint();
|
|
||||||
List<TaskInstance> tasks = new List<TaskInstance>();
|
|
||||||
Guid JobId = Guid.NewGuid();
|
|
||||||
string jobName = "some job name";
|
|
||||||
var jobRequest = Pipelines.AgentJobRequestMessageUtil.Convert(new AgentJobRequestMessage(plan, timeline, JobId, jobName, jobName, environment, tasks));
|
|
||||||
jobRequest.Resources.Repositories.Add(new Pipelines.RepositoryResource()
|
|
||||||
{
|
|
||||||
Alias = Pipelines.PipelineConstants.SelfAlias,
|
|
||||||
Id = "github",
|
|
||||||
Version = "sha1"
|
|
||||||
});
|
|
||||||
jobRequest.ContextData["github"] = new Pipelines.ContextData.DictionaryContextData();
|
|
||||||
jobRequest.Variables["ACTIONS_STEP_DEBUG"] = "true";
|
|
||||||
|
|
||||||
// Some service dependencies
|
|
||||||
var jobServerQueue = new Mock<IJobServerQueue>();
|
|
||||||
jobServerQueue.Setup(x => x.QueueTimelineRecordUpdate(It.IsAny<Guid>(), It.IsAny<TimelineRecord>()));
|
|
||||||
|
|
||||||
_hc.SetSingleton(jobServerQueue.Object);
|
|
||||||
|
|
||||||
var extensionManager = new Mock<IExtensionManager>();
|
|
||||||
var echoCommand = new EchoCommandExtension();
|
|
||||||
echoCommand.Initialize(_hc);
|
|
||||||
|
|
||||||
extensionManager.Setup(x => x.GetExtensions<IActionCommandExtension>())
|
|
||||||
.Returns(new List<IActionCommandExtension>() { echoCommand });
|
|
||||||
_hc.SetSingleton<IExtensionManager>(extensionManager.Object);
|
|
||||||
|
|
||||||
var configurationStore = new Mock<IConfigurationStore>();
|
|
||||||
configurationStore.Setup(x => x.GetSettings()).Returns(new RunnerSettings());
|
|
||||||
_hc.SetSingleton(configurationStore.Object);
|
|
||||||
|
|
||||||
var pagingLogger = new Mock<IPagingLogger>();
|
|
||||||
_hc.EnqueueInstance(pagingLogger.Object);
|
|
||||||
|
|
||||||
ActionCommandManager commandManager = new ActionCommandManager();
|
|
||||||
commandManager.Initialize(_hc);
|
|
||||||
|
|
||||||
var _ec = new Runner.Worker.ExecutionContext();
|
|
||||||
_ec.Initialize(_hc);
|
|
||||||
|
|
||||||
// Initialize the job (to exercise logic that sets EchoOnActionCommand)
|
|
||||||
_ec.InitializeJob(jobRequest, System.Threading.CancellationToken.None);
|
|
||||||
|
|
||||||
_ec.Complete();
|
|
||||||
|
|
||||||
Assert.True(_ec.EchoOnActionCommand);
|
|
||||||
|
|
||||||
Assert.True(commandManager.TryProcessCommand(_ec, "::echo::off"));
|
|
||||||
Assert.False(_ec.EchoOnActionCommand);
|
|
||||||
|
|
||||||
Assert.True(commandManager.TryProcessCommand(_ec, "::echo::on"));
|
|
||||||
Assert.True(_ec.EchoOnActionCommand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void EchoProcessCommandInvalid()
|
|
||||||
{
|
|
||||||
using (TestHostContext _hc = new TestHostContext(this))
|
|
||||||
{
|
|
||||||
var extensionManager = new Mock<IExtensionManager>();
|
|
||||||
var echoCommand = new EchoCommandExtension();
|
|
||||||
echoCommand.Initialize(_hc);
|
|
||||||
|
|
||||||
extensionManager.Setup(x => x.GetExtensions<IActionCommandExtension>())
|
|
||||||
.Returns(new List<IActionCommandExtension>() { echoCommand });
|
|
||||||
_hc.SetSingleton<IExtensionManager>(extensionManager.Object);
|
|
||||||
|
|
||||||
Mock<IExecutionContext> _ec = new Mock<IExecutionContext>();
|
|
||||||
_ec.Setup(x => x.Write(It.IsAny<string>(), It.IsAny<string>()))
|
|
||||||
.Returns((string tag, string line) =>
|
|
||||||
{
|
|
||||||
_hc.GetTrace().Info($"{tag} {line}");
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
_ec.SetupAllProperties();
|
|
||||||
|
|
||||||
ActionCommandManager commandManager = new ActionCommandManager();
|
|
||||||
commandManager.Initialize(_hc);
|
|
||||||
|
|
||||||
// Echo commands below are considered "processed", but are invalid
|
|
||||||
// 1. Invalid echo value
|
|
||||||
Assert.True(commandManager.TryProcessCommand(_ec.Object, "::echo::invalid"));
|
|
||||||
Assert.Equal(TaskResult.Failed, _ec.Object.CommandResult);
|
|
||||||
Assert.False(_ec.Object.EchoOnActionCommand);
|
|
||||||
|
|
||||||
// 2. No value
|
|
||||||
Assert.True(commandManager.TryProcessCommand(_ec.Object, "::echo::"));
|
|
||||||
Assert.Equal(TaskResult.Failed, _ec.Object.CommandResult);
|
|
||||||
Assert.False(_ec.Object.EchoOnActionCommand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,25 +37,25 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
|
|
||||||
Assert.Equal("Hello World", result.Name);
|
Assert.Equal(result.Name, "Hello World");
|
||||||
Assert.Equal("Greet the world and record the time", result.Description);
|
Assert.Equal(result.Description, "Greet the world and record the time");
|
||||||
Assert.Equal(2, result.Inputs.Count);
|
Assert.Equal(result.Inputs.Count, 2);
|
||||||
Assert.Equal("greeting", result.Inputs[0].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[0].Key.AssertString("key").Value, "greeting");
|
||||||
Assert.Equal("Hello", result.Inputs[0].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[0].Value.AssertString("value").Value, "Hello");
|
||||||
Assert.Equal("entryPoint", result.Inputs[1].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[1].Key.AssertString("key").Value, "entryPoint");
|
||||||
Assert.Equal("", result.Inputs[1].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[1].Value.AssertString("value").Value, "");
|
||||||
|
|
||||||
Assert.Equal(ActionExecutionType.Container, result.Execution.ExecutionType);
|
Assert.Equal(result.Execution.ExecutionType, ActionExecutionType.Container);
|
||||||
|
|
||||||
var containerAction = result.Execution as ContainerActionExecutionData;
|
var containerAction = result.Execution as ContainerActionExecutionData;
|
||||||
|
|
||||||
Assert.Equal("Dockerfile", containerAction.Image);
|
Assert.Equal(containerAction.Image, "Dockerfile");
|
||||||
Assert.Equal("main.sh", containerAction.EntryPoint);
|
Assert.Equal(containerAction.EntryPoint, "main.sh");
|
||||||
Assert.Equal("bzz", containerAction.Arguments[0].ToString());
|
Assert.Equal(containerAction.Arguments[0].ToString(), "bzz");
|
||||||
Assert.Equal("Token", containerAction.Environment[0].Key.ToString());
|
Assert.Equal(containerAction.Environment[0].Key.ToString(), "Token");
|
||||||
Assert.Equal("foo", containerAction.Environment[0].Value.ToString());
|
Assert.Equal(containerAction.Environment[0].Value.ToString(), "foo");
|
||||||
Assert.Equal("Url", containerAction.Environment[1].Key.ToString());
|
Assert.Equal(containerAction.Environment[1].Key.ToString(), "Url");
|
||||||
Assert.Equal("bar", containerAction.Environment[1].Value.ToString());
|
Assert.Equal(containerAction.Environment[1].Value.ToString(), "bar");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -81,27 +81,27 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
|
|
||||||
Assert.Equal("Hello World", result.Name);
|
Assert.Equal(result.Name, "Hello World");
|
||||||
Assert.Equal("Greet the world and record the time", result.Description);
|
Assert.Equal(result.Description, "Greet the world and record the time");
|
||||||
Assert.Equal(2, result.Inputs.Count);
|
Assert.Equal(result.Inputs.Count, 2);
|
||||||
Assert.Equal("greeting", result.Inputs[0].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[0].Key.AssertString("key").Value, "greeting");
|
||||||
Assert.Equal("Hello", result.Inputs[0].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[0].Value.AssertString("value").Value, "Hello");
|
||||||
Assert.Equal("entryPoint", result.Inputs[1].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[1].Key.AssertString("key").Value, "entryPoint");
|
||||||
Assert.Equal("", result.Inputs[1].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[1].Value.AssertString("value").Value, "");
|
||||||
|
|
||||||
Assert.Equal(ActionExecutionType.Container, result.Execution.ExecutionType);
|
Assert.Equal(result.Execution.ExecutionType, ActionExecutionType.Container);
|
||||||
|
|
||||||
var containerAction = result.Execution as ContainerActionExecutionData;
|
var containerAction = result.Execution as ContainerActionExecutionData;
|
||||||
|
|
||||||
Assert.Equal("Dockerfile", containerAction.Image);
|
Assert.Equal(containerAction.Image, "Dockerfile");
|
||||||
Assert.Equal("main.sh", containerAction.EntryPoint);
|
Assert.Equal(containerAction.EntryPoint, "main.sh");
|
||||||
Assert.Equal("cleanup.sh", containerAction.Cleanup);
|
Assert.Equal(containerAction.Cleanup, "cleanup.sh");
|
||||||
Assert.Equal("failure()", containerAction.CleanupCondition);
|
Assert.Equal(containerAction.CleanupCondition, "failure()");
|
||||||
Assert.Equal("bzz", containerAction.Arguments[0].ToString());
|
Assert.Equal(containerAction.Arguments[0].ToString(), "bzz");
|
||||||
Assert.Equal("Token", containerAction.Environment[0].Key.ToString());
|
Assert.Equal(containerAction.Environment[0].Key.ToString(), "Token");
|
||||||
Assert.Equal("foo", containerAction.Environment[0].Value.ToString());
|
Assert.Equal(containerAction.Environment[0].Value.ToString(), "foo");
|
||||||
Assert.Equal("Url", containerAction.Environment[1].Key.ToString());
|
Assert.Equal(containerAction.Environment[1].Key.ToString(), "Url");
|
||||||
Assert.Equal("bar", containerAction.Environment[1].Value.ToString());
|
Assert.Equal(containerAction.Environment[1].Value.ToString(), "bar");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -126,19 +126,19 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "dockerfileaction_noargs_noenv_noentrypoint.yml"));
|
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "dockerfileaction_noargs_noenv_noentrypoint.yml"));
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("Hello World", result.Name);
|
Assert.Equal(result.Name, "Hello World");
|
||||||
Assert.Equal("Greet the world and record the time", result.Description);
|
Assert.Equal(result.Description, "Greet the world and record the time");
|
||||||
Assert.Equal(2, result.Inputs.Count);
|
Assert.Equal(result.Inputs.Count, 2);
|
||||||
Assert.Equal("greeting", result.Inputs[0].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[0].Key.AssertString("key").Value, "greeting");
|
||||||
Assert.Equal("Hello", result.Inputs[0].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[0].Value.AssertString("value").Value, "Hello");
|
||||||
Assert.Equal("entryPoint", result.Inputs[1].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[1].Key.AssertString("key").Value, "entryPoint");
|
||||||
Assert.Equal("", result.Inputs[1].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[1].Value.AssertString("value").Value, "");
|
||||||
|
|
||||||
Assert.Equal(ActionExecutionType.Container, result.Execution.ExecutionType);
|
Assert.Equal(result.Execution.ExecutionType, ActionExecutionType.Container);
|
||||||
|
|
||||||
var containerAction = result.Execution as ContainerActionExecutionData;
|
var containerAction = result.Execution as ContainerActionExecutionData;
|
||||||
|
|
||||||
Assert.Equal("Dockerfile", containerAction.Image);
|
Assert.Equal(containerAction.Image, "Dockerfile");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -164,25 +164,25 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
|
|
||||||
Assert.Equal("Hello World", result.Name);
|
Assert.Equal(result.Name, "Hello World");
|
||||||
Assert.Equal("Greet the world and record the time", result.Description);
|
Assert.Equal(result.Description, "Greet the world and record the time");
|
||||||
Assert.Equal(2, result.Inputs.Count);
|
Assert.Equal(result.Inputs.Count, 2);
|
||||||
Assert.Equal("greeting", result.Inputs[0].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[0].Key.AssertString("key").Value, "greeting");
|
||||||
Assert.Equal("Hello", result.Inputs[0].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[0].Value.AssertString("value").Value, "Hello");
|
||||||
Assert.Equal("entryPoint", result.Inputs[1].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[1].Key.AssertString("key").Value, "entryPoint");
|
||||||
Assert.Equal("", result.Inputs[1].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[1].Value.AssertString("value").Value, "");
|
||||||
|
|
||||||
Assert.Equal(ActionExecutionType.Container, result.Execution.ExecutionType);
|
Assert.Equal(result.Execution.ExecutionType, ActionExecutionType.Container);
|
||||||
|
|
||||||
var containerAction = result.Execution as ContainerActionExecutionData;
|
var containerAction = result.Execution as ContainerActionExecutionData;
|
||||||
|
|
||||||
Assert.Equal("Dockerfile", containerAction.Image);
|
Assert.Equal(containerAction.Image, "Dockerfile");
|
||||||
Assert.Equal("main.sh", containerAction.EntryPoint);
|
Assert.Equal(containerAction.EntryPoint, "main.sh");
|
||||||
Assert.Equal("${{ inputs.greeting }}", containerAction.Arguments[0].ToString());
|
Assert.Equal(containerAction.Arguments[0].ToString(), "${{ inputs.greeting }}");
|
||||||
Assert.Equal("Token", containerAction.Environment[0].Key.ToString());
|
Assert.Equal(containerAction.Environment[0].Key.ToString(), "Token");
|
||||||
Assert.Equal("foo", containerAction.Environment[0].Value.ToString());
|
Assert.Equal(containerAction.Environment[0].Value.ToString(), "foo");
|
||||||
Assert.Equal("Url", containerAction.Environment[1].Key.ToString());
|
Assert.Equal(containerAction.Environment[1].Key.ToString(), "Url");
|
||||||
Assert.Equal("${{ inputs.entryPoint }}", containerAction.Environment[1].Value.ToString());
|
Assert.Equal(containerAction.Environment[1].Value.ToString(), "${{ inputs.entryPoint }}");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -207,25 +207,25 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "dockerhubaction.yml"));
|
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "dockerhubaction.yml"));
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("Hello World", result.Name);
|
Assert.Equal(result.Name, "Hello World");
|
||||||
Assert.Equal("Greet the world and record the time", result.Description);
|
Assert.Equal(result.Description, "Greet the world and record the time");
|
||||||
Assert.Equal(2, result.Inputs.Count);
|
Assert.Equal(result.Inputs.Count, 2);
|
||||||
Assert.Equal("greeting", result.Inputs[0].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[0].Key.AssertString("key").Value, "greeting");
|
||||||
Assert.Equal("Hello", result.Inputs[0].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[0].Value.AssertString("value").Value, "Hello");
|
||||||
Assert.Equal("entryPoint", result.Inputs[1].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[1].Key.AssertString("key").Value, "entryPoint");
|
||||||
Assert.Equal("", result.Inputs[1].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[1].Value.AssertString("value").Value, "");
|
||||||
|
|
||||||
Assert.Equal(ActionExecutionType.Container, result.Execution.ExecutionType);
|
Assert.Equal(result.Execution.ExecutionType, ActionExecutionType.Container);
|
||||||
|
|
||||||
var containerAction = result.Execution as ContainerActionExecutionData;
|
var containerAction = result.Execution as ContainerActionExecutionData;
|
||||||
|
|
||||||
Assert.Equal("docker://ubuntu:18.04", containerAction.Image);
|
Assert.Equal(containerAction.Image, "docker://ubuntu:18.04");
|
||||||
Assert.Equal("main.sh", containerAction.EntryPoint);
|
Assert.Equal(containerAction.EntryPoint, "main.sh");
|
||||||
Assert.Equal("bzz", containerAction.Arguments[0].ToString());
|
Assert.Equal(containerAction.Arguments[0].ToString(), "bzz");
|
||||||
Assert.Equal("Token", containerAction.Environment[0].Key.ToString());
|
Assert.Equal(containerAction.Environment[0].Key.ToString(), "Token");
|
||||||
Assert.Equal("foo", containerAction.Environment[0].Value.ToString());
|
Assert.Equal(containerAction.Environment[0].Value.ToString(), "foo");
|
||||||
Assert.Equal("Url", containerAction.Environment[1].Key.ToString());
|
Assert.Equal(containerAction.Environment[1].Key.ToString(), "Url");
|
||||||
Assert.Equal("bar", containerAction.Environment[1].Value.ToString());
|
Assert.Equal(containerAction.Environment[1].Value.ToString(), "bar");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -250,24 +250,24 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "nodeaction.yml"));
|
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "nodeaction.yml"));
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("Hello World", result.Name);
|
Assert.Equal(result.Name, "Hello World");
|
||||||
Assert.Equal("Greet the world and record the time", result.Description);
|
Assert.Equal(result.Description, "Greet the world and record the time");
|
||||||
Assert.Equal(2, result.Inputs.Count);
|
Assert.Equal(result.Inputs.Count, 2);
|
||||||
Assert.Equal("greeting", result.Inputs[0].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[0].Key.AssertString("key").Value, "greeting");
|
||||||
Assert.Equal("Hello", result.Inputs[0].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[0].Value.AssertString("value").Value, "Hello");
|
||||||
Assert.Equal("entryPoint", result.Inputs[1].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[1].Key.AssertString("key").Value, "entryPoint");
|
||||||
Assert.Equal("", result.Inputs[1].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[1].Value.AssertString("value").Value, "");
|
||||||
Assert.Equal(1, result.Deprecated.Count);
|
Assert.Equal(result.Deprecated.Count, 1);
|
||||||
|
|
||||||
Assert.True(result.Deprecated.ContainsKey("greeting"));
|
Assert.True(result.Deprecated.ContainsKey("greeting"));
|
||||||
result.Deprecated.TryGetValue("greeting", out string value);
|
result.Deprecated.TryGetValue("greeting", out string value);
|
||||||
Assert.Equal("This property has been deprecated", value);
|
Assert.Equal(value, "This property has been deprecated");
|
||||||
|
|
||||||
Assert.Equal(ActionExecutionType.NodeJS, result.Execution.ExecutionType);
|
Assert.Equal(result.Execution.ExecutionType, ActionExecutionType.NodeJS);
|
||||||
|
|
||||||
var nodeAction = result.Execution as NodeJSActionExecutionData;
|
var nodeAction = result.Execution as NodeJSActionExecutionData;
|
||||||
|
|
||||||
Assert.Equal("main.js", nodeAction.Script);
|
Assert.Equal(nodeAction.Script, "main.js");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -292,26 +292,26 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "nodeaction_cleanup.yml"));
|
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "nodeaction_cleanup.yml"));
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("Hello World", result.Name);
|
Assert.Equal(result.Name, "Hello World");
|
||||||
Assert.Equal("Greet the world and record the time", result.Description);
|
Assert.Equal(result.Description, "Greet the world and record the time");
|
||||||
Assert.Equal(2, result.Inputs.Count);
|
Assert.Equal(result.Inputs.Count, 2);
|
||||||
Assert.Equal("greeting", result.Inputs[0].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[0].Key.AssertString("key").Value, "greeting");
|
||||||
Assert.Equal("Hello", result.Inputs[0].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[0].Value.AssertString("value").Value, "Hello");
|
||||||
Assert.Equal("entryPoint", result.Inputs[1].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[1].Key.AssertString("key").Value, "entryPoint");
|
||||||
Assert.Equal("", result.Inputs[1].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[1].Value.AssertString("value").Value, "");
|
||||||
Assert.Equal(1, result.Deprecated.Count);
|
Assert.Equal(result.Deprecated.Count, 1);
|
||||||
|
|
||||||
Assert.True(result.Deprecated.ContainsKey("greeting"));
|
Assert.True(result.Deprecated.ContainsKey("greeting"));
|
||||||
result.Deprecated.TryGetValue("greeting", out string value);
|
result.Deprecated.TryGetValue("greeting", out string value);
|
||||||
Assert.Equal("This property has been deprecated", value);
|
Assert.Equal(value, "This property has been deprecated");
|
||||||
|
|
||||||
Assert.Equal(ActionExecutionType.NodeJS, result.Execution.ExecutionType);
|
Assert.Equal(result.Execution.ExecutionType, ActionExecutionType.NodeJS);
|
||||||
|
|
||||||
var nodeAction = result.Execution as NodeJSActionExecutionData;
|
var nodeAction = result.Execution as NodeJSActionExecutionData;
|
||||||
|
|
||||||
Assert.Equal("main.js", nodeAction.Script);
|
Assert.Equal(nodeAction.Script, "main.js");
|
||||||
Assert.Equal("cleanup.js", nodeAction.Cleanup);
|
Assert.Equal(nodeAction.Cleanup, "cleanup.js");
|
||||||
Assert.Equal("cancelled()", nodeAction.CleanupCondition);
|
Assert.Equal(nodeAction.CleanupCondition, "cancelled()");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -336,19 +336,19 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "pluginaction.yml"));
|
var result = actionManifest.Load(_ec.Object, Path.Combine(TestUtil.GetTestDataPath(), "pluginaction.yml"));
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("Hello World", result.Name);
|
Assert.Equal(result.Name, "Hello World");
|
||||||
Assert.Equal("Greet the world and record the time", result.Description);
|
Assert.Equal(result.Description, "Greet the world and record the time");
|
||||||
Assert.Equal(2, result.Inputs.Count);
|
Assert.Equal(result.Inputs.Count, 2);
|
||||||
Assert.Equal("greeting", result.Inputs[0].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[0].Key.AssertString("key").Value, "greeting");
|
||||||
Assert.Equal("Hello", result.Inputs[0].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[0].Value.AssertString("value").Value, "Hello");
|
||||||
Assert.Equal("entryPoint", result.Inputs[1].Key.AssertString("key").Value);
|
Assert.Equal(result.Inputs[1].Key.AssertString("key").Value, "entryPoint");
|
||||||
Assert.Equal("", result.Inputs[1].Value.AssertString("value").Value);
|
Assert.Equal(result.Inputs[1].Value.AssertString("value").Value, "");
|
||||||
|
|
||||||
Assert.Equal(ActionExecutionType.Plugin, result.Execution.ExecutionType);
|
Assert.Equal(result.Execution.ExecutionType, ActionExecutionType.Plugin);
|
||||||
|
|
||||||
var pluginAction = result.Execution as PluginActionExecutionData;
|
var pluginAction = result.Execution as PluginActionExecutionData;
|
||||||
|
|
||||||
Assert.Equal("someplugin", pluginAction.Plugin);
|
Assert.Equal(pluginAction.Plugin, "someplugin");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -383,9 +383,9 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var result = actionManifest.EvaluateContainerArguments(_ec.Object, arguments, evaluateContext);
|
var result = actionManifest.EvaluateContainerArguments(_ec.Object, arguments, evaluateContext);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("hello", result[0]);
|
Assert.Equal(result[0], "hello");
|
||||||
Assert.Equal("test", result[1]);
|
Assert.Equal(result[1], "test");
|
||||||
Assert.Equal(2, result.Count);
|
Assert.Equal(result.Count, 2);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -420,9 +420,9 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var result = actionManifest.EvaluateContainerEnvironment(_ec.Object, environment, evaluateContext);
|
var result = actionManifest.EvaluateContainerEnvironment(_ec.Object, environment, evaluateContext);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("hello", result["hello"]);
|
Assert.Equal(result["hello"], "hello");
|
||||||
Assert.Equal("test", result["test"]);
|
Assert.Equal(result["test"], "test");
|
||||||
Assert.Equal(2, result.Count);
|
Assert.Equal(result.Count, 2);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -459,13 +459,13 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var result = actionManifest.EvaluateDefaultInput(_ec.Object, "testInput", new StringToken(null, null, null, "defaultValue"), evaluateContext);
|
var result = actionManifest.EvaluateDefaultInput(_ec.Object, "testInput", new StringToken(null, null, null, "defaultValue"), evaluateContext);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("defaultValue", result);
|
Assert.Equal(result, "defaultValue");
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
result = actionManifest.EvaluateDefaultInput(_ec.Object, "testInput", new BasicExpressionToken(null, null, null, "github.ref"), evaluateContext);
|
result = actionManifest.EvaluateDefaultInput(_ec.Object, "testInput", new BasicExpressionToken(null, null, null, "github.ref"), evaluateContext);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("refs/heads/master", result);
|
Assert.Equal(result, "refs/heads/master");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
private TestHostContext _hc;
|
private TestHostContext _hc;
|
||||||
private ActionRunner _actionRunner;
|
private ActionRunner _actionRunner;
|
||||||
private IActionManifestManager _actionManifestManager;
|
private IActionManifestManager _actionManifestManager;
|
||||||
|
private string _workFolder;
|
||||||
private DictionaryContextData _context = new DictionaryContextData();
|
private DictionaryContextData _context = new DictionaryContextData();
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -74,9 +75,9 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.Equal("test1", finialInputs["input1"]);
|
Assert.Equal(finialInputs["input1"], "test1");
|
||||||
Assert.Equal("test2", finialInputs["input2"]);
|
Assert.Equal(finialInputs["input2"], "test2");
|
||||||
Assert.Equal("github", finialInputs["input3"]);
|
Assert.Equal(finialInputs["input3"], "github");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -277,6 +278,24 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
Assert.Equal("${{ matrix.node }}", _actionRunner.DisplayName);
|
Assert.Equal("${{ matrix.node }}", _actionRunner.DisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateAction(string yamlContent, out Pipelines.ActionStep instance, out string directory)
|
||||||
|
{
|
||||||
|
directory = Path.Combine(_workFolder, Constants.Path.ActionsDirectory, "GitHub/actions".Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar), "master");
|
||||||
|
string file = Path.Combine(directory, Constants.Path.ActionManifestFile);
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(file));
|
||||||
|
File.WriteAllText(file, yamlContent);
|
||||||
|
instance = new Pipelines.ActionStep()
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Reference = new Pipelines.RepositoryPathReference()
|
||||||
|
{
|
||||||
|
Name = "GitHub/actions",
|
||||||
|
Ref = "master",
|
||||||
|
RepositoryType = Pipelines.RepositoryTypes.GitHub
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void Setup([CallerMemberName] string name = "")
|
private void Setup([CallerMemberName] string name = "")
|
||||||
{
|
{
|
||||||
_ecTokenSource?.Dispose();
|
_ecTokenSource?.Dispose();
|
||||||
|
|||||||
@@ -206,22 +206,8 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var action2 = jobContext.CreateChild(Guid.NewGuid(), "action_2", "action_2", null, null);
|
var action2 = jobContext.CreateChild(Guid.NewGuid(), "action_2", "action_2", null, null);
|
||||||
action2.IntraActionState["state"] = "2";
|
action2.IntraActionState["state"] = "2";
|
||||||
|
|
||||||
|
action1.RegisterPostJobAction("post1", "always()", new Pipelines.ActionStep() { Name = "post1", DisplayName = "Test 1", Reference = new Pipelines.RepositoryPathReference() { Name = "actions/action" } });
|
||||||
var postRunner1 = hc.CreateService<IActionRunner>();
|
action2.RegisterPostJobAction("post2", "always()", new Pipelines.ActionStep() { Name = "post2", DisplayName = "Test 2", Reference = new Pipelines.RepositoryPathReference() { Name = "actions/action" } });
|
||||||
postRunner1.Action = new Pipelines.ActionStep() { Name = "post1", DisplayName = "Test 1", Reference = new Pipelines.RepositoryPathReference() { Name = "actions/action" } };
|
|
||||||
postRunner1.Stage = ActionRunStage.Post;
|
|
||||||
postRunner1.Condition = "always()";
|
|
||||||
postRunner1.DisplayName = "post1";
|
|
||||||
|
|
||||||
|
|
||||||
var postRunner2 = hc.CreateService<IActionRunner>();
|
|
||||||
postRunner2.Action = new Pipelines.ActionStep() { Name = "post2", DisplayName = "Test 2", Reference = new Pipelines.RepositoryPathReference() { Name = "actions/action" } };
|
|
||||||
postRunner2.Stage = ActionRunStage.Post;
|
|
||||||
postRunner2.Condition = "always()";
|
|
||||||
postRunner2.DisplayName = "post2";
|
|
||||||
|
|
||||||
action1.RegisterPostJobStep("post1", postRunner1);
|
|
||||||
action2.RegisterPostJobStep("post2", postRunner2);
|
|
||||||
|
|
||||||
Assert.NotNull(jobContext.JobSteps);
|
Assert.NotNull(jobContext.JobSteps);
|
||||||
Assert.NotNull(jobContext.PostJobSteps);
|
Assert.NotNull(jobContext.PostJobSteps);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using GitHub.Runner.Sdk;
|
using GitHub.Runner.Sdk;
|
||||||
@@ -159,7 +158,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Level", "L0")]
|
[Trait("Level", "L0")]
|
||||||
[Trait("Category", "Worker")]
|
[Trait("Category", "Worker")]
|
||||||
public void MatcherCode()
|
public void Code()
|
||||||
{
|
{
|
||||||
var matchers = new IssueMatchersConfig
|
var matchers = new IssueMatchersConfig
|
||||||
{
|
{
|
||||||
@@ -301,7 +300,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Level", "L0")]
|
[Trait("Level", "L0")]
|
||||||
[Trait("Category", "Worker")]
|
[Trait("Category", "Worker")]
|
||||||
public void MatcherLineColumn()
|
public void LineColumn()
|
||||||
{
|
{
|
||||||
var matchers = new IssueMatchersConfig
|
var matchers = new IssueMatchersConfig
|
||||||
{
|
{
|
||||||
@@ -349,7 +348,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Level", "L0")]
|
[Trait("Level", "L0")]
|
||||||
[Trait("Category", "Worker")]
|
[Trait("Category", "Worker")]
|
||||||
public void MatcherDoesNotReceiveCommand()
|
public void ProcessCommand()
|
||||||
{
|
{
|
||||||
using (Setup())
|
using (Setup())
|
||||||
using (_outputManager)
|
using (_outputManager)
|
||||||
@@ -383,7 +382,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Level", "L0")]
|
[Trait("Level", "L0")]
|
||||||
[Trait("Category", "Worker")]
|
[Trait("Category", "Worker")]
|
||||||
public void MatcherRemoveColorCodes()
|
public void RemoveColorCodes()
|
||||||
{
|
{
|
||||||
using (Setup())
|
using (Setup())
|
||||||
using (_outputManager)
|
using (_outputManager)
|
||||||
@@ -529,7 +528,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Level", "L0")]
|
[Trait("Level", "L0")]
|
||||||
[Trait("Category", "Worker")]
|
[Trait("Category", "Worker")]
|
||||||
public void MatcherSeverity()
|
public void Severity()
|
||||||
{
|
{
|
||||||
var matchers = new IssueMatchersConfig
|
var matchers = new IssueMatchersConfig
|
||||||
{
|
{
|
||||||
@@ -590,7 +589,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Level", "L0")]
|
[Trait("Level", "L0")]
|
||||||
[Trait("Category", "Worker")]
|
[Trait("Category", "Worker")]
|
||||||
public void MatcherTimeout()
|
public void Timeout()
|
||||||
{
|
{
|
||||||
Environment.SetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_ISSUE_MATCHER_TIMEOUT", "0:0:0.01");
|
Environment.SetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_ISSUE_MATCHER_TIMEOUT", "0:0:0.01");
|
||||||
var matchers = new IssueMatchersConfig
|
var matchers = new IssueMatchersConfig
|
||||||
@@ -641,216 +640,10 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
// todo: roots file against fromPath
|
||||||
[Trait("Level", "L0")]
|
// todo: roots file against system.defaultWorkingDirectory
|
||||||
[Trait("Category", "Worker")]
|
// todo: matches repository
|
||||||
public void MatcherFile()
|
// todo: checks file exists
|
||||||
{
|
|
||||||
var matchers = new IssueMatchersConfig
|
|
||||||
{
|
|
||||||
Matchers =
|
|
||||||
{
|
|
||||||
new IssueMatcherConfig
|
|
||||||
{
|
|
||||||
Owner = "my-matcher-1",
|
|
||||||
Patterns = new[]
|
|
||||||
{
|
|
||||||
new IssuePatternConfig
|
|
||||||
{
|
|
||||||
Pattern = @"(.+): (.+)",
|
|
||||||
File = 1,
|
|
||||||
Message = 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
using (var hostContext = Setup(matchers: matchers))
|
|
||||||
using (_outputManager)
|
|
||||||
{
|
|
||||||
// Setup github.workspace
|
|
||||||
var workDirectory = hostContext.GetDirectory(WellKnownDirectory.Work);
|
|
||||||
ArgUtil.NotNullOrEmpty(workDirectory, nameof(workDirectory));
|
|
||||||
Directory.CreateDirectory(workDirectory);
|
|
||||||
var workspaceDirectory = Path.Combine(workDirectory, "workspace");
|
|
||||||
Directory.CreateDirectory(workspaceDirectory);
|
|
||||||
_executionContext.Setup(x => x.GetGitHubContext("workspace")).Returns(workspaceDirectory);
|
|
||||||
|
|
||||||
// Create a test file
|
|
||||||
Directory.CreateDirectory(Path.Combine(workspaceDirectory, "some-directory"));
|
|
||||||
var filePath = Path.Combine(workspaceDirectory, "some-directory", "some-file.txt");
|
|
||||||
File.WriteAllText(filePath, "");
|
|
||||||
|
|
||||||
// Process
|
|
||||||
Process("some-directory/some-file.txt: some error");
|
|
||||||
Assert.Equal(1, _issues.Count);
|
|
||||||
Assert.Equal("some error", _issues[0].Item1.Message);
|
|
||||||
Assert.Equal("some-directory/some-file.txt", _issues[0].Item1.Data["file"]);
|
|
||||||
Assert.Equal(0, _commands.Count);
|
|
||||||
Assert.Equal(0, _messages.Count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void MatcherFileExists()
|
|
||||||
{
|
|
||||||
var matchers = new IssueMatchersConfig
|
|
||||||
{
|
|
||||||
Matchers =
|
|
||||||
{
|
|
||||||
new IssueMatcherConfig
|
|
||||||
{
|
|
||||||
Owner = "my-matcher-1",
|
|
||||||
Patterns = new[]
|
|
||||||
{
|
|
||||||
new IssuePatternConfig
|
|
||||||
{
|
|
||||||
Pattern = @"(.+): (.+)",
|
|
||||||
File = 1,
|
|
||||||
Message = 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
using (var hostContext = Setup(matchers: matchers))
|
|
||||||
using (_outputManager)
|
|
||||||
{
|
|
||||||
// Setup github.workspace
|
|
||||||
var workDirectory = hostContext.GetDirectory(WellKnownDirectory.Work);
|
|
||||||
ArgUtil.NotNullOrEmpty(workDirectory, nameof(workDirectory));
|
|
||||||
Directory.CreateDirectory(workDirectory);
|
|
||||||
var workspaceDirectory = Path.Combine(workDirectory, "workspace");
|
|
||||||
Directory.CreateDirectory(workspaceDirectory);
|
|
||||||
_executionContext.Setup(x => x.GetGitHubContext("workspace")).Returns(workspaceDirectory);
|
|
||||||
|
|
||||||
// Create a test file
|
|
||||||
File.WriteAllText(Path.Combine(workspaceDirectory, "some-file-1.txt"), "");
|
|
||||||
|
|
||||||
// Process
|
|
||||||
Process("some-file-1.txt: some error 1"); // file exists
|
|
||||||
Process("some-file-2.txt: some error 2"); // file does not exist
|
|
||||||
|
|
||||||
Assert.Equal(2, _issues.Count);
|
|
||||||
Assert.Equal("some error 1", _issues[0].Item1.Message);
|
|
||||||
Assert.Equal("some-file-1.txt", _issues[0].Item1.Data["file"]);
|
|
||||||
Assert.Equal("some error 2", _issues[1].Item1.Message);
|
|
||||||
Assert.False(_issues[1].Item1.Data.ContainsKey("file")); // does not contain file key
|
|
||||||
Assert.Equal(0, _commands.Count);
|
|
||||||
Assert.Equal(0, _messages.Where(x => !x.StartsWith("##[debug]")).Count());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void MatcherFileOutsideRepository()
|
|
||||||
{
|
|
||||||
var matchers = new IssueMatchersConfig
|
|
||||||
{
|
|
||||||
Matchers =
|
|
||||||
{
|
|
||||||
new IssueMatcherConfig
|
|
||||||
{
|
|
||||||
Owner = "my-matcher-1",
|
|
||||||
Patterns = new[]
|
|
||||||
{
|
|
||||||
new IssuePatternConfig
|
|
||||||
{
|
|
||||||
Pattern = @"(.+): (.+)",
|
|
||||||
File = 1,
|
|
||||||
Message = 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
using (var hostContext = Setup(matchers: matchers))
|
|
||||||
using (_outputManager)
|
|
||||||
{
|
|
||||||
// Setup github.workspace
|
|
||||||
var workDirectory = hostContext.GetDirectory(WellKnownDirectory.Work);
|
|
||||||
ArgUtil.NotNullOrEmpty(workDirectory, nameof(workDirectory));
|
|
||||||
Directory.CreateDirectory(workDirectory);
|
|
||||||
var workspaceDirectory = Path.Combine(workDirectory, "workspace");
|
|
||||||
Directory.CreateDirectory(workspaceDirectory);
|
|
||||||
_executionContext.Setup(x => x.GetGitHubContext("workspace")).Returns(workspaceDirectory);
|
|
||||||
|
|
||||||
// Create test files
|
|
||||||
var filePath1 = Path.Combine(workspaceDirectory, "some-file-1.txt");
|
|
||||||
File.WriteAllText(filePath1, "");
|
|
||||||
var workspaceSiblingDirectory = Path.Combine(Path.GetDirectoryName(workspaceDirectory), "workspace-sibling");
|
|
||||||
Directory.CreateDirectory(workspaceSiblingDirectory);
|
|
||||||
var filePath2 = Path.Combine(workspaceSiblingDirectory, "some-file-2.txt");
|
|
||||||
File.WriteAllText(filePath2, "");
|
|
||||||
|
|
||||||
// Process
|
|
||||||
Process($"{filePath1}: some error 1"); // file exists inside workspace
|
|
||||||
Process($"{filePath2}: some error 2"); // file exists outside workspace
|
|
||||||
|
|
||||||
Assert.Equal(2, _issues.Count);
|
|
||||||
Assert.Equal("some error 1", _issues[0].Item1.Message);
|
|
||||||
Assert.Equal("some-file-1.txt", _issues[0].Item1.Data["file"]);
|
|
||||||
Assert.Equal("some error 2", _issues[1].Item1.Message);
|
|
||||||
Assert.False(_issues[1].Item1.Data.ContainsKey("file")); // does not contain file key
|
|
||||||
Assert.Equal(0, _commands.Count);
|
|
||||||
Assert.Equal(0, _messages.Where(x => !x.StartsWith("##[debug]")).Count());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void MatcherFromPath()
|
|
||||||
{
|
|
||||||
var matchers = new IssueMatchersConfig
|
|
||||||
{
|
|
||||||
Matchers =
|
|
||||||
{
|
|
||||||
new IssueMatcherConfig
|
|
||||||
{
|
|
||||||
Owner = "my-matcher-1",
|
|
||||||
Patterns = new[]
|
|
||||||
{
|
|
||||||
new IssuePatternConfig
|
|
||||||
{
|
|
||||||
Pattern = @"(.+): (.+) \[(.+)\]",
|
|
||||||
File = 1,
|
|
||||||
Message = 2,
|
|
||||||
FromPath = 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
using (var hostContext = Setup(matchers: matchers))
|
|
||||||
using (_outputManager)
|
|
||||||
{
|
|
||||||
// Setup github.workspace
|
|
||||||
var workDirectory = hostContext.GetDirectory(WellKnownDirectory.Work);
|
|
||||||
ArgUtil.NotNullOrEmpty(workDirectory, nameof(workDirectory));
|
|
||||||
Directory.CreateDirectory(workDirectory);
|
|
||||||
var workspaceDirectory = Path.Combine(workDirectory, "workspace");
|
|
||||||
Directory.CreateDirectory(workspaceDirectory);
|
|
||||||
_executionContext.Setup(x => x.GetGitHubContext("workspace")).Returns(workspaceDirectory);
|
|
||||||
|
|
||||||
// Create a test file
|
|
||||||
Directory.CreateDirectory(Path.Combine(workspaceDirectory, "some-directory"));
|
|
||||||
Directory.CreateDirectory(Path.Combine(workspaceDirectory, "some-project", "some-directory"));
|
|
||||||
var filePath = Path.Combine(workspaceDirectory, "some-project", "some-directory", "some-file.txt");
|
|
||||||
File.WriteAllText(filePath, "");
|
|
||||||
|
|
||||||
// Process
|
|
||||||
Process("some-directory/some-file.txt: some error [some-project/some-project.proj]");
|
|
||||||
Assert.Equal(1, _issues.Count);
|
|
||||||
Assert.Equal("some error", _issues[0].Item1.Message);
|
|
||||||
Assert.Equal("some-project/some-directory/some-file.txt", _issues[0].Item1.Data["file"]);
|
|
||||||
Assert.Equal(0, _commands.Count);
|
|
||||||
Assert.Equal(0, _messages.Count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestHostContext Setup(
|
private TestHostContext Setup(
|
||||||
[CallerMemberName] string name = "",
|
[CallerMemberName] string name = "",
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
string actual = variables.Get("no such");
|
string actual = variables.Get("no such");
|
||||||
|
|
||||||
// Assert.
|
// Assert.
|
||||||
Assert.Null(actual);
|
Assert.Equal(null, actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||||
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm;rhel.6-x64;osx-x64</RuntimeIdentifiers>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
<AssetTargetFallback>portable-net45+win8</AssetTargetFallback>
|
||||||
<NoWarn>NU1701;NU1603;NU1603;xUnit2013;</NoWarn>
|
<NoWarn>NU1701;NU1603;NU1603;xUnit2013;</NoWarn>
|
||||||
@@ -29,4 +29,42 @@
|
|||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x64'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'win-x86'">
|
||||||
|
<DefineConstants>OS_WINDOWS;X86;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
|
||||||
|
<DefineConstants>OS_OSX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' AND '$(Configuration)' == 'Debug'">
|
||||||
|
<DefineConstants>OS_OSX;DEBUG;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'rhel.6-x64'">
|
||||||
|
<DefineConstants>OS_LINUX;OS_RHEL6;X64;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(Configuration)' == 'Debug' AND '$(PackageRuntime)' == 'linux-arm'">
|
||||||
|
<DefineConstants>OS_LINUX;ARM;DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
103
src/dev.sh
103
src/dev.sh
@@ -10,7 +10,6 @@ set -e
|
|||||||
|
|
||||||
DEV_CMD=$1
|
DEV_CMD=$1
|
||||||
DEV_CONFIG=$2
|
DEV_CONFIG=$2
|
||||||
DEV_TARGET_RUNTIME=$3
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
LAYOUT_DIR="$SCRIPT_DIR/../_layout"
|
LAYOUT_DIR="$SCRIPT_DIR/../_layout"
|
||||||
@@ -34,32 +33,29 @@ if [[ ($(uname) == "Linux") || ($(uname) == "Darwin") ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then
|
if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then
|
||||||
RUNTIME_ID='win-x64'
|
RUNTIME_ID='win-x64'
|
||||||
if [[ "$PROCESSOR_ARCHITECTURE" == 'x86' ]]; then
|
if [[ "$PROCESSOR_ARCHITECTURE" == 'x86' ]]; then
|
||||||
RUNTIME_ID='win-x86'
|
RUNTIME_ID='win-x86'
|
||||||
fi
|
fi
|
||||||
elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then
|
elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then
|
||||||
RUNTIME_ID="linux-x64"
|
RUNTIME_ID="linux-x64"
|
||||||
if command -v uname > /dev/null; then
|
if command -v uname > /dev/null; then
|
||||||
CPU_NAME=$(uname -m)
|
CPU_NAME=$(uname -m)
|
||||||
case $CPU_NAME in
|
case $CPU_NAME in
|
||||||
armv7l) RUNTIME_ID="linux-arm";;
|
armv7l) RUNTIME_ID="linux-arm";;
|
||||||
aarch64) RUNTIME_ID="linux-arm64";;
|
aarch64) RUNTIME_ID="linux-arm";;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -e /etc/redhat-release ]; then
|
||||||
|
redhatRelease=$(</etc/redhat-release)
|
||||||
|
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
|
||||||
|
RUNTIME_ID='rhel.6-x64'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -e /etc/redhat-release ]; then
|
|
||||||
redhatRelease=$(</etc/redhat-release)
|
|
||||||
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
|
|
||||||
RUNTIME_ID='rhel.6-x64'
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then
|
elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then
|
||||||
RUNTIME_ID='osx-x64'
|
RUNTIME_ID='osx-x64'
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$DEV_TARGET_RUNTIME" ]]; then
|
|
||||||
RUNTIME_ID="$DEV_TARGET_RUNTIME"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure current platform support publish the dotnet runtime
|
# Make sure current platform support publish the dotnet runtime
|
||||||
@@ -67,34 +63,34 @@ fi
|
|||||||
# Linux can publish linux-x64/arm/rhel.6-x64
|
# Linux can publish linux-x64/arm/rhel.6-x64
|
||||||
# OSX can publish osx-x64
|
# OSX can publish osx-x64
|
||||||
if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then
|
if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then
|
||||||
if [[ ("$RUNTIME_ID" != 'win-x86') && ("$RUNTIME_ID" != 'win-x64') ]]; then
|
if [[ ("$RUNTIME_ID" != 'win-x86') && ("$RUNTIME_ID" != 'win-x64') ]]; then
|
||||||
echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2
|
echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then
|
elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then
|
||||||
if [[ ("$RUNTIME_ID" != 'linux-x64') && ("$RUNTIME_ID" != 'linux-x86') && ("$RUNTIME_ID" != 'linux-arm64') && ("$RUNTIME_ID" != 'linux-arm') && ("$RUNTIME_ID" != 'rhel.6-x64') ]]; then
|
if [[ ("$RUNTIME_ID" != 'linux-x64') && ("$RUNTIME_ID" != 'linux-arm') && ("$RUNTIME_ID" != 'rhel.6-x64') ]]; then
|
||||||
echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2
|
echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then
|
elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then
|
||||||
if [[ ("$RUNTIME_ID" != 'osx-x64') ]]; then
|
if [[ ("$RUNTIME_ID" != 'osx-x64') ]]; then
|
||||||
echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2
|
echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function failed()
|
function failed()
|
||||||
{
|
{
|
||||||
local error=${1:-Undefined error}
|
local error=${1:-Undefined error}
|
||||||
echo "Failed: $error" >&2
|
echo "Failed: $error" >&2
|
||||||
popd
|
popd
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function warn()
|
function warn()
|
||||||
{
|
{
|
||||||
local error=${1:-Undefined error}
|
local error=${1:-Undefined error}
|
||||||
echo "WARNING - FAILED: $error" >&2
|
echo "WARNING - FAILED: $error" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkRC() {
|
function checkRC() {
|
||||||
@@ -155,8 +151,7 @@ function package ()
|
|||||||
echo "You must build first. Expecting to find ${LAYOUT_DIR}/bin"
|
echo "You must build first. Expecting to find ${LAYOUT_DIR}/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: We are cross-compiling arm on x64 so we cant exec Runner.Listener. Remove after building on native arm host
|
runner_ver=$("${LAYOUT_DIR}/bin/Runner.Listener" --version) || failed "version"
|
||||||
runner_ver=$("${LAYOUT_DIR}/bin/Runner.Listener" --version) || runner_ver=$(cat runnerversion) || failed "version"
|
|
||||||
runner_pkg_name="actions-runner-${RUNTIME_ID}-${runner_ver}"
|
runner_pkg_name="actions-runner-${RUNTIME_ID}-${runner_ver}"
|
||||||
|
|
||||||
heading "Packaging ${runner_pkg_name}"
|
heading "Packaging ${runner_pkg_name}"
|
||||||
@@ -213,6 +208,8 @@ fi
|
|||||||
echo "Prepend ${DOTNETSDK_INSTALLDIR} to %PATH%"
|
echo "Prepend ${DOTNETSDK_INSTALLDIR} to %PATH%"
|
||||||
export PATH=${DOTNETSDK_INSTALLDIR}:$PATH
|
export PATH=${DOTNETSDK_INSTALLDIR}:$PATH
|
||||||
|
|
||||||
|
heading "Github Dreamlifter Runner"
|
||||||
|
|
||||||
heading "Dotnet SDK Version"
|
heading "Dotnet SDK Version"
|
||||||
dotnet --version
|
dotnet --version
|
||||||
|
|
||||||
@@ -236,15 +233,15 @@ if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case $DEV_CMD in
|
case $DEV_CMD in
|
||||||
"build") build;;
|
"build") build;;
|
||||||
"b") build;;
|
"b") build;;
|
||||||
"test") runtest;;
|
"test") runtest;;
|
||||||
"t") runtest;;
|
"t") runtest;;
|
||||||
"layout") layout;;
|
"layout") layout;;
|
||||||
"l") layout;;
|
"l") layout;;
|
||||||
"package") package;;
|
"package") package;;
|
||||||
"p") package;;
|
"p") package;;
|
||||||
*) echo "Invalid cmd. Use build(b), test(t), layout(l) or package(p)";;
|
*) echo "Invalid cmd. Use build(b), test(t), layout(l) or package(p)";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.161.0
|
2.160.0
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
parameters:
|
|
||||||
targetRuntime: ''
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
# Build agent layout
|
# Build agent layout
|
||||||
- script: dev.cmd layout Release ${{ parameters.targetRuntime }}
|
- script: dev.cmd layout Release
|
||||||
workingDirectory: src
|
workingDirectory: src
|
||||||
displayName: Build & Layout Release ${{ parameters.targetRuntime }}
|
displayName: Build & Layout Release
|
||||||
|
|
||||||
# Run test
|
# Run test
|
||||||
- script: dev.cmd test
|
- script: dev.cmd test
|
||||||
|
|||||||
Reference in New Issue
Block a user