Skip to content

Commit 5d3950e

Browse files
committed
(#51) Linux: use downloaded nuget.exe for tests
1 parent 1429efa commit 5d3950e

File tree

2 files changed

+60
-24
lines changed

2 files changed

+60
-24
lines changed

.github/workflows/main.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
# Build:
3131
- name: Install
3232
shell: pwsh
33-
run: ./linux/install.ps1
33+
run: ./linux/install.ps1 -ForBuild
3434
- name: Build
3535
shell: pwsh
3636
run: ./linux/build.ps1
@@ -90,6 +90,10 @@ jobs:
9090
- name: Install PowerShell
9191
run: bash ./linux/install-pwsh.sh
9292

93+
- name: Install
94+
shell: pwsh
95+
run: ./linux/install.ps1 -ForTests
96+
9397
- name: Download Linux artifact
9498
uses: actions/download-artifact@v2
9599
with:
@@ -105,7 +109,7 @@ jobs:
105109
dotnet-version: '2.2.x'
106110
- name: Pack NuGet
107111
shell: pwsh
108-
run: ./common/nuget-pack.ps1 -Version "${{ env.PACKAGE_VERSION_BASE }}.${{ github.run_id }}" -NuGet nuget
112+
run: ./common/nuget-pack.ps1 -Version "${{ env.PACKAGE_VERSION_BASE }}.${{ github.run_id }}" -NuGet $env:GITHUB_WORKSPACE/tools/nuget.exe -UseMono
109113

110114
- name: NuGet cache
111115
uses: actions/cache@v2
@@ -114,7 +118,7 @@ jobs:
114118
key: ${{ runner.os }}.nuget.${{ hashFiles('tdsharp/**/*.csproj') }}
115119
- name: Test
116120
shell: pwsh
117-
run: ./common/test.ps1 -NuGet nuget
121+
run: ./common/test.ps1 -NuGet $env:GITHUB_WORKSPACE/tools/nuget.exe -UseMono
118122

119123
test-macos:
120124
needs: build-macos

linux/install.ps1

+53-21
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,69 @@
11
param (
22
[string] $NuGetDownloadUrl = 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe',
3-
[string] $NuGetPath = "$PSScriptRoot/../tools/nuget.exe"
3+
[string] $NuGetPath = "$PSScriptRoot/../tools/nuget.exe",
4+
[switch] $ForBuild,
5+
[switch] $ForTests
46
)
57

68
$ErrorActionPreference = 'Stop'
79
Set-StrictMode -Version Latest
810

9-
try {
10-
# The following command requires installing tzdata which is interactive, so let's forbid its interactivity.
11-
$oldDebianFrontend = $env:DEBIAN_FRONTEND
12-
$env:DEBIAN_FRONTEND = 'noninteractive'
11+
if ($ForBuild) {
12+
try {
13+
# The following command requires installing tzdata which is interactive, so let's forbid its interactivity.
14+
$oldDebianFrontend = $env:DEBIAN_FRONTEND
15+
$env:DEBIAN_FRONTEND = 'noninteractive'
16+
$dependencies = @(
17+
'cmake'
18+
'g++'
19+
'git'
20+
'gperf'
21+
'gperf'
22+
'libssl-dev'
23+
'make'
24+
'php-cli'
25+
'zlib1g-dev'
26+
)
27+
28+
Write-Output 'Installing dependencies.'
29+
apt-get install -y @dependencies
30+
if (!$?) {
31+
throw 'Cannot install dependencies from apt-get'
32+
}
33+
} finally {
34+
$env:DEBIAN_FRONTEND = $oldDebianFrontend
35+
}
36+
}
37+
38+
if ($ForTests) {
1339
$dependencies = @(
14-
'cmake'
15-
'gperf'
16-
'make'
17-
'git'
18-
'zlib1g-dev'
19-
'libssl-dev'
20-
'gperf'
21-
'php-cli'
22-
'cmake'
23-
'g++'
40+
'ca-certificates'
41+
'gnupg'
2442
)
2543

2644
Write-Output 'Installing dependencies.'
2745
apt-get install -y @dependencies
2846
if (!$?) {
2947
throw 'Cannot install dependencies from apt-get'
3048
}
31-
} finally {
32-
$env:DEBIAN_FRONTEND = $oldDebianFrontend
33-
}
3449

35-
Write-Output "Downloading NuGet client to $NuGetPath"
36-
New-Item -Type Directory ([IO.Path]::GetDirectoryName($NuGetPath))
37-
Invoke-WebRequest -OutFile $NuGetPath $NuGetDownloadUrl
50+
Write-Output 'Installing Mono.'
51+
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
52+
if (!$?) {
53+
throw 'Cannot execute apt-key adv.'
54+
}
55+
56+
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list
57+
if (!$?) {
58+
throw 'Cannot add a package source.'
59+
}
60+
61+
apt-get update && apt-get install -y mono-devel
62+
if (!$?) {
63+
throw 'Cannot execute apt-get update.'
64+
}
65+
66+
Write-Output "Downloading NuGet client to $NuGetPath"
67+
New-Item -Type Directory ([IO.Path]::GetDirectoryName($NuGetPath))
68+
Invoke-WebRequest -OutFile $NuGetPath $NuGetDownloadUrl
69+
}

0 commit comments

Comments
 (0)