101 lines
2.7 KiB
YAML
101 lines
2.7 KiB
YAML
name: Functional tests (Postgres)
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
env:
|
|
PREFIX_TEST_NAMES_WITH_FILE: true
|
|
|
|
jobs:
|
|
build:
|
|
name: "Build + tests"
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
services:
|
|
database:
|
|
image: postgres:14
|
|
env:
|
|
POSTGRES_PASSWORD: "secret"
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd pg_isready -u postgres
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
steps:
|
|
|
|
- name: "Force machineid"
|
|
run: |
|
|
sudo chmod +w /etc/machine-id
|
|
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
|
|
|
|
- name: "Set up Go 1.20"
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: 1.20.1
|
|
id: go
|
|
|
|
- name: "Check out CrowdSec repository"
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: true
|
|
|
|
- name: "Install bats dependencies"
|
|
run: |
|
|
sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq netcat-openbsd
|
|
go install github.com/mikefarah/yq/v4@latest
|
|
go install github.com/cloudflare/cfssl/cmd/cfssl@master
|
|
go install github.com/cloudflare/cfssl/cmd/cfssljson@master
|
|
sudo cp -u ~/go/bin/yq ~/go/bin/cfssl ~/go/bin/cfssljson /usr/local/bin/
|
|
|
|
- name: "Build crowdsec and fixture (DB_BACKEND: pgx)"
|
|
run: |
|
|
make clean bats-build bats-fixture
|
|
env:
|
|
DB_BACKEND: pgx
|
|
PGHOST: 127.0.0.1
|
|
PGPORT: 5432
|
|
PGPASSWORD: "secret"
|
|
PGUSER: postgres
|
|
|
|
- name: "Run tests (DB_BACKEND: pgx)"
|
|
run: make bats-test
|
|
env:
|
|
DB_BACKEND: pgx
|
|
PGHOST: 127.0.0.1
|
|
PGPORT: 5432
|
|
PGPASSWORD: "secret"
|
|
PGUSER: postgres
|
|
|
|
# - 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: "secret"
|
|
# PGUSER: postgres
|
|
#
|
|
# - name: "Run tests (DB_BACKEND: postgres)"
|
|
# run: make bats-test
|
|
# env:
|
|
# DB_BACKEND: postgres
|
|
# PGHOST: 127.0.0.1
|
|
# PGPORT: 5432
|
|
# PGPASSWORD: "secret"
|
|
# PGUSER: postgres
|
|
|
|
- name: "Show stack traces"
|
|
run: for file in $(find /tmp/crowdsec-crash.*.txt); do echo ">>>>> $file"; cat $file; echo; done
|
|
if: ${{ always() }}
|
|
|
|
- name: "Show crowdsec logs"
|
|
run: for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
|
|
if: ${{ always() }}
|
|
|
|
- name: "Show database logs"
|
|
run: docker logs "${{ job.services.database.id }}"
|
|
if: ${{ always() }}
|