2022-03-21 14:51:05 +00:00
|
|
|
name: bats / functional tests with PostgreSQL
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: "Build the application"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 20
|
|
|
|
services:
|
|
|
|
postgres:
|
|
|
|
image: postgres:latest
|
|
|
|
env:
|
2022-03-23 08:40:23 +00:00
|
|
|
POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
|
2022-03-21 14:51:05 +00:00
|
|
|
ports:
|
|
|
|
- 5432:5432
|
|
|
|
options: >-
|
|
|
|
--health-cmd pg_isready
|
|
|
|
--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
|
|
|
|
|
2022-03-21 14:51:05 +00:00
|
|
|
- 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 daemonize netcat-openbsd
|
|
|
|
GO111MODULE=on go get github.com/mikefarah/yq/v4
|
|
|
|
|
|
|
|
- name: "BATS: build crowdsec"
|
|
|
|
run: make bats-clean bats-build
|
|
|
|
env:
|
|
|
|
DB_BACKEND: postgres
|
|
|
|
POSTGRES_HOST: 127.0.0.1
|
|
|
|
POSTGRES_PORT: 5432
|
2022-03-23 08:40:23 +00:00
|
|
|
POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
|
2022-03-21 14:51:05 +00:00
|
|
|
POSTGRES_USER: postgres
|
|
|
|
|
|
|
|
- name: "BATS: run tests"
|
|
|
|
run: make bats-test
|
|
|
|
env:
|
|
|
|
DB_BACKEND: postgres
|
|
|
|
POSTGRES_HOST: 127.0.0.1
|
|
|
|
POSTGRES_PORT: 5432
|
2022-03-23 08:40:23 +00:00
|
|
|
POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
|
2022-03-21 14:51:05 +00:00
|
|
|
POSTGRES_USER: postgres
|