crowdsec/.github/workflows/ci_bats_postgres.yaml

93 lines
2.3 KiB
YAML
Raw Normal View History

name: Functional tests with PostgreSQL
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
name: "Build + tests"
runs-on: ubuntu-latest
timeout-minutes: 20
services:
database:
image: postgres:latest
env:
POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
ports:
- 5432:5432
options: >-
2022-03-25 11:17:28 +00:00
--health-cmd pg_isready -u postgres
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
2022-03-22 11:33:36 +00:00
- name: "Force machineid"
run: |
sudo chmod +w /etc/machine-id
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
- name: "Set up Go 1.17"
uses: actions/setup-go@v1
with:
go-version: 1.17
id: go
- name: "Clone CrowdSec"
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: "Install bats dependencies"
run: |
sudo apt install -y -qq build-essential daemonize jq netcat-openbsd
GO111MODULE=on go get github.com/mikefarah/yq/v4
sudo cp -u ~/go/bin/yq /usr/local/bin/
- name: "Build crowdsec and fixture (DB_BACKEND: pgx)"
run: make clean bats-build bats-fixture
2022-03-23 10:13:23 +00:00
env:
DB_BACKEND: pgx
PGHOST: 127.0.0.1
PGPORT: 5432
PGPASSWORD: ${{ secrets.DATABASE_PASSWORD }}
PGUSER: postgres
2022-03-23 10:13:23 +00:00
- name: "Run tests (DB_BACKEND: pgx)"
run: make bats-test
2022-03-23 10:13:23 +00:00
env:
DB_BACKEND: pgx
PGHOST: 127.0.0.1
PGPORT: 5432
PGPASSWORD: ${{ secrets.DATABASE_PASSWORD }}
PGUSER: postgres
2022-03-23 10:13:23 +00:00
- name: "Build crowdsec and fixture (DB_BACKEND: postgres)"
run: make clean bats-build bats-fixture
env:
DB_BACKEND: postgres
PGHOST: 127.0.0.1
PGPORT: 5432
PGPASSWORD: ${{ secrets.DATABASE_PASSWORD }}
PGUSER: postgres
- name: "Run tests (DB_BACKEND: postgres)"
run: make bats-test
env:
DB_BACKEND: postgres
PGHOST: 127.0.0.1
PGPORT: 5432
PGPASSWORD: ${{ secrets.DATABASE_PASSWORD }}
PGUSER: postgres
2022-03-25 11:17:28 +00:00
- name: "Show database logs"
run: docker logs "${{ job.services.database.id }}"
2022-03-25 11:17:28 +00:00
if: ${{ always() }}