Bump Particular.Approvals from 0.3.0 to 0.5.0 #1307
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- master | |
- release-* | |
pull_request: | |
workflow_dispatch: | |
env: | |
DOTNET_NOLOGO: true | |
jobs: | |
build: | |
name: ${{ matrix.os-name }}-${{ matrix.engine }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-2022, ubuntu-22.04] | |
engine: [SqlServer, MySql, PostgreSql, Oracle] | |
include: | |
# Add os-name alias for job name | |
- os: windows-2022 | |
os-name: Windows | |
- os: ubuntu-22.04 | |
os-name: Linux | |
fail-fast: false | |
steps: | |
- name: Check for secrets | |
env: | |
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }} | |
shell: pwsh | |
run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 }) | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET SDK | |
uses: actions/[email protected] | |
with: | |
dotnet-version: 8.0.x | |
dotnet-quality: 'preview' | |
- name: Build | |
run: dotnet build src --configuration Release | |
- name: Upload packages | |
uses: actions/[email protected] | |
with: | |
name: NuGet packages | |
path: nugets/ | |
retention-days: 7 | |
- name: Azure login | |
uses: azure/[email protected] | |
if: matrix.engine == 'PostgreSQL' || (matrix.engine == 'Oracle' && matrix.os-name == 'Windows') | |
with: | |
creds: ${{ secrets.AZURE_ACI_CREDENTIALS }} | |
- name: Setup SQL Server | |
if: matrix.engine == 'SqlServer' | |
uses: Particular/[email protected] | |
with: | |
connection-string-env-var: SQLServerConnectionString | |
catalog: nservicebus | |
extra-params: "Encrypt=False;" | |
- name: Setup PostgreSql 15.x | |
id: setup-postgresql | |
if: matrix.engine == 'PostgreSql' | |
shell: pwsh | |
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:15 --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' | |
shell: pwsh | |
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/[email protected] | |
with: | |
connection-string-name: OracleConnectionString | |
init-script: ./.github/workflows/scripts/setup-oracle-database-users-and-permissions.sql | |
tag: SqlPersistence | |
- name: Prepare Connection Strings for Oracle | |
if: matrix.engine == 'Oracle' | |
shell: pwsh | |
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/[email protected] | |
- name: Teardown infrastructure | |
if: ${{ always() }} | |
shell: pwsh | |
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" | |
} |