2022-04-01 12:12:03 +00:00
|
|
|
name: Functional tests with MySQL
|
2022-03-18 16:36:51 +00:00
|
|
|
|
|
|
|
on:
|
2022-04-05 09:00:11 +00:00
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
database_image:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
secrets:
|
|
|
|
DATABASE_PASSWORD:
|
|
|
|
required: true
|
2022-03-18 16:36:51 +00:00
|
|
|
|
|
|
|
jobs:
|
2022-04-13 13:44:23 +00:00
|
|
|
|
2022-03-18 16:36:51 +00:00
|
|
|
build:
|
2022-04-01 12:12:03 +00:00
|
|
|
name: "Build + tests"
|
2022-03-18 16:36:51 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 20
|
|
|
|
services:
|
2022-04-01 12:12:03 +00:00
|
|
|
database:
|
2022-04-05 09:00:11 +00:00
|
|
|
image: ${{ inputs.database_image }}
|
2022-03-18 16:36:51 +00:00
|
|
|
env:
|
2022-03-23 08:40:23 +00:00
|
|
|
MYSQL_ROOT_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
|
2022-03-18 16:36:51 +00:00
|
|
|
ports:
|
|
|
|
- 3306:3306
|
2022-04-13 13:44:23 +00:00
|
|
|
|
2022-03-18 16:36:51 +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
|
|
|
|
|
2022-03-18 16:36:51 +00:00
|
|
|
- name: "Set up Go 1.17"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/setup-go@v3
|
2022-03-18 16:36:51 +00:00
|
|
|
with:
|
|
|
|
go-version: 1.17
|
|
|
|
id: go
|
|
|
|
|
|
|
|
- name: "Clone CrowdSec"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-03-18 16:36:51 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
|
|
|
|
|
|
|
- name: "Install bats dependencies"
|
|
|
|
run: |
|
2022-04-01 12:12:03 +00:00
|
|
|
sudo apt install -y -qq build-essential daemonize jq netcat-openbsd
|
2022-03-18 16:36:51 +00:00
|
|
|
GO111MODULE=on go get github.com/mikefarah/yq/v4
|
2022-04-01 12:12:03 +00:00
|
|
|
sudo cp -u ~/go/bin/yq /usr/local/bin/
|
2022-03-18 16:36:51 +00:00
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Build crowdsec and fixture"
|
|
|
|
run: make bats-clean bats-build bats-fixture
|
2022-03-18 16:36:51 +00:00
|
|
|
env:
|
|
|
|
DB_BACKEND: mysql
|
|
|
|
MYSQL_HOST: 127.0.0.1
|
|
|
|
MYSQL_PORT: 3306
|
2022-03-23 08:40:23 +00:00
|
|
|
MYSQL_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
|
2022-03-18 16:36:51 +00:00
|
|
|
MYSQL_USER: root
|
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Run tests"
|
2022-03-18 16:36:51 +00:00
|
|
|
run: make bats-test
|
|
|
|
env:
|
|
|
|
DB_BACKEND: mysql
|
|
|
|
MYSQL_HOST: 127.0.0.1
|
|
|
|
MYSQL_PORT: 3306
|
2022-03-23 08:40:23 +00:00
|
|
|
MYSQL_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
|
2022-03-18 16:36:51 +00:00
|
|
|
MYSQL_USER: root
|
2022-03-25 11:17:28 +00:00
|
|
|
|
2022-04-13 13:03:37 +00:00
|
|
|
- name: "Show crowdsec logs"
|
|
|
|
run:
|
|
|
|
for file in $(find ./tests/local/var/log -type f); do echo ">>>>> $file"; cat $file; echo; done
|
|
|
|
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() }}
|
|
|
|
|