Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

FEATURE (deploy): Run tests on each deployment

Rostislav Dugin200429dbab83
diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml
index 6fd88c58..acd7d923 100644
--- a/.github/workflows/ci-release.yml
+++ b/.github/workflows/ci-release.yml
@@ -80,9 +80,101 @@ jobs:
cd frontend
npm run lint
+ test-backend:
+ runs-on: ubuntu-latest
+ needs: [lint-backend]
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v4
+
+ - name: Set up Go
+ uses: actions/setup-go@v5
+ with:
+ go-version: "1.23.3"
+
+ - name: Cache Go modules
+ uses: actions/cache@v4
+ with:
+ path: |
+ ~/go/pkg/mod
+ ~/.cache/go-build
+ key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
+ restore-keys: |
+ ${{ runner.os }}-go-
+
+ - name: Create .env file for testing
+ run: |
+ cd backend
+ cat > .env << EOF
+ # docker-compose.yml
+ DEV_DB_NAME=postgresus
+ DEV_DB_USERNAME=postgres
+ DEV_DB_PASSWORD=Q1234567
+ #app
+ ENV_MODE=development
+ # db
+ DATABASE_DSN=host=localhost user=postgres password=Q1234567 dbname=postgresus port=5437 sslmode=disable
+ DATABASE_URL=postgres://postgres:Q1234567@localhost:5437/postgresus?sslmode=disable
+ # migrations
+ GOOSE_DRIVER=postgres
+ GOOSE_DBSTRING=postgres://postgres:Q1234567@localhost:5437/postgresus?sslmode=disable
+ GOOSE_MIGRATION_DIR=./migrations
+ # testing
+ # to get Google Drive env variables: add storage in UI and copy data from added storage here
+ TEST_GOOGLE_DRIVE_CLIENT_ID=${{ secrets.TEST_GOOGLE_DRIVE_CLIENT_ID }}
+ TEST_GOOGLE_DRIVE_CLIENT_SECRET=${{ secrets.TEST_GOOGLE_DRIVE_CLIENT_SECRET }}
+ TEST_GOOGLE_DRIVE_TOKEN_JSON=${{ secrets.TEST_GOOGLE_DRIVE_TOKEN_JSON }}
+ # testing DBs
+ TEST_POSTGRES_13_PORT=5001
+ TEST_POSTGRES_14_PORT=5002
+ TEST_POSTGRES_15_PORT=5003
+ TEST_POSTGRES_16_PORT=5004
+ TEST_POSTGRES_17_PORT=5005
+ # testing S3
+ TEST_MINIO_PORT=9000
+ TEST_MINIO_CONSOLE_PORT=9001
+ EOF
+
+ - name: Start test containers
+ run: |
+ cd backend
+ docker-compose -f docker-compose.yml.example up -d
+
+ - name: Wait for containers to be ready
+ run: |
+ # Wait for main dev database
+ timeout 60 bash -c 'until docker exec dev-db pg_isready -h localhost -p 5437 -U postgres; do sleep 2; done'
+
+ # Wait for test databases
+ timeout 60 bash -c 'until nc -z localhost 5001; do sleep 2; done'
+ timeout 60 bash -c 'until nc -z localhost 5002; do sleep 2; done'
+ timeout 60 bash -c 'until nc -z localhost 5003; do sleep 2; done'
+ timeout 60 bash -c 'until nc -z localhost 5004; do sleep 2; done'
+ timeout 60 bash -c 'until nc -z localhost 5005; do sleep 2; done'
+
+ # Wait for MinIO
+ timeout 60 bash -c 'until nc -z localhost 9000; do sleep 2; done'
+
+ - name: Run database migrations
+ run: |
+ cd backend
+ go install github.com/pressly/goose/v3/cmd/goose@latest
+ goose -dir migrations postgres "postgres://postgres:Q1234567@localhost:5437/postgresus?sslmode=disable" up
+
+ - name: Run Go tests
+ run: |
+ cd backend
+ go test ./internal/...
+
+ - name: Stop test containers
+ if: always()
+ run: |
+ cd backend
+ docker-compose -f docker-compose.yml.example down -v
+
determine-version:
runs-on: ubuntu-latest
- needs: [lint-backend, lint-frontend]
+ needs: [test-backend, lint-frontend]
if: ${{ !contains(github.event.head_commit.message, '[skip-release]') }}
outputs:
should_release: ${{ steps.version_bump.outputs.should_release }}
@@ -175,7 +267,7 @@ jobs:
build-only:
runs-on: ubuntu-latest
- needs: [lint-backend, lint-frontend]
+ needs: [test-backend, lint-frontend]
if: ${{ contains(github.event.head_commit.message, '[skip-release]') }}
steps:
- name: Check out code