2022-06-17 14:12:49 +00:00
|
|
|
name: Functional tests (Postgres)
|
2022-03-21 14:51:05 +00:00
|
|
|
|
|
|
|
on:
|
2022-04-05 09:00:11 +00:00
|
|
|
workflow_call:
|
2022-03-21 14:51:05 +00:00
|
|
|
|
2022-06-17 14:12:49 +00:00
|
|
|
env:
|
|
|
|
PREFIX_TEST_NAMES_WITH_FILE: true
|
|
|
|
|
2022-03-21 14:51:05 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2022-04-01 12:12:03 +00:00
|
|
|
name: "Build + tests"
|
2022-03-21 14:51:05 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 20
|
|
|
|
services:
|
2022-04-01 12:12:03 +00:00
|
|
|
database:
|
2022-10-17 07:21:55 +00:00
|
|
|
image: postgres:14
|
2022-03-21 14:51:05 +00:00
|
|
|
env:
|
2022-09-01 14:49:12 +00:00
|
|
|
POSTGRES_PASSWORD: "secret"
|
2022-03-21 14:51:05 +00:00
|
|
|
ports:
|
|
|
|
- 5432:5432
|
|
|
|
options: >-
|
2022-03-25 11:17:28 +00:00
|
|
|
--health-cmd pg_isready -u postgres
|
2022-03-21 14:51:05 +00:00
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
2022-04-13 13:44:23 +00:00
|
|
|
|
2022-03-21 14:51:05 +00:00
|
|
|
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
|
|
|
|
|
2023-02-15 13:27:17 +00:00
|
|
|
- name: "Set up Go 1.20"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/setup-go@v3
|
2022-03-21 14:51:05 +00:00
|
|
|
with:
|
2023-02-15 13:27:17 +00:00
|
|
|
go-version: 1.20.1
|
2022-03-21 14:51:05 +00:00
|
|
|
id: go
|
|
|
|
|
2022-06-17 14:12:49 +00:00
|
|
|
- name: "Check out CrowdSec repository"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-03-21 14:51:05 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
|
|
|
|
|
|
|
- name: "Install bats dependencies"
|
2023-02-15 13:27:47 +00:00
|
|
|
env:
|
|
|
|
GOBIN: /usr/local/bin
|
2022-03-21 14:51:05 +00:00
|
|
|
run: |
|
2022-06-17 14:12:49 +00:00
|
|
|
sudo apt -qq -y -o=Dpkg::Use-Pty=0 install build-essential daemonize jq netcat-openbsd
|
2022-06-08 14:05:52 +00:00
|
|
|
go install github.com/mikefarah/yq/v4@latest
|
2022-08-26 11:31:49 +00:00
|
|
|
go install github.com/cloudflare/cfssl/cmd/cfssl@master
|
|
|
|
go install github.com/cloudflare/cfssl/cmd/cfssljson@master
|
2022-03-21 14:51:05 +00:00
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Build crowdsec and fixture (DB_BACKEND: pgx)"
|
2022-06-17 14:12:49 +00:00
|
|
|
run: |
|
|
|
|
make clean bats-build bats-fixture
|
2022-03-23 10:13:23 +00:00
|
|
|
env:
|
|
|
|
DB_BACKEND: pgx
|
2022-03-28 08:41:32 +00:00
|
|
|
PGHOST: 127.0.0.1
|
|
|
|
PGPORT: 5432
|
2022-09-01 14:49:12 +00:00
|
|
|
PGPASSWORD: "secret"
|
2022-03-28 08:41:32 +00:00
|
|
|
PGUSER: postgres
|
2022-03-23 10:13:23 +00:00
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Run tests (DB_BACKEND: pgx)"
|
2022-04-01 13:03:17 +00:00
|
|
|
run: make bats-test
|
2022-03-23 10:13:23 +00:00
|
|
|
env:
|
|
|
|
DB_BACKEND: pgx
|
2022-03-28 08:41:32 +00:00
|
|
|
PGHOST: 127.0.0.1
|
|
|
|
PGPORT: 5432
|
2022-09-01 14:49:12 +00:00
|
|
|
PGPASSWORD: "secret"
|
2022-03-28 08:41:32 +00:00
|
|
|
PGUSER: postgres
|
2022-03-23 10:13:23 +00:00
|
|
|
|
2022-11-08 11:27:31 +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: "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
|
2022-03-25 11:17:28 +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() }}
|
|
|
|
|
2022-04-13 13:03:37 +00:00
|
|
|
- name: "Show crowdsec logs"
|
2022-11-25 11:02:38 +00:00
|
|
|
run: for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
|
2022-04-13 13:03:37 +00:00
|
|
|
if: ${{ always() }}
|
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Show database logs"
|
|
|
|
run: docker logs "${{ job.services.database.id }}"
|
2022-03-25 11:17:28 +00:00
|
|
|
if: ${{ always() }}
|