Skip to content

Commit e2e0dc0

Browse files
authored
GitHub Actions - release-6.2 (#832)
* SQL Persistence CI - release branch * Release workflow * Back to simpler setup fixture, add ifs * Oracle doesn't store fractional seconds, so testing 2s timeout does not work * Align with master * Try local MySQL, why not? * Try to fix platform-specific MySQL connect issue * Bit closer * Maybe this time * C'mon now * Rename MsSql -> SqlServer in job names * Remove problematic test - timeout too short, has been removed in master
1 parent dee4bf4 commit e2e0dc0

File tree

60 files changed

+453
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+453
-83
lines changed

.github/workflows/ci.yml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- release-[6-9].*
7+
pull_request:
8+
branches-ignore:
9+
- release-[0-5].*
10+
workflow_dispatch:
11+
env:
12+
DOTNET_NOLOGO: true
13+
jobs:
14+
build:
15+
name: ${{ matrix.os-name }}-${{ matrix.engine }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ windows-2019, ubuntu-20.04 ]
20+
engine: [ SqlServer, MySql, PostgreSql ]
21+
include:
22+
# Add os-name alias for job name
23+
- os: windows-2019
24+
os-name: Windows
25+
- os: ubuntu-20.04
26+
os-name: Linux
27+
# Additional permutatations for Oracle
28+
- os: ubuntu-20.04
29+
os-name: Linux
30+
engine: Oracle
31+
- os: [self-hosted, windows, oracle]
32+
os-name: Windows
33+
engine: Oracle
34+
fail-fast: false
35+
steps:
36+
- name: Check for secrets
37+
env:
38+
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
39+
shell: pwsh
40+
run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 })
41+
- name: Checkout
42+
uses: actions/checkout@v2.4.0
43+
with:
44+
fetch-depth: 0
45+
- name: Setup .NET SDK
46+
uses: actions/setup-dotnet@v1.9.0
47+
with:
48+
dotnet-version: |
49+
5.0.x
50+
3.1.x
51+
- name: Build
52+
run: dotnet build src --configuration Release
53+
- name: Upload packages
54+
uses: actions/upload-artifact@v2.2.4
55+
with:
56+
name: NuGet packages
57+
path: nugets/
58+
retention-days: 7
59+
- name: Azure login
60+
uses: azure/login@v1.3.0
61+
if: matrix.engine == 'PostgreSQL'
62+
with:
63+
creds: ${{ secrets.AZURE_ACI_CREDENTIALS }}
64+
- name: Setup SQL Server
65+
if: matrix.engine == 'SqlServer'
66+
uses: Particular/install-sql-server-action@v1.0.0
67+
with:
68+
connection-string-env-var: SQLServerConnectionString
69+
catalog: nservicebus
70+
- name: Setup PostgreSql
71+
id: setup-postgresql
72+
if: matrix.engine == 'PostgreSql'
73+
shell: pwsh
74+
run: |
75+
echo "Getting the Azure region in which this workflow is running..."
76+
$hostInfo = curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | ConvertFrom-Json
77+
$region = $hostInfo.compute.location
78+
echo "Actions agent running in Azure region: $region"
79+
80+
$name = "postgres-$(Get-Random)"
81+
$packageTag = "Package=SqlPersistence"
82+
$runnerOsTag = "RunnerOS=$($Env:RUNNER_OS)"
83+
$dateTag = "Created=$(Get-Date -Format "yyyy-MM-dd")"
84+
85+
$password = [guid]::NewGuid().ToString("n")
86+
echo "::add-mask::$password"
87+
88+
echo "Creating PostgreSQL container $name (This can take a while)"
89+
$details = az container create --image postgres:14 --name $name --location $region --dns-name-label $name --resource-group GitHubActions-RG --cpu 2 --memory 8 --ports 5432 --ip-address public --environment-variables POSTGRES_PASSWORD="$password" | ConvertFrom-Json
90+
echo "::set-output name=name::$name"
91+
92+
echo "Tagging container"
93+
$ignore = az tag create --resource-id $details.id --tags $packageTag $runnerOsTag $dateTag
94+
95+
$fqdn = $details.ipAddress.fqdn
96+
echo "::add-mask::$fqdn"
97+
98+
$connectionString = "User ID=postgres;Password=$password;Host=$fqdn;Port=5432;Database=postgres;"
99+
echo "PostgreSqlConnectionString=$connectionString" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
100+
101+
$env:PGPASSWORD = $password
102+
103+
# psql not in PATH on Windows
104+
if ($Env:RUNNER_OS -eq 'Windows') {
105+
$Env:PATH = $Env:PATH + ';' + $Env:PGBIN
106+
}
107+
108+
for ($i = 0; $i -lt 24; $i++) { ## 2 minute timeout
109+
echo "Checking for PostgreSQL connectivity $($i+1)/30..."
110+
$ignore = psql --host $fqdn --username=postgres --list
111+
if ($?) {
112+
echo "Connection successful"
113+
break;
114+
}
115+
sleep 5
116+
}
117+
118+
- name: Setup MySQL
119+
id: setup-mysql
120+
if: matrix.engine == 'MySql'
121+
shell: pwsh
122+
run: |
123+
echo '[client]
124+
user=root
125+
host=localhost' >> mysql-login
126+
127+
if ($Env:RUNNER_OS -eq 'Windows') {
128+
echo "Installing MySQL from Chocolatey"
129+
choco install mysql --limitoutput
130+
echo 'password=' >> mysql-login
131+
} else {
132+
echo "Starting MySQL service preinstalled on Linux agent"
133+
sudo systemctl start mysql.service
134+
echo 'password=root' >> mysql-login
135+
}
136+
137+
for ($i = 0; $i -lt 30; $i++) { ## 2.5 minute timeout
138+
echo "Checking for MySQL connectivity $($i+1)/30..."
139+
$ignore = mysql --defaults-extra-file=mysql-login -e "show databases;"
140+
if ($?) {
141+
echo "Connection successful"
142+
break;
143+
}
144+
sleep 5
145+
}
146+
147+
echo "Creating nservicebus database"
148+
mysql --defaults-extra-file=mysql-login -D mysql -e "create database if not exists nservicebus ;"
149+
echo "Creating user particular"
150+
mysql --defaults-extra-file=mysql-login -D mysql -e "create user particular identified by 'Welcome1' ;"
151+
echo "Giving user particular access to schema nservicebus"
152+
mysql --defaults-extra-file=mysql-login -D mysql -e "grant all on *.* to particular@'%' ;"
153+
154+
$connectionString = "Data Source=localhost;Initial Catalog=nservicebus;User ID=particular;Password=Welcome1;AllowUserVariables=True;AutoEnlist=false;Connect Timeout=60"
155+
echo "MySQLConnectionString=$connectionString" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
156+
157+
- name: Setup Oracle
158+
id: setup-oracle
159+
if: matrix.engine == 'Oracle'
160+
shell: pwsh
161+
run: |
162+
if ( $Env:RUNNER_OS -eq 'Windows') {
163+
echo "Adding environment variables for Oracle connection strings"
164+
echo "OracleConnectionString=User Id=particular;Password=Welcome1;Data Source=127.0.0.1:1521/nservicebus;Enlist=dynamic" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
165+
echo "OracleConnectionString_Particular2=User Id=particular2;Password=Welcome1;Data Source=127.0.0.1:1521/nservicebus;Enlist=dynamic" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
166+
}
167+
168+
if ( $Env:RUNNER_OS -eq 'Linux' ) {
169+
echo "Running Oracle using Docker"
170+
docker run --name oracle -d -p 1521:1521 -e ORACLE_PASSWORD=Welcome1 gvenzl/oracle-xe:21
171+
172+
for ($i = 0; $i -lt 24; $i++) { ## 2 minute timeout
173+
echo "Checking for Oracle connectivity $($i+1)/24..."
174+
docker exec oracle ./healthcheck.sh
175+
if ($?) {
176+
echo "Connection successful"
177+
break;
178+
}
179+
sleep 5
180+
}
181+
182+
cat ./.github/workflows/scripts/oracle-setup-linux.sql | docker exec -i oracle sqlplus / as sysdba
183+
184+
echo "Adding environment variables for Oracle connection strings"
185+
echo "OracleConnectionString=Data Source=(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = XE)));User Id=particular; Password=Welcome1; Enlist=dynamic" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
186+
echo "OracleConnectionString_Particular2=Data Source=(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = XE)));User Id=particular2; Password=Welcome1; Enlist=dynamic" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
187+
}
188+
189+
- name: Run tests
190+
uses: Particular/run-tests-action@v1.0.0
191+
- name: Teardown infrastructure
192+
if: ${{ always() }}
193+
shell: pwsh
194+
run: |
195+
if ('${{ matrix.engine }}' -eq 'PostgreSql') {
196+
echo "Removing container ${{ steps.setup-postgresql.outputs.name }}"
197+
$ignore = az container delete --resource-group GitHubActions-RG --name ${{ steps.setup-postgresql.outputs.name }} --yes
198+
echo "Removal complete"
199+
}

.github/workflows/release.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- '[6-9].[0-9]+.[0-9]+'
6+
- '[6-9].[0-9]+.[0-9]+-*'
7+
env:
8+
DOTNET_NOLOGO: true
9+
jobs:
10+
release:
11+
runs-on: windows-2019 # Code signing requirement https://github.com/NuGet/Home/issues/7939
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2.3.4
15+
with:
16+
fetch-depth: 0
17+
- name: Parse repo name
18+
run: |
19+
$FullName = "$env:GITHUB_REPOSITORY"
20+
$Org,$RepoName = $FullName.Split('/')
21+
echo "PARTICULAR_REPO_NAME=$RepoName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
22+
shell: pwsh
23+
- name: Setup .NET SDK
24+
uses: actions/setup-dotnet@v1.9.0
25+
with:
26+
dotnet-version: 5.0.x
27+
- name: Build
28+
run: dotnet build src --configuration Release
29+
- name: Install NuGetKeyVaultSignTool
30+
run: dotnet tool install --global NuGetKeyVaultSignTool
31+
- name: Sign NuGet Packages
32+
run: |
33+
NuGetKeyVaultSignTool sign nugets\*.nupkg `
34+
--file-digest sha256 `
35+
--timestamp-rfc3161 http://timestamp.digicert.com `
36+
--timestamp-digest sha256 `
37+
--azure-key-vault-url https://particularcodesigning.vault.azure.net `
38+
--azure-key-vault-client-id ${{ secrets.AZURE_KEY_VAULT_CLIENT_ID }} `
39+
--azure-key-vault-tenant-id ${{ secrets.AZURE_KEY_VAULT_TENANT_ID }} `
40+
--azure-key-vault-client-secret ${{ secrets.AZURE_KEY_VAULT_CLIENT_SECRET }} `
41+
--azure-key-vault-certificate ${{ secrets.AZURE_KEY_VAULT_CERTIFICATE_NAME }}
42+
shell: pwsh
43+
- name: Publish artifacts
44+
uses: actions/upload-artifact@v2.2.2
45+
with:
46+
name: nugets
47+
path: nugets/*
48+
retention-days: 1
49+
- name: Install Octopus CLI
50+
uses: OctopusDeploy/install-octopus-cli-action@v1.1.1
51+
with:
52+
version: latest
53+
- name: Create Octopus Package
54+
run: |
55+
# Creating the expected file layout for the Octopus package, including intermediate directories
56+
mkdir -p packaging/content
57+
58+
# Octopus expects NuGet packages to have an extra .nzip extension for NuGet, .czip for Chocolatey
59+
$nugets = Get-ChildItem -Path "./nugets/*.nupkg"
60+
foreach ($file in $nugets) {
61+
cp $file "./packaging/content/$($file.Name).nzip"
62+
}
63+
64+
# Octopus Deploy scripts need an executable file to recreate this metadata
65+
@"
66+
`$Branch = "${{env.GitVersion_BranchName}}"
67+
`$Version = "${{env.GitVersion_LegacySemVer}}"
68+
`$Product = "${{env.PARTICULAR_REPO_NAME}}"
69+
`$Major = "${{env.GitVersion_Major}}"
70+
`$Minor = "${{env.GitVersion_Minor}}"
71+
`$Commit = "${{env.GitVersion_Sha}}"
72+
"@ > packaging/Metadata.ps1
73+
74+
# Create the Octopus package
75+
octo pack --id="${{env.PARTICULAR_REPO_NAME}}.Deploy" --version="${{env.GitVersion_SemVer}}" --format="nupkg" --basePath="packaging" --outFolder="octopus-package"
76+
shell: pwsh
77+
- name: Publish Octopus Package Artifacts
78+
uses: actions/upload-artifact@v2.2.2
79+
with:
80+
name: octopus-package
81+
path: octopus-package/*
82+
retention-days: 1
83+
- name: Push package to Octopus Deploy
84+
uses: OctopusDeploy/push-package-action@v1.0.0
85+
with:
86+
server: https://deploy.particular.net
87+
api_key: ${{ secrets.OCTOPUS_DEPLOY_API_KEY }}
88+
packages: octopus-package/${{env.PARTICULAR_REPO_NAME}}.Deploy.${{env.GitVersion_SemVer}}.nupkg
89+
- name: Create Octopus Deploy release
90+
uses: OctopusDeploy/create-release-action@v1.0.2
91+
with:
92+
server: https://deploy.particular.net
93+
api_key: ${{ secrets.OCTOPUS_DEPLOY_API_KEY }}
94+
project: ${{env.PARTICULAR_REPO_NAME}}
95+
release_number: ${{env.GitVersion_SemVer}}
96+
package_version: ${{env.GitVersion_SemVer}}
97+
package: "GitReleaseManager:0.11.0"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
create user particular identified by Welcome1;
2+
create user particular2 identified by Welcome1;
3+
4+
grant all privileges to particular;
5+
grant all privileges to particular2;
6+
7+
exit;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[*.cs]
2+
3+
# Justification: Test project
4+
dotnet_diagnostic.CA2007.severity = none
5+
6+
# may be enabled in future
7+
dotnet_diagnostic.PS0018.severity = none # A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext
8+
9+
# Justification: Tests don't support cancellation and don't need to forward IMessageHandlerContext.CancellationToken
10+
dotnet_diagnostic.NSB0002.severity = none

src/AcceptanceTestsShared/NoPersistenceServer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using AcceptanceTesting.Customization;
77
using AcceptanceTesting.Support;
88
using Configuration.AdvancedExtensibility;
9-
using Features;
9+
using NServiceBus.Features;
1010

1111
public class NoPersistenceServer : IEndpointSetupTemplate
1212
{
@@ -20,9 +20,7 @@ public NoPersistenceServer(List<Type> typesToInclude)
2020
this.typesToInclude = typesToInclude;
2121
}
2222

23-
#pragma warning disable CS0618
2423
public async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointConfiguration, Action<EndpointConfiguration> configurationBuilderCustomization)
25-
#pragma warning restore CS0618
2624
{
2725
var types = endpointConfiguration.GetTypesScopedByTestClass();
2826

src/MsSqlMicrosoftDataClientAcceptanceTests/MsSqlMicrosoftDataClientAcceptanceTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16+
<PackageReference Include="GitHubActionsTestLogger" Version="1.2.0" />
1617
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
1718
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="7.5.0" />
1819
<PackageReference Include="NUnit" Version="3.12.0" />

src/MsSqlMicrosoftDataClientAcceptanceTests/TestSuiteConstraints.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.AcceptanceTests
1+
[assembly: SqlServerTest]
2+
3+
namespace NServiceBus.AcceptanceTests
24
{
35
using AcceptanceTesting.Support;
46

src/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15+
<PackageReference Include="GitHubActionsTestLogger" Version="1.2.0" />
1516
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
1617
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="7.5.0" GeneratePathProperty="true" />
1718
<PackageReference Include="NServiceBus.Transport.SqlServer" Version="6.1.1" />

src/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests/TestSuiteConstraints.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.AcceptanceTests
1+
[assembly: SqlServerTest]
2+
3+
namespace NServiceBus.AcceptanceTests
24
{
35
using AcceptanceTesting.Support;
46

src/MsSqlSystemDataClientAcceptanceTests/MsSqlSystemDataClientAcceptanceTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16+
<PackageReference Include="GitHubActionsTestLogger" Version="1.2.0" />
1617
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
1718
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="7.5.0" />
1819
<PackageReference Include="NUnit" Version="3.12.0" />

0 commit comments

Comments
 (0)