Skip to content

feat(code-coverage): refactor test workflows - part 7 #1

feat(code-coverage): refactor test workflows - part 7

feat(code-coverage): refactor test workflows - part 7 #1

on:

Check failure on line 1 in .github/workflows/test-dispatcher.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/test-dispatcher.yaml

Invalid workflow file

Cannot define both `uses` and `steps` at the same time for the following jobs: test-mssql, test-postgres, test-sqlite
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 }})
uses: ./.github/workflows/code-coverage-and-test.yaml
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: actions/checkout@v4
test-postgres:
name: 🧪 Tests (postgres)
if: ${{ inputs.run && !contains(inputs.backend_exclude, 'postgres')}}
uses: ./.github/workflows/code-coverage-and-test.yaml
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: actions/checkout@v4
test-mssql:
name: 🧪 Tests (SQL Server 2019)
if: ${{ inputs.run && !contains(inputs.backend_exclude, 'mssql')}}
uses: ./.github/workflows/code-coverage-and-test.yaml
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: actions/checkout@v4