github.com/crowdsecurity/crowdsec@v1.6.1/.github/workflows/docker-tests.yml (about)

     1  name: Test Docker images
     2  
     3  on:
     4    push:
     5      branches:
     6        - master
     7        - releases/**
     8      paths-ignore:
     9        - 'README.md'
    10    pull_request:
    11      branches:
    12        - master
    13        - releases/**
    14      paths-ignore:
    15        - 'README.md'
    16  
    17  jobs:
    18    test_flavor:
    19      strategy:
    20        # we could test all the flavors in a single pytest job,
    21        # but let's split them (and the image build) in multiple runners for performance
    22        matrix:
    23          # can be slim, full or debian (no debian slim).
    24          flavor: ["slim", "debian"]
    25  
    26      runs-on: ubuntu-latest
    27      timeout-minutes: 30
    28      steps:
    29  
    30        - name: Check out the repo
    31          uses: actions/checkout@v4
    32          with:
    33            fetch-depth: 0
    34  
    35        - name: Set up Docker Buildx
    36          uses: docker/setup-buildx-action@v3
    37          with:
    38            config: .github/buildkit.toml
    39  
    40        - name: "Build image"
    41          uses: docker/build-push-action@v5
    42          with:
    43            context: .
    44            file: ./Dockerfile${{ matrix.flavor == 'debian' && '.debian' || '' }}
    45            tags: crowdsecurity/crowdsec:test${{ matrix.flavor == 'full' && '' || '-' }}${{ matrix.flavor == 'full' && '' || matrix.flavor }}
    46            target: ${{ matrix.flavor == 'debian' && 'full' || matrix.flavor }}
    47            platforms: linux/amd64
    48            load: true
    49            cache-from: type=gha
    50            cache-to: type=gha,mode=min
    51  
    52        - name: "Setup Python"
    53          uses: actions/setup-python@v5
    54          with:
    55            python-version: "3.x"
    56  
    57        - name: "Install pipenv"
    58          run: |
    59            cd docker/test
    60            python -m pip install --upgrade pipenv wheel
    61  
    62        - name: "Cache virtualenvs"
    63          id: cache-pipenv
    64          uses: actions/cache@v4
    65          with:
    66            path: ~/.local/share/virtualenvs
    67            key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
    68  
    69        - name: "Install dependencies"
    70          if: steps.cache-pipenv.outputs.cache-hit != 'true'
    71          run: |
    72            cd docker/test
    73            pipenv install --deploy
    74  
    75        - name: "Create Docker network"
    76          run: docker network create net-test
    77  
    78        - name: "Run tests"
    79          env:
    80            CROWDSEC_TEST_VERSION: test
    81            CROWDSEC_TEST_FLAVORS: ${{ matrix.flavor }}
    82            CROWDSEC_TEST_NETWORK: net-test
    83            CROWDSEC_TEST_TIMEOUT: 90
    84          # running serially to reduce test flakiness
    85          run: |
    86            cd docker/test
    87            pipenv run pytest -n 1 --durations=0 --color=yes