Skip to content

Commit e900227

Browse files
mmetcsbs2001
andauthored
Dependency updates and tests (#49)
- improve goroutine management - add "bin_args" config option - update crowdsec and third-party dependencies - refactor build and CI - functional tests Co-authored-by: Shivam Sandbhor <[email protected]> Co-authored-by: Shivam Sandbhor <[email protected]>
1 parent 19cc560 commit e900227

28 files changed

+948
-2306
lines changed

.github/workflows/build-binary-package.yml

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
uses: actions/setup-go@v3
1515
with:
1616
go-version: 1.20.1
17-
id: go
1817
- name: Check out code into the Go module directory
1918
uses: actions/checkout@v3
2019
- name: Build the binaries

.github/workflows/functional_tests.yaml

-34
This file was deleted.

.github/workflows/go.yml

-31
This file was deleted.

.github/workflows/tests.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build + tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
go-version: ["1.20.1"]
14+
15+
name: "Build + tests"
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
20+
- name: Set up Go ${{ matrix.go-version }}
21+
uses: actions/setup-go@v3
22+
with:
23+
go-version: ${{ matrix.go-version }}
24+
25+
- name: Check out code into the Go module directory
26+
uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Cache Go modules
31+
uses: actions/cache@v3
32+
with:
33+
path: |
34+
~/go/pkg/mod
35+
~/.cache/go-build
36+
~/Library/Caches/go-build
37+
%LocalAppData%\go-build
38+
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
39+
restore-keys: |
40+
${{ runner.os }}-${{ matrix.go-version }}-go-
41+
42+
- name: Build
43+
run: |
44+
make build
45+
46+
- name: Run unit tests
47+
run: |
48+
go install github.com/kyoh86/[email protected]
49+
set -o pipefail
50+
make test | richgo testfilter
51+
52+
- name: Cache virtualenvs
53+
id: cache-pipenv
54+
uses: actions/cache@v3
55+
with:
56+
path: ~/.local/share/virtualenvs
57+
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
58+
59+
- name: Install functional test dependencies
60+
run: |
61+
python3 -m pip install --upgrade pipenv wheel
62+
pipenv install --deploy
63+
docker network create net-test
64+
65+
- name: Run functional tests
66+
env:
67+
CROWDSEC_TEST_VERSION: dev
68+
CROWDSEC_TEST_FLAVORS: full
69+
CROWDSEC_TEST_NETWORK: net-test
70+
CROWDSEC_TEST_TIMEOUT: 60
71+
run: |
72+
pipenv run pytest --durations=0 --color=yes
73+
74+
- name: golangci-lint
75+
uses: golangci/golangci-lint-action@v3
76+
with:
77+
version: v1.51
78+
args: --issues-exit-code=1 --timeout 10m
79+
only-new-issues: false

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 crowdsecurity
3+
Copyright (c) 2020-2023 crowdsecurity
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

+2-5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ export LD_OPTS=-ldflags "-s -w -X github.com/crowdsecurity/cs-custom-bouncer/pkg
1919

2020
RELDIR = "crowdsec-custom-bouncer-${BUILD_VERSION}"
2121

22-
PYTHON=python3
23-
PIP=pip
24-
25-
all: clean test build
22+
all: clean build test
2623

2724
static: clean
2825
$(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) -v -a -tags netgo -ldflags '-w -extldflags "-static"'
@@ -31,7 +28,7 @@ build: goversion clean
3128
$(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) -v
3229

3330
test:
34-
@$(GOTEST) -v ./...
31+
@$(GOTEST) ./...
3532

3633
clean:
3734
@rm -f $(BINARY_NAME)

Pipfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[packages]
2-
pytest = "*"
2+
pytest-dotenv = "*"
33
flask = "*"
44
pytimeparse = "*"
55
psutil = "*"
6+
pytest-cs = {ref = "0.4.0", git = "https://github.com/crowdsecurity/pytest-cs.git"}
67

78
[dev-packages]
89
gnureadline = "*"

0 commit comments

Comments
 (0)