Repository navigation
78 lines (66 loc) · 2.46 KB
/
Copy pathbats-hub.yml
File metadata and controls
78 lines (66 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: (sub) Bats / Hub
on:
workflow_call:
secrets:
GIST_BADGES_SECRET:
required: true
GIST_BADGES_ID:
required: true
permissions:
contents: read
jobs:
build:
name: "Functional tests"
runs-on: ubuntu-latest
timeout-minutes: 30
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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
submodules: true
persist-credentials: false
- name: "Set up Go"
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
- 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"
# fetch the hub index from a git clone to avoid cdn-hub rate limiting (403)
env:
TEST_HUB_CLONE: "true"
run: make bats-clean bats-build bats-fixture BUILD_STATIC=1
- name: "Run hub tests"
run: |
PATH=$(pwd)/test/local/bin:$PATH
./test/instance-data load
sudo install -d -o "$USER" /hub
git clone --depth 1 https://github.com/crowdsecurity/hub.git /hub
cd /hub
cscli hubtest run --all --clean --max-jobs 4
- name: "Collect hub coverage"
run: ./test/bin/collect-hub-coverage /hub >> $GITHUB_ENV
- name: "Update coverage badges"
if: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'crowdsecurity' }}
env:
GH_TOKEN: ${{ secrets.GIST_BADGES_SECRET }}
GIST_ID: ${{ secrets.GIST_BADGES_ID }}
run: |
set -euo pipefail
# shields.io endpoint badge, written as a gist file
badge() { jq -nc --arg l "$1" --arg m "$2" --arg c "$3" \
'{schemaVersion:1,label:$l,message:$m,color:$c}'; }
jq -n \
--arg p "$(badge 'Hub Parsers' "$PARSERS_COV" "$PARSERS_BADGE_COLOR")" \
--arg s "$(badge 'Hub Scenarios' "$SCENARIOS_COV" "$SCENARIOS_BADGE_COLOR")" \
'{files:{"crowdsec_parsers_badge.json":{content:$p},
"crowdsec_scenarios_badge.json":{content:$s}}}' \
| gh api --method PATCH "/gists/${GIST_ID}" --input -