2023-12-12 21:08:12 +01:00
|
|
|
---
|
2022-09-08 21:14:34 +02:00
|
|
|
name: Validate Database
|
|
|
|
|
|
|
|
on:
|
2022-09-08 21:26:26 +02:00
|
|
|
pull_request:
|
2022-09-08 21:14:34 +02:00
|
|
|
branches-ignore:
|
|
|
|
- 'l10n_master'
|
|
|
|
- 'gh-pages'
|
|
|
|
paths:
|
|
|
|
- 'src/Sql/**'
|
|
|
|
- 'util/Migrator/**'
|
2022-09-08 21:26:26 +02:00
|
|
|
push:
|
|
|
|
branches:
|
2023-12-12 21:08:12 +01:00
|
|
|
- 'main'
|
2022-09-08 21:26:26 +02:00
|
|
|
- 'rc'
|
|
|
|
paths:
|
|
|
|
- 'src/Sql/**'
|
|
|
|
- 'util/Migrator/**'
|
2022-09-08 21:14:34 +02:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs: {}
|
|
|
|
|
|
|
|
jobs:
|
2023-04-27 21:44:34 +02:00
|
|
|
validate:
|
|
|
|
name: Validate
|
|
|
|
runs-on: ubuntu-22.04
|
2022-09-08 21:14:34 +02:00
|
|
|
steps:
|
2023-04-27 21:44:34 +02:00
|
|
|
- name: Checkout repo
|
2023-09-25 14:34:54 +02:00
|
|
|
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
2023-04-27 21:44:34 +02:00
|
|
|
|
2022-09-08 21:14:34 +02:00
|
|
|
- name: Set up dotnet
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
|
2022-09-08 21:14:34 +02:00
|
|
|
with:
|
|
|
|
dotnet-version: '6.0.x'
|
2023-12-12 21:08:12 +01:00
|
|
|
|
2022-09-08 21:14:34 +02:00
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
dotnet --info
|
|
|
|
nuget help | grep Version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
|
|
|
|
- name: Build DACPAC
|
2023-04-27 21:44:34 +02:00
|
|
|
run: dotnet build src/Sql --configuration Release --verbosity minimal --output .
|
2022-09-08 21:14:34 +02:00
|
|
|
shell: pwsh
|
|
|
|
|
|
|
|
- name: Upload DACPAC
|
2023-09-18 16:39:38 +02:00
|
|
|
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
2022-09-08 21:14:34 +02:00
|
|
|
with:
|
|
|
|
name: sql.dacpac
|
2023-04-27 21:44:34 +02:00
|
|
|
path: Sql.dacpac
|
2022-09-08 21:14:34 +02:00
|
|
|
|
|
|
|
- name: Docker Compose up
|
|
|
|
working-directory: "dev"
|
|
|
|
run: |
|
|
|
|
cp .env.example .env
|
|
|
|
docker compose --profile mssql up -d
|
|
|
|
shell: pwsh
|
|
|
|
|
|
|
|
- name: Migrate
|
|
|
|
working-directory: "dev"
|
|
|
|
run: "pwsh ./migrate.ps1"
|
|
|
|
shell: pwsh
|
|
|
|
|
|
|
|
- name: Diff sqlproj to migrations
|
|
|
|
run: /usr/local/sqlpackage/sqlpackage /action:DeployReport /SourceFile:"Sql.dacpac" /TargetConnectionString:"Server=localhost;Database=vault_dev;User Id=SA;Password=SET_A_PASSWORD_HERE_123;Encrypt=True;TrustServerCertificate=True;" /OutputPath:"report.xml" /p:IgnoreColumnOrder=True /p:IgnoreComments=True
|
|
|
|
shell: pwsh
|
|
|
|
|
2023-02-13 15:07:42 +01:00
|
|
|
- name: Generate SQL file
|
|
|
|
run: /usr/local/sqlpackage/sqlpackage /action:Script /SourceFile:"Sql.dacpac" /TargetConnectionString:"Server=localhost;Database=vault_dev;User Id=SA;Password=SET_A_PASSWORD_HERE_123;Encrypt=True;TrustServerCertificate=True;" /OutputPath:"diff.sql" /p:IgnoreColumnOrder=True /p:IgnoreComments=True
|
|
|
|
shell: pwsh
|
|
|
|
|
2022-09-08 21:14:34 +02:00
|
|
|
- name: Upload Report
|
2023-09-18 16:39:38 +02:00
|
|
|
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
2022-09-08 21:14:34 +02:00
|
|
|
with:
|
|
|
|
name: report.xml
|
2023-02-13 15:07:42 +01:00
|
|
|
path: |
|
|
|
|
report.xml
|
|
|
|
diff.sql
|
2022-09-08 21:14:34 +02:00
|
|
|
|
|
|
|
- name: Validate XML
|
|
|
|
run: |
|
|
|
|
if grep -q "<Operations>" "report.xml"; then
|
|
|
|
echo
|
|
|
|
echo "Migrations are out of sync with sqlproj!"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Report looks good"
|
|
|
|
fi
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Docker compose down
|
|
|
|
if: ${{ always() }}
|
|
|
|
working-directory: "dev"
|
|
|
|
run: docker compose down
|
|
|
|
shell: pwsh
|