2022-04-01 12:12:03 +00:00
|
|
|
name: Hub tests
|
2022-03-09 13:45:36 +00:00
|
|
|
|
|
|
|
on:
|
2022-04-05 09:00:11 +00:00
|
|
|
workflow_call:
|
|
|
|
secrets:
|
|
|
|
GIST_BADGES_SECRET:
|
|
|
|
required: true
|
|
|
|
GIST_BADGES_ID:
|
|
|
|
required: true
|
2022-03-09 13:45:36 +00:00
|
|
|
|
2022-06-17 14:12:49 +00:00
|
|
|
env:
|
|
|
|
PREFIX_TEST_NAMES_WITH_FILE: true
|
|
|
|
|
2022-03-09 13:45:36 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2022-04-01 12:12:03 +00:00
|
|
|
name: "Build + tests"
|
2022-03-09 13:45:36 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 20
|
|
|
|
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-09 13:45:36 +00:00
|
|
|
with:
|
2023-02-15 13:27:17 +00:00
|
|
|
go-version: 1.20.1
|
2022-03-09 13:45:36 +00:00
|
|
|
id: go
|
|
|
|
|
|
|
|
- name: "Clone CrowdSec"
|
2022-04-05 09:00:11 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-03-09 13:45:36 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
|
|
|
|
|
|
|
- name: "Install bats dependencies"
|
|
|
|
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-04-01 12:12:03 +00:00
|
|
|
sudo cp -u ~/go/bin/yq /usr/local/bin/
|
2022-06-08 14:05:52 +00:00
|
|
|
sudo cp -u ~/go/bin/cfssl /usr/local/bin
|
|
|
|
sudo cp -u ~/go/bin/cfssljson /usr/local/bin
|
2022-03-09 13:45:36 +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-09 13:45:36 +00:00
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Run hub tests"
|
2022-03-21 14:51:05 +00:00
|
|
|
run: make bats-test-hub
|
2022-03-09 13:45:36 +00:00
|
|
|
|
2022-04-01 12:12:03 +00:00
|
|
|
- name: "Collect hub coverage"
|
2022-10-04 13:58:10 +00:00
|
|
|
run: ./tests/bin/collect-hub-coverage >> $GITHUB_ENV
|
2022-03-09 13:45:36 +00:00
|
|
|
|
|
|
|
- name: "Create Parsers badge"
|
2023-02-01 15:55:34 +00:00
|
|
|
uses: schneegans/dynamic-badges-action@v1.6.0
|
2022-10-28 08:11:15 +00:00
|
|
|
if: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'crowdsecurity' }}
|
2022-03-09 13:45:36 +00:00
|
|
|
with:
|
|
|
|
auth: ${{ secrets.GIST_BADGES_SECRET }}
|
|
|
|
gistID: ${{ secrets.GIST_BADGES_ID }}
|
|
|
|
filename: crowdsec_parsers_badge.json
|
|
|
|
label: Hub Parsers
|
|
|
|
message: ${{ env.PARSERS_COV }}
|
|
|
|
color: ${{ env.SCENARIO_BADGE_COLOR }}
|
|
|
|
|
|
|
|
- name: "Create Scenarios badge"
|
2023-02-01 15:55:34 +00:00
|
|
|
uses: schneegans/dynamic-badges-action@v1.6.0
|
2022-10-28 08:11:15 +00:00
|
|
|
if: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'crowdsecurity' }}
|
2022-03-09 13:45:36 +00:00
|
|
|
with:
|
|
|
|
auth: ${{ secrets.GIST_BADGES_SECRET }}
|
|
|
|
gistID: ${{ secrets.GIST_BADGES_ID }}
|
|
|
|
filename: crowdsec_scenarios_badge.json
|
|
|
|
label: Hub Scenarios
|
|
|
|
message: ${{ env.SCENARIOS_COV }}
|
|
|
|
color: ${{ env.SCENARIO_BADGE_COLOR }}
|