2023-02-20 13:55:56 +00:00
|
|
|
name: Test Docker images
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
- releases/**
|
|
|
|
paths-ignore:
|
|
|
|
- 'README.md'
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
- releases/**
|
|
|
|
paths-ignore:
|
|
|
|
- 'README.md'
|
|
|
|
|
|
|
|
jobs:
|
2024-01-31 11:07:27 +00:00
|
|
|
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"]
|
|
|
|
|
2023-02-20 13:55:56 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-03-09 11:00:29 +00:00
|
|
|
timeout-minutes: 30
|
2023-02-20 13:55:56 +00:00
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: Check out the repo
|
2024-01-30 09:20:25 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-02-20 13:55:56 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2023-02-28 16:49:32 +00:00
|
|
|
- name: Set up Docker Buildx
|
2024-01-30 09:20:25 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2023-03-01 09:56:25 +00:00
|
|
|
with:
|
|
|
|
config: .github/buildkit.toml
|
2023-02-28 16:49:32 +00:00
|
|
|
|
2024-01-31 11:07:27 +00:00
|
|
|
- name: "Build image"
|
2024-01-30 09:20:25 +00:00
|
|
|
uses: docker/build-push-action@v5
|
2023-02-28 16:49:32 +00:00
|
|
|
with:
|
|
|
|
context: .
|
2024-01-31 11:07:27 +00:00
|
|
|
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 }}
|
2023-02-28 16:49:32 +00:00
|
|
|
platforms: linux/amd64
|
|
|
|
load: true
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=min
|
2023-02-20 13:55:56 +00:00
|
|
|
|
|
|
|
- name: "Setup Python"
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: "3.x"
|
|
|
|
|
|
|
|
- name: "Install pipenv"
|
|
|
|
run: |
|
|
|
|
cd docker/test
|
|
|
|
python -m pip install --upgrade pipenv wheel
|
|
|
|
|
2023-02-24 10:01:45 +00:00
|
|
|
- name: "Cache virtualenvs"
|
|
|
|
id: cache-pipenv
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: ~/.local/share/virtualenvs
|
|
|
|
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
|
2023-02-20 13:55:56 +00:00
|
|
|
|
|
|
|
- name: "Install dependencies"
|
|
|
|
if: steps.cache-pipenv.outputs.cache-hit != 'true'
|
|
|
|
run: |
|
|
|
|
cd docker/test
|
2023-02-24 10:01:45 +00:00
|
|
|
pipenv install --deploy
|
2023-02-24 16:15:17 +00:00
|
|
|
|
|
|
|
- name: "Create Docker network"
|
|
|
|
run: docker network create net-test
|
2023-02-20 13:55:56 +00:00
|
|
|
|
|
|
|
- name: "Run tests"
|
|
|
|
env:
|
|
|
|
CROWDSEC_TEST_VERSION: test
|
2024-01-31 11:07:27 +00:00
|
|
|
CROWDSEC_TEST_FLAVORS: ${{ matrix.flavor }}
|
2023-02-20 13:55:56 +00:00
|
|
|
CROWDSEC_TEST_NETWORK: net-test
|
2023-03-09 11:00:29 +00:00
|
|
|
CROWDSEC_TEST_TIMEOUT: 90
|
2024-01-31 11:07:27 +00:00
|
|
|
# running serially to reduce test flakiness
|
2023-02-20 13:55:56 +00:00
|
|
|
run: |
|
|
|
|
cd docker/test
|
2024-01-31 11:07:27 +00:00
|
|
|
pipenv run pytest -n 1 --durations=0 --color=yes
|