crowdsec/.github/workflows/bats-postgres.yml

86 lines
2.4 KiB
YAML
Raw Permalink Normal View History

name: (sub) Bats / Postgres
on:
workflow_call:
jobs:
build:
name: "Functional tests"
runs-on: ubuntu-latest
2023-04-05 13:15:33 +00:00
timeout-minutes: 30
services:
database:
image: postgres:16
env:
POSTGRES_PASSWORD: "secret"
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:
- name: "Install pg_dump v16"
# we can remove this when it's released on ubuntu-latest
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
sudo apt update
sudo apt -qq -y -o=Dpkg::Use-Pty=0 install postgresql-client-16
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: "Check out CrowdSec repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: "Set up Go"
uses: actions/setup-go@v5
2023-02-28 16:25:09 +00:00
with:
2024-04-25 13:11:08 +00:00
go-version: "1.22.2"
2023-02-28 16:25:09 +00:00
- name: "Install bats dependencies"
env:
GOBIN: /usr/local/bin
run: |
sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq libre2-dev
- name: "Build crowdsec and fixture (DB_BACKEND: pgx)"
run: |
make clean bats-build bats-fixture BUILD_STATIC=1
2022-03-23 10:13:23 +00:00
env:
DB_BACKEND: pgx
PGHOST: 127.0.0.1
PGPORT: 5432
PGPASSWORD: "secret"
PGUSER: postgres
2022-03-23 10:13:23 +00:00
- name: "Run tests (DB_BACKEND: pgx)"
2024-02-12 19:15:16 +00:00
run: ./test/run-tests ./test/bats --formatter $(pwd)/test/lib/color-formatter
2022-03-23 10:13:23 +00:00
env:
DB_BACKEND: pgx
PGHOST: 127.0.0.1
PGPORT: 5432
PGPASSWORD: "secret"
PGUSER: postgres
2022-03-23 10:13:23 +00:00
2022-11-25 11:02:38 +00:00
- 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 ./test/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 }}"
2022-03-25 11:17:28 +00:00
if: ${{ always() }}