Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency updates and tests #49

Merged
merged 39 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f56bb60
Use go 0.19 and add prometheus server
sbs2001 Aug 25, 2022
aec1259
Update default conf
sbs2001 Aug 25, 2022
557c19c
Add func tests
sbs2001 Oct 3, 2022
ee5f5cb
Fix bin path in tests
sbs2001 Oct 3, 2022
d42cff9
log=info for tests
sbs2001 Oct 3, 2022
3d6eca9
Track stream init error
sbs2001 Oct 3, 2022
c4b5a1d
Fix default config
sbs2001 Oct 4, 2022
0caeed8
Fix merge
sbs2001 Dec 14, 2022
cb9b00a
Func tests without sudo
sbs2001 Jan 4, 2023
eea3b27
use pipenv/pytest
mmetc Feb 22, 2023
8d0cd32
Merge branch 'main' into mm-func-tests
mmetc Feb 22, 2023
fc60c9f
Log error if Prometheus can't shutdown
mmetc Feb 22, 2023
984e787
Bump GitHub actions, added golangci-lint
mmetc Feb 22, 2023
e2b7e1f
Build before test
mmetc Feb 22, 2023
0214e36
Remove unused vars
mmetc Feb 22, 2023
4c20bf2
Lint
mmetc Feb 22, 2023
1acd395
wip
mmetc Feb 22, 2023
122ee5c
Merge branch 'main' into mm-func-tests-docker
mmetc Feb 23, 2023
bd2ab1b
wip
mmetc Feb 23, 2023
fe011aa
Use pytest-cs
mmetc Feb 23, 2023
5057d7a
Refactor tests; added bin_args option
mmetc Feb 23, 2023
0f1ac27
Added tests with real lapi
mmetc Feb 28, 2023
29e9129
wip
mmetc Feb 28, 2023
7aaaac1
Test non-blocking behavior with updated go-cs-bouncer; removed mock lapi
mmetc Mar 3, 2023
3616e31
Skip unused error return
mmetc Mar 3, 2023
46b331e
Added test envvars for pytest
mmetc Mar 3, 2023
5e9a905
CI: fetch all git commits to set version
mmetc Mar 3, 2023
3a75ea7
-dev tag only has full flavor
mmetc Mar 3, 2023
c245f03
create docker network for tests
mmetc Mar 3, 2023
cc0a514
use errgroup; go 1.20
mmetc Mar 3, 2023
b5b99fd
Test with both api_key='' and undefined
mmetc Mar 6, 2023
2f5701e
Refactor fixtures for reuse
mmetc Mar 6, 2023
4fcba8b
Bump go-cs-bouncer and deps
mmetc Mar 7, 2023
de328e0
use go 1.20.1
mmetc Mar 7, 2023
207d49c
Merge branch 'main' into mm-func-tests-docker
mmetc Mar 7, 2023
8051a9a
Bump pytest-cs dependency, set timeout in CI
mmetc Mar 8, 2023
6f279ce
Unified build/test workflow, renamed test directory
mmetc Mar 14, 2023
c2914fe
Update systemd dependency
mmetc Mar 14, 2023
0e18fa3
Add bin_args to default config
mmetc Mar 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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