Skip to content

Commit

Permalink
Dependency updates and tests (#49)
Browse files Browse the repository at this point in the history
 - 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]>
  • Loading branch information
3 people authored Mar 14, 2023
1 parent 19cc560 commit e900227
Show file tree
Hide file tree
Showing 28 changed files with 948 additions and 2,306 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-binary-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: 1.20.1
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Build the binaries
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/functional_tests.yaml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/go.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build + tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
strategy:
matrix:
go-version: ["1.20.1"]

name: "Build + tests"
runs-on: ubuntu-latest

steps:

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: Build
run: |
make build
- name: Run unit tests
run: |
go install github.com/kyoh86/[email protected]
set -o pipefail
make test | richgo testfilter
- name: Cache virtualenvs
id: cache-pipenv
uses: actions/cache@v3
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}

- name: Install functional test dependencies
run: |
python3 -m pip install --upgrade pipenv wheel
pipenv install --deploy
docker network create net-test
- name: Run functional tests
env:
CROWDSEC_TEST_VERSION: dev
CROWDSEC_TEST_FLAVORS: full
CROWDSEC_TEST_NETWORK: net-test
CROWDSEC_TEST_TIMEOUT: 60
run: |
pipenv run pytest --durations=0 --color=yes
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51
args: --issues-exit-code=1 --timeout 10m
only-new-issues: false
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 crowdsecurity
Copyright (c) 2020-2023 crowdsecurity

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ export LD_OPTS=-ldflags "-s -w -X github.com/crowdsecurity/cs-custom-bouncer/pkg

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

PYTHON=python3
PIP=pip

all: clean test build
all: clean build test

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

test:
@$(GOTEST) -v ./...
@$(GOTEST) ./...

clean:
@rm -f $(BINARY_NAME)
Expand Down
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[packages]
pytest = "*"
pytest-dotenv = "*"
flask = "*"
pytimeparse = "*"
psutil = "*"
pytest-cs = {ref = "0.4.0", git = "https://github.com/crowdsecurity/pytest-cs.git"}

[dev-packages]
gnureadline = "*"
Expand Down
Loading

0 comments on commit e900227

Please sign in to comment.