feat(code-coverage): refactor test workflows - part 9 #3
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
on: | |
workflow_call: | |
inputs: | |
run: | |
type: boolean | |
default: true | |
schemas: | |
type: string | |
default: '' | |
backend_exclude: | |
type: string | |
default: '' | |
jobs: | |
test-sqlite: | |
if: ${{ inputs.run && !contains(inputs.backend_exclude, 'sqlite')}} | |
name: 🧪 Tests (${{ matrix.config.backend }}) | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- backend: SQLite - no schemas | |
args: 'list(dbname = file.path(tempdir(), "SQLite"))' | |
post_connect: '' | |
- backend: SQLite - w. schemas | |
args: 'list(dbname = file.path(tempdir(), "SQLite_schemas"))' | |
post_connect: > | |
list(paste0("ATTACH '", file.path(tempdir(), "SQLite_schemas_test"), "' AS 'test'"), | |
paste0("ATTACH '", file.path(tempdir(), "SQLite_schemas_test_one"), "' AS 'test.one'")) | |
env: | |
BACKEND: ${{ matrix.config.backend }} | |
BACKEND_DRV: RSQLite::SQLite | |
BACKEND_ARGS: ${{ matrix.config.args }} | |
BACKEND_POST_CONNECT: ${{ matrix.config.post_connect }} | |
steps: | |
- uses: ssi-dk/AEF-DDF/.github/workflows/code-coverage-and-test.yaml@feature/mssql_code_coverage | |
test-postgres: | |
name: 🧪 Tests (postgres) | |
if: ${{ inputs.run && !contains(inputs.backend_exclude, 'postgres')}} | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: test | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- 5432:5432 | |
options: --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 | |
env: | |
BACKEND: PostgreSQL | |
BACKEND_DRV: RPostgres::Postgres | |
BACKEND_ARGS: '' | |
PGHOST: localhost | |
PGPORT: 5432 | |
PGDATABASE: test | |
PGUSER: postgres | |
PGPASSWORD: postgres | |
steps: | |
- name: Setup testing schemata in PostgreSQL | |
if: ${{ inputs.schemas != 'none' }} | |
run: | | |
set -o xtrace | |
IFS=',' read -ra schemas <<< "${{ inputs.schemas }}" | |
for schema in "${schemas[@]}"; do | |
psql test -c "CREATE SCHEMA \"$schema\";" | |
done | |
- uses: ssi-dk/AEF-DDF/.github/workflows/code-coverage-and-test.yaml@feature/mssql_code_coverage | |
test-mssql: | |
name: 🧪 Tests (SQL Server 2019) | |
if: ${{ inputs.run && !contains(inputs.backend_exclude, 'mssql')}} | |
env: | |
BACKEND: MSSQL | |
BACKEND_DRV: odbc::odbc | |
BACKEND_ARGS: '' | |
CONN_ARGS_JSON: '{"MSSQL": {"driver": "SQL Server", "server": "localhost", "database": "TestDB", "trusted_connection": "true"}}' | |
steps: | |
- name: Install a SQL Server suite of tools | |
uses: potatoqualitee/[email protected] | |
with: | |
install: sqlengine, sqlpackage | |
- name: Configure database | |
run: | | |
sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "CREATE DATABASE TestDB;" | |
sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "GO" | |
sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "USE TestDB;" | |
sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "GO" | |
- name: Setup testing schemata in SQL server | |
if: ${{ inputs.schemas != 'none' }} | |
run: | | |
set -o xtrace | |
IFS=',' read -ra schemas <<< "${{ inputs.schemas }}" | |
for schema in "${schemas[@]}"; do | |
sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "CREATE SCHEMA [$schema];" | |
sqlcmd -V 10 -S localhost -U SA -P dbatools.I0 -d tempdb -Q "GO" | |
done | |
- uses: ssi-dk/AEF-DDF/.github/workflows/code-coverage-and-test.yaml@feature/mssql_code_coverage |