-
Notifications
You must be signed in to change notification settings - Fork 5
53 lines (43 loc) · 2.28 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Build and test
on: [push]
defaults:
run:
shell: pwsh
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build docker images
run: docker compose -f ./sqlinstance/docker-compose.yml up --force-recreate --build --remove-orphans -d
- name: Stop newly built containers and remove volumes
run: docker compose -f ./sqlinstance/docker-compose.yml down --volumes
- name: Recreate the scenario from dbatools.io/docker
run: |
# create a shared network
docker network create localnet
# Expose engine then setup a shared path for migrations
docker run -p 1433:1433 --volume shared:/shared:z --hostname mssql1 --name mssql1 --network localnet -d dbatools/sqlinstance
# Expose second engine on different port and use the same shared path
docker run -p 14333:1433 --volume shared:/shared:z --hostname mssql2 --name mssql2 --network localnet -d dbatools/sqlinstance2
- name: Install and cache dbatools
uses: potatoqualitee/psmodulecache@v4
with:
modules-to-cache: dbatools
- name: Test that commands continue to work with new build
run: |
$null = Invoke-Pester ./tests/actions.ps1 -Output Detailed -PassThru
Get-DbatoolsError -All
- name: Remove containers
run: docker rm -vf mssql1 mssql2
- name: Recreate the scenario from the env PR
run: |
docker run -p 1433:1433 --volume shared:/shared:z --name mssql1 --hostname mssql1 --network localnet --env MSSQL_DB=mydb1 -d dbatools/sqlinstance
docker run -p 14333:1433 --volume shared:/shared:z --name mssql2 --hostname mssql2 --network localnet --env MSSQL_DB=mydb2 -d dbatools/sqlinstance2
sleep 20
- name: Test that commands continue to work with new build
run: |
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
Get-DbaDatabase -SqlInstance localhost -SqlCredential $cred -Database mydb1 | Should -Not -BeNullOrEmpty
Get-DbaDatabase -SqlInstance localhost:14333 -SqlCredential $cred -Database mydb2 | Should -Not -BeNullOrEmpty