92 lines
2.4 KiB
YAML
92 lines
2.4 KiB
YAML
name: (sub) Bats / MySQL
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
database_image:
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
name: "Functional tests"
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
services:
|
|
database:
|
|
image: ${{ inputs.database_image }}
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: "secret"
|
|
ports:
|
|
- 3306:3306
|
|
|
|
steps:
|
|
|
|
- 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
|
|
with:
|
|
go-version: "1.21.8"
|
|
|
|
- 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"
|
|
run: |
|
|
make clean bats-build bats-fixture BUILD_STATIC=1
|
|
env:
|
|
DB_BACKEND: mysql
|
|
MYSQL_HOST: 127.0.0.1
|
|
MYSQL_PORT: 3306
|
|
MYSQL_PASSWORD: "secret"
|
|
MYSQL_USER: root
|
|
|
|
- name: "Run tests"
|
|
run: ./test/run-tests ./test/bats --formatter $(pwd)/test/lib/color-formatter
|
|
env:
|
|
DB_BACKEND: mysql
|
|
MYSQL_HOST: 127.0.0.1
|
|
MYSQL_PORT: 3306
|
|
MYSQL_PASSWORD: "secret"
|
|
MYSQL_USER: root
|
|
|
|
#
|
|
# In case you need to inspect the database status after the failure of a given test
|
|
#
|
|
# - name: "Run specified tests"
|
|
# run: ./test/run-tests test/bats/<filename>.bats -f "<test name>"
|
|
|
|
- name: Show database dump
|
|
run: ./test/instance-db dump /dev/fd/1
|
|
env:
|
|
DB_BACKEND: mysql
|
|
MYSQL_HOST: 127.0.0.1
|
|
MYSQL_PORT: 3306
|
|
MYSQL_PASSWORD: "secret"
|
|
MYSQL_USER: root
|
|
if: ${{ always() }}
|
|
|
|
- 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 }}"
|
|
if: ${{ always() }}
|