Skip to content

Commit 049b099

Browse files
authored
update GH actions, workflows, move test packaging to uv/ruff (#105)
* update GH actions, workflows, move test packaging to uv/ruff
1 parent dc188f5 commit 049b099

33 files changed

+1394
-1249
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ jobs:
2020
steps:
2121

2222
- name: Check out repository
23-
uses: actions/checkout@v3
23+
uses: actions/checkout@v4
2424
with:
2525
fetch-depth: 0
2626

2727
- name: Set up Go
28-
uses: actions/setup-go@v4
28+
uses: actions/setup-go@v5
2929
with:
30-
go-version: 1.21.7
30+
go-version-file: go.mod
3131

3232
- name: Build all platforms
3333
run: |

.github/workflows/lint.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ jobs:
1818
steps:
1919

2020
- name: Check out code into the Go module directory
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 0
2424

2525
- name: Set up Go
26-
uses: actions/setup-go@v4
26+
uses: actions/setup-go@v5
2727
with:
28-
go-version: 1.21.7
28+
go-version-file: go.mod
2929

3030
- name: Initialize CodeQL
31-
uses: github/codeql-action/init@v2
31+
uses: github/codeql-action/init@v3
3232
with:
3333
languages: go, python
3434

@@ -37,15 +37,11 @@ jobs:
3737
make build
3838
3939
- name: golangci-lint
40-
uses: golangci/golangci-lint-action@v3
40+
uses: golangci/golangci-lint-action@v6
4141
with:
42-
version: v1.55
42+
version: v1.64
4343
args: --issues-exit-code=1 --timeout 10m
4444
only-new-issues: false
45-
# the cache is already managed above, enabling it here
46-
# gives errors when extracting
47-
skip-pkg-cache: true
48-
skip-build-cache: true
4945

5046
- name: Perform CodeQL Analysis
51-
uses: github/codeql-action/analyze@v2
47+
uses: github/codeql-action/analyze@v3

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Update the release draft
2222
steps:
2323
# Drafts your next Release notes as Pull Requests are merged into "main"
24-
- uses: release-drafter/release-drafter@v5
24+
- uses: release-drafter/release-drafter@v6
2525
with:
2626
config-name: release-drafter.yml
2727
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml

.github/workflows/tests.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ jobs:
1717
steps:
1818

1919
- name: Check out code into the Go module directory
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121
with:
2222
fetch-depth: 0
2323

2424
- name: Set up Go
25-
uses: actions/setup-go@v4
25+
uses: actions/setup-go@v5
2626
with:
27-
go-version: 1.21.7
27+
go-version-file: go.mod
2828

2929
- name: Build
3030
run: |
@@ -38,21 +38,25 @@ jobs:
3838
env:
3939
RICHGO_FORCE_COLOR: 1
4040

41-
- name: Cache virtualenvs
42-
id: cache-pipenv
43-
uses: actions/cache@v3
41+
- name: Install uv
42+
uses: astral-sh/setup-uv@v5
4443
with:
45-
path: ~/.local/share/virtualenvs
46-
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
44+
version: 0.5.24
45+
enable-cache: true
46+
cache-dependency-glob: "test/uv.lock"
47+
48+
- name: "Set up Python"
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version-file: "test/.python-version"
52+
53+
- name: Install the project
54+
working-directory: ./test
55+
run: uv sync --all-extras --dev
4756

4857
- name: Install functional test dependencies
4958
run: |
5059
docker network create net-test
51-
python3 -m pip install --upgrade pipenv wheel
52-
pipenv install --deploy
53-
# some tests need root, so we have to install pytest twice
54-
sudo python3 -m pip install --upgrade pipenv wheel
55-
sudo pipenv install --deploy
5660
5761
- name: Run functional tests
5862
env:
@@ -61,18 +65,26 @@ jobs:
6165
CROWDSEC_TEST_NETWORK: net-test
6266
CROWDSEC_TEST_TIMEOUT: 60
6367
PYTEST_ADDOPTS: --durations=0 -vv --color=yes -m "not (deb or rpm)"
68+
working-directory: ./test
6469
run: |
6570
# everything except for
6671
# - install (requires root, ignored by default)
6772
# - deb/rpm (on their own workflows)
68-
pipenv run pytest
73+
uv run pytest
6974
# these need root
70-
sudo -E pipenv run pytest ./test/install/no_crowdsec
75+
sudo -E $(which uv) run pytest ./tests/install/no_crowdsec
7176
# these need a running crowdsec
7277
docker run -d --name crowdsec -e CI_TESTING=true -e DISABLE_ONLINE_API=true -p 8080:8080 -ti crowdsecurity/crowdsec
7378
install -m 0755 /dev/stdin /usr/local/bin/cscli <<'EOT'
7479
#!/bin/sh
7580
docker exec crowdsec cscli "$@"
7681
EOT
7782
sleep 5
78-
sudo -E pipenv run pytest ./test/install/with_crowdsec
83+
sudo -E $(which uv) run pytest ./tests/install/with_crowdsec
84+
85+
- name: Lint
86+
working-directory: ./test
87+
run: |
88+
uv run ruff check
89+
uv run basedpyright
90+

.github/workflows/tests_deb.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,36 @@ jobs:
1717
steps:
1818

1919
- name: Check out code into the Go module directory
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121
with:
2222
fetch-depth: 0
2323

2424
- name: Set up Go
25-
uses: actions/setup-go@v4
25+
uses: actions/setup-go@v5
2626
with:
27-
go-version: 1.21.7
27+
go-version-file: go.mod
2828

29-
- name: Cache virtualenvs
30-
id: cache-pipenv
31-
uses: actions/cache@v3
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v5
3231
with:
33-
path: ~/.local/share/virtualenvs
34-
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
32+
version: 0.5.24
33+
enable-cache: true
34+
cache-dependency-glob: "test/uv.lock"
35+
36+
- name: "Set up Python"
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version-file: "test/.python-version"
40+
41+
- name: Install the project
42+
run: uv sync --all-extras --dev
43+
working-directory: ./test
3544

3645
- name: Install functional test dependencies
3746
run: |
3847
sudo apt update
3948
sudo apt install -y build-essential debhelper devscripts fakeroot lintian
4049
docker network create net-test
41-
python3 -m pip install --upgrade pipenv wheel
42-
pipenv install --deploy
43-
sudo python3 -m pip install --upgrade pipenv wheel
44-
sudo pipenv install --deploy
4550
4651
- name: Run functional tests
4752
env:
@@ -50,6 +55,7 @@ jobs:
5055
CROWDSEC_TEST_NETWORK: net-test
5156
CROWDSEC_TEST_TIMEOUT: 60
5257
PYTEST_ADDOPTS: --durations=0 -vv --color=yes
58+
working-directory: ./test
5359
run: |
54-
pipenv run pytest test/pkg/test_build_deb.py
55-
sudo -E pipenv run pytest -m deb ./test/install/no_crowdsec
60+
uv run pytest ./tests/pkg/test_build_deb.py
61+
sudo -E $(which uv) run pytest -m deb ./tests/install/no_crowdsec

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LD_OPTS_VARS=\
1919
-X 'github.com/crowdsecurity/go-cs-lib/version.Tag=$(BUILD_TAG)'
2020

2121
export CGO_ENABLED=0
22-
export LD_OPTS=-ldflags "-a -s -w -extldflags '-static' $(LD_OPTS_VARS)" \
22+
export LD_OPTS=-ldflags "-s -extldflags '-static' $(LD_OPTS_VARS)" \
2323
-trimpath -tags netgo
2424

2525
.PHONY: all

Pipfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)