database-anonymizer/.woodpecker/test.yml

55 lines
1.3 KiB
YAML

when:
- event: [pull_request, tag]
- event: push
branch:
- ${CI_REPO_DEFAULT_BRANCH}
- release/*
- renovate/*
variables:
- &golang_image 'golang:1.22.0'
- &mysql_image 'mariadb:10.3'
- &postgres_image 'postgres:16'
steps:
"Add vendor":
image: *golang_image
commands:
- go mod vendor
"Wait databases":
image: gitnet.fr/deblan/timeout:latest
commands:
- /bin/timeout -t 30 -v -c 'while true; do nc -z -v service-mysql 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done'
- /bin/timeout -t 30 -v -c 'while true; do nc -z -v service-postgres 5432 2>&1 | grep succeeded && exit 0; sleep 0.5; done'
"Fill MySQL":
image: *mysql_image
commands:
- mysql -hservice-mysql -uroot -proot test < tests/mysql_data.sql
"Fill PostgresSQL":
image: *postgres_image
commands:
- psql -U postgres -h service-postgres -d test < tests/postgres_data.sql
"Run tests":
image: *golang_image
commands:
- go test -v ./...
services:
service-postgres:
image: *postgres_image
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=test
- POSTGRES_HOST_AUTH_METHOD=trust
service-mysql:
image: *mysql_image
environment:
- MYSQL_DATABASE=test
- MARIADB_ROOT_PASSWORD=root