mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-07-21 03:28:59 +02:00
♻️ tests: run e2e suite in a single sequential job
The matrix spawned one runner per scenario, so the Traefik, Crowdsec and whoami images were pulled — and Crowdsec booted — once per scenario. Run the whole suite in a single job with `make -k e2e` instead: Docker caches the images locally so they are pulled only once, and `-k` keeps the remaining scenarios running after a failure (make still exits non-zero). Scenarios already share the canonical `crowdsec` container name and the 8000 port, so they were meant to run sequentially anyway. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+10
-16
@@ -14,27 +14,21 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
e2e:
|
e2e:
|
||||||
name: ${{ matrix.scenario }}
|
name: e2e
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
scenario:
|
|
||||||
- stream-mode
|
|
||||||
- live-mode
|
|
||||||
- none-mode
|
|
||||||
- trusted-ips
|
|
||||||
- custom-ban-page
|
|
||||||
- captcha
|
|
||||||
- appsec
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- name: Run scenario
|
# A single runner runs every scenario sequentially. Docker caches the
|
||||||
run: ./tests/e2e/scenarios/${{ matrix.scenario }}/run.sh
|
# Traefik/Crowdsec/whoami images locally, so they are pulled only once
|
||||||
|
# for the whole suite instead of once per scenario. `-k` keeps going
|
||||||
|
# after a failing scenario so the logs cover all of them, while make
|
||||||
|
# still exits non-zero if any scenario failed.
|
||||||
|
- name: Run scenarios
|
||||||
|
run: make -k e2e
|
||||||
- name: Upload logs on failure
|
- name: Upload logs on failure
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: logs-${{ matrix.scenario }}
|
name: e2e-logs
|
||||||
path: /tmp/e2e-${{ matrix.scenario }}.log
|
path: /tmp/e2e-*.log
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
|
|||||||
+13
-10
@@ -28,22 +28,25 @@ Run everything:
|
|||||||
make e2e
|
make e2e
|
||||||
```
|
```
|
||||||
|
|
||||||
Each scenario uses an isolated Docker Compose project (`-p e2e-<scenario>`),
|
Scenarios run **sequentially** on a single host: they share the canonical
|
||||||
so multiple scenarios can run in parallel without colliding on container
|
`crowdsec` container name (so `cscli` commands work uniformly) and the same
|
||||||
names — except for the `crowdsec` container, which keeps its canonical
|
`8000:80` port. Each scenario uses its own Docker Compose project
|
||||||
name so `cscli` commands work uniformly across scenarios. Run scenarios
|
(`-p e2e-<scenario>`) and tears its stack down on exit, so the next one
|
||||||
serially if you need to invoke them on the same host at the same time.
|
starts clean. `make e2e` runs them one after another; Docker reuses the
|
||||||
|
images pulled by the first scenario, so the Traefik / Crowdsec / whoami
|
||||||
|
images are downloaded only once for the whole suite.
|
||||||
|
|
||||||
## Writing a new scenario
|
## Writing a new scenario
|
||||||
|
|
||||||
1. Copy `scenarios/stream-mode/` as a template.
|
1. Copy `scenarios/stream-mode/` as a template.
|
||||||
2. Rename `container_name`s (keep `crowdsec` for the LAPI container).
|
2. Rename `container_name`s (keep `crowdsec` for the LAPI container).
|
||||||
3. Edit `run.sh` to express the behavior under test.
|
3. Edit `run.sh` to express the behavior under test.
|
||||||
4. Add the scenario name to the `matrix` in `.github/workflows/e2e.yml`
|
4. Add the scenario name to `E2E_SCENARIOS` in the `Makefile`.
|
||||||
and to `E2E_SCENARIOS` in the `Makefile`.
|
|
||||||
|
|
||||||
## CI
|
## CI
|
||||||
|
|
||||||
`.github/workflows/e2e.yml` runs one parallel job per scenario on every
|
`.github/workflows/e2e.yml` runs the whole suite in a single job
|
||||||
PR and push to `main`. On failure, container logs are uploaded as an
|
(`make -k e2e`) on every PR and push to `main`. `-k` lets the remaining
|
||||||
artifact named `logs-<scenario>`.
|
scenarios run after a failure so the logs cover all of them, while make
|
||||||
|
still exits non-zero if any scenario failed. On failure, the per-scenario
|
||||||
|
logs (`/tmp/e2e-*.log`) are uploaded as an artifact named `e2e-logs`.
|
||||||
|
|||||||
Reference in New Issue
Block a user