From d329af12a16cee0dc131e50d364b75ee4e2a2c52 Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Fri, 10 Jun 2022 16:13:28 +0200 Subject: [PATCH] .github/workflows: Add DB tests --- .github/workflows/tests.yml | 39 +++++++++++++++++++++++++++++++++++++ test/cases/base_tests.sh | 22 --------------------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 58073dd95..ddd1ff396 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,6 +38,45 @@ jobs: - name: Send coverage to codecov.io run: bash <(curl -s https://codecov.io/bash) + db-tests: + name: "🗄 DB tests" + runs-on: ubuntu-20.04 + services: + postgres: + # 12 is used in deployments + image: postgres:12 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: foobar + POSTGRES_DB: osbuildcomposer + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.16 + - env: + PGUSER: postgres + PGPASSWORD: foobar + PGDATABASE: osbuildcomposer + PGHOST: localhost + PGPORT: 5432 + run: | + WORKDIR=$(readlink -f pkg/jobqueue/dbjobqueue/schemas) + pushd $(mktemp -d) + go mod init temp + go get -u github.com/jackc/tern + go run github.com/jackc/tern migrate -m "$WORKDIR" + popd + - run: go test -tags=integration ./cmd/osbuild-composer-dbjobqueue-tests + - run: go test -tags=integration ./cmd/osbuild-service-maintenance + python-lint: name: "🐍 Lint (dnf-json)" runs-on: ubuntu-latest diff --git a/test/cases/base_tests.sh b/test/cases/base_tests.sh index d262a2e94..ce7762d8a 100755 --- a/test/cases/base_tests.sh +++ b/test/cases/base_tests.sh @@ -18,7 +18,6 @@ TEST_CASES=( "osbuild-dnf-json-tests" "osbuild-composer-cli-tests" "osbuild-auth-tests" - "osbuild-composer-dbjobqueue-tests" ) # Print out a nice test divider so we know when tests stop and start. @@ -48,27 +47,6 @@ run_test_case () { # Provision the software under test. /usr/libexec/osbuild-composer-test/provision.sh -# Set up a basic postgres db -sudo dnf install -y go postgresql postgresql-server postgresql-contrib -PWFILE=$(sudo -u postgres mktemp) -cat <