Skip to content

GitHubSync update - release-6.6 #1678

GitHubSync update - release-6.6

GitHubSync update - release-6.6 #1678

Workflow file for this run

name: CI
on:
push:
branches:
- master
- release-*
pull_request:
workflow_dispatch:
env:
DOTNET_NOLOGO: true
defaults:
run:
shell: pwsh
jobs:
build:
name: ${{ matrix.os-name }}-${{ matrix.engine }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-2019, ubuntu-20.04 ]
engine: [ SqlServer, MySql, PostgreSql, Oracle ]
include:
# Add os-name alias for job name
- os: windows-2019
os-name: Windows
- os: ubuntu-20.04
os-name: Linux
fail-fast: false
steps:
- name: Check for secrets
env:
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 })
- name: Checkout
uses: actions/checkout@v4.1.2
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: 8.0.x
- name: Build
run: dotnet build src --configuration Release
- name: Upload packages
uses: actions/upload-artifact@v4.3.1
if: matrix.name == 'Windows-SqlServer'
with:
name: NuGet packages
path: nugets/
retention-days: 7
- name: Azure login
uses: azure/login@v2.0.0
if: matrix.engine == 'PostgreSQL' || matrix.engine == 'Oracle'
with:
creds: ${{ secrets.AZURE_ACI_CREDENTIALS }}
- name: Setup SQL Server
if: matrix.engine == 'SqlServer'
uses: Particular/install-sql-server-action@v1.1.0
with:
connection-string-env-var: SQLServerConnectionString
catalog: nservicebus
- name: Setup PostgreSql
id: setup-postgresql
if: matrix.engine == 'PostgreSql'
run: |
echo "Getting the Azure region in which this workflow is running..."
$hostInfo = curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | ConvertFrom-Json
$region = $hostInfo.compute.location
echo "Actions agent running in Azure region: $region"
$name = "postgres-$(Get-Random)"
$packageTag = "Package=SqlPersistence"
$runnerOsTag = "RunnerOS=$($Env:RUNNER_OS)"
$dateTag = "Created=$(Get-Date -Format "yyyy-MM-dd")"
$password = [guid]::NewGuid().ToString("n")
echo "::add-mask::$password"
echo "Creating PostgreSQL container $name (This can take a while)"
$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
echo "name=$name" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf-8 -Append
echo "Tagging container"
$ignore = az tag create --resource-id $details.id --tags $packageTag $runnerOsTag $dateTag
$fqdn = $details.ipAddress.fqdn
echo "::add-mask::$fqdn"
$connectionString = "User ID=postgres;Password=$password;Host=$fqdn;Port=5432;Database=postgres;"
echo "PostgreSqlConnectionString=$connectionString" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
$env:PGPASSWORD = $password
# psql not in PATH on Windows
if ($Env:RUNNER_OS -eq 'Windows') {
$Env:PATH = $Env:PATH + ';' + $Env:PGBIN
}
for ($i = 0; $i -lt 24; $i++) { ## 2 minute timeout
echo "Checking for PostgreSQL connectivity $($i+1)/30..."
$ignore = psql --host $fqdn --username=postgres --list
if ($?) {
echo "Connection successful"
break;
}
sleep 5
}
- name: Setup MySQL
id: setup-mysql
if: matrix.engine == 'MySql'
run: |
echo '[client]
user=root
host=localhost' >> mysql-login
if ($Env:RUNNER_OS -eq 'Windows') {
echo "Installing MySQL from Chocolatey"
choco install mysql --limitoutput
echo 'password=' >> mysql-login
} else {
echo "Starting MySQL service preinstalled on Linux agent"
sudo systemctl start mysql.service
echo 'password=root' >> mysql-login
}
for ($i = 0; $i -lt 30; $i++) { ## 2.5 minute timeout
echo "Checking for MySQL connectivity $($i+1)/30..."
$ignore = mysql --defaults-extra-file=mysql-login -e "show databases;"
if ($?) {
echo "Connection successful"
break;
}
sleep 5
}
echo "Creating nservicebus database"
mysql --defaults-extra-file=mysql-login -D mysql -e "create database if not exists nservicebus ;"
echo "Creating user particular"
mysql --defaults-extra-file=mysql-login -D mysql -e "create user particular identified by 'Welcome1' ;"
echo "Giving user particular access to schema nservicebus"
mysql --defaults-extra-file=mysql-login -D mysql -e "grant all on *.* to particular@'%' ;"
$connectionString = "Data Source=localhost;Initial Catalog=nservicebus;User ID=particular;Password=Welcome1;AllowUserVariables=True;AutoEnlist=false;Connect Timeout=60"
echo "MySQLConnectionString=$connectionString" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Setup Oracle
id: setup-oracle
if: matrix.engine == 'Oracle'
uses: Particular/setup-oracle-action@v1.4.0
with:
connection-string-name: OracleConnectionString
init-script: ./.github/workflows/scripts/setup-database-users-and-permissions.sql
tag: SqlPersistence
- name: Prepare Connection Strings for Oracle
if: matrix.engine == 'Oracle'
run: |
$connectionString = $Env:OracleConnectionString
"OracleConnectionString=$($connectionString.Replace('system', 'particular'))" >> $Env:GITHUB_ENV
"OracleConnectionString_Particular2=$($connectionString.Replace('system', 'particular2'))" >> $Env:GITHUB_ENV
- name: Run tests
uses: Particular/run-tests-action@v1.7.0
- name: Teardown infrastructure
if: ${{ always() }}
run: |
if ('${{ matrix.engine }}' -eq 'PostgreSql') {
echo "Removing container ${{ steps.setup-postgresql.outputs.name }}"
$ignore = az container delete --resource-group GitHubActions-RG --name ${{ steps.setup-postgresql.outputs.name }} --yes
echo "Removal complete"
}