Skip to content

Commit

Permalink
Merge branch 'master' into cscli-alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Jan 31, 2024
2 parents 006f1e5 + 4192af3 commit 79537d5
Show file tree
Hide file tree
Showing 43 changed files with 628 additions and 693 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/bats-hub.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Hub tests
name: (sub) Bats / Hub

on:
workflow_call:
Expand All @@ -17,7 +17,7 @@ jobs:
matrix:
test-file: ["hub-1.bats", "hub-2.bats", "hub-3.bats"]

name: "Build + tests"
name: "Functional tests"
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -28,13 +28,13 @@ jobs:
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
- name: "Check out CrowdSec repository"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: "Set up Go"
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21.6"

Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/bats-mysql.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Functional tests (MySQL)
name: (sub) Bats / MySQL

on:
workflow_call:
Expand All @@ -12,11 +12,7 @@ env:

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

name: "Build + tests"
name: "Functional tests"
runs-on: ubuntu-latest
timeout-minutes: 30
services:
Expand All @@ -35,15 +31,15 @@ jobs:
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
- name: "Check out CrowdSec repository"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v4
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.21.6"

- name: "Install bats dependencies"
env:
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/bats-postgres.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Functional tests (Postgres)
name: (sub) Bats / Postgres

on:
workflow_call:
Expand All @@ -8,11 +8,7 @@ env:

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

name: "Build + tests"
name: "Functional tests"
runs-on: ubuntu-latest
timeout-minutes: 30
services:
Expand Down Expand Up @@ -44,15 +40,15 @@ jobs:
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
- name: "Check out CrowdSec repository"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v4
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.21.6"

- name: "Install bats dependencies"
env:
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/bats-sqlite-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Functional tests (sqlite)
name: (sub) Bats / sqlite + coverage

on:
workflow_call:
Expand All @@ -9,11 +9,7 @@ env:

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

name: "Build + tests"
name: "Functional tests"
runs-on: ubuntu-latest
timeout-minutes: 20

Expand All @@ -25,15 +21,15 @@ jobs:
echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id
- name: "Check out CrowdSec repository"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v4
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.21.6"

- name: "Install bats dependencies"
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cache-cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cleanup
run: |
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/ci-windows-build-msi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,21 @@ on:

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

name: Build
runs-on: windows-2019

steps:

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

- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v4
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.21.6"

- name: Build
run: make windows_installer BUILD_RE2_WASM=1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# required to pick up tags for BUILD_VERSION
fetch-depth: 0
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
# uses a compiled language

- name: "Set up Go"
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21.6"
cache-dependency-path: "**/go.sum"
Expand Down
52 changes: 18 additions & 34 deletions .github/workflows/docker-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,35 @@ on:
- 'README.md'

jobs:
test_docker_image:
test_flavor:
strategy:
# we could test all the flavors in a single pytest job,
# but let's split them (and the image build) in multiple runners for performance
matrix:
# can be slim, full or debian (no debian slim).
flavor: ["slim", "debian"]

runs-on: ubuntu-latest
timeout-minutes: 30
steps:

- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
config: .github/buildkit.toml

- name: "Build flavor: slim"
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
tags: crowdsecurity/crowdsec:test-slim
target: slim
platforms: linux/amd64
load: true
cache-from: type=gha
cache-to: type=gha,mode=min

- name: "Build flavor: full"
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
tags: crowdsecurity/crowdsec:test
target: full
platforms: linux/amd64
load: true
cache-from: type=gha
cache-to: type=gha,mode=min

- name: "Build flavor: full (debian)"
uses: docker/build-push-action@v4
- name: "Build image"
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.debian
tags: crowdsecurity/crowdsec:test-debian
target: full
file: ./Dockerfile${{ matrix.flavor == 'debian' && '.debian' || '' }}
tags: crowdsecurity/crowdsec:test${{ matrix.flavor == 'full' && '' || '-' }}${{ matrix.flavor == 'full' && '' || matrix.flavor }}
target: ${{ matrix.flavor == 'debian' && 'full' || matrix.flavor }}
platforms: linux/amd64
load: true
cache-from: type=gha
Expand Down Expand Up @@ -95,9 +78,10 @@ jobs:
- name: "Run tests"
env:
CROWDSEC_TEST_VERSION: test
CROWDSEC_TEST_FLAVORS: slim,debian
CROWDSEC_TEST_FLAVORS: ${{ matrix.flavor }}
CROWDSEC_TEST_NETWORK: net-test
CROWDSEC_TEST_TIMEOUT: 90
# running serially to reduce test flakiness
run: |
cd docker/test
pipenv run pytest -n 2 --durations=0 --color=yes
pipenv run pytest -n 1 --durations=0 --color=yes
12 changes: 4 additions & 8 deletions .github/workflows/go-tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,21 @@ env:

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

name: "Build + tests"
runs-on: windows-2022

steps:

- name: Check out CrowdSec repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false

- name: "Set up Go ${{ matrix.go-version }}"
uses: actions/setup-go@v4
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.21.6"

- name: Build
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ jobs:
steps:

- name: Check out CrowdSec repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false

- name: "Set up Go"
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21.6"

Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/publish-docker-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: (push-master) Publish latest Docker images

on:
push:
branches: [ master ]
paths:
- 'pkg/**'
- 'cmd/**'
- 'mk/**'
- 'docker/docker_start.sh'
- 'docker/config.yaml'
- '.github/workflows/publish-docker-master.yml'
- '.github/workflows/publish-docker.yml'
- 'Dockerfile'
- 'Dockerfile.debian'
- 'go.mod'
- 'go.sum'
- 'Makefile'

jobs:
dev-alpine:
uses: ./.github/workflows/publish-docker.yml
with:
platform: linux/amd64
crowdsec_version: ""
image_version: dev
latest: false
push: true
slim: false
debian: false
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

dev-debian:
uses: ./.github/workflows/publish-docker.yml
with:
platform: linux/amd64
crowdsec_version: ""
image_version: dev
latest: false
push: true
slim: false
debian: true
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

0 comments on commit 79537d5

Please sign in to comment.