With fail-fast: true and max-parallel: 1, runner 0 must complete before runner 1 starts. If runner 0 fails, runners 1 and 2 are cancelled. This gives immediate feedback on the first failure instead of waiting for all 3 to fail in parallel. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
71 lines
2.1 KiB
YAML
71 lines
2.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches: [master]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
quality:
|
|
runs-on: docker
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up environment
|
|
run: make setup
|
|
- name: Lint all
|
|
run: |
|
|
. .venv/bin/activate
|
|
make lint-all
|
|
- name: Unit tests with 100% coverage
|
|
run: |
|
|
. .venv/bin/activate
|
|
make pytest-cov
|
|
- name: Check unit test speed
|
|
run: |
|
|
. .venv/bin/activate
|
|
python3 scripts/check_test_speed.py --max-seconds 10
|
|
|
|
molecule-tests:
|
|
needs: quality
|
|
runs-on: docker
|
|
strategy:
|
|
fail-fast: true
|
|
max-parallel: 1
|
|
matrix:
|
|
runner-index: [0, 1, 2]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up environment
|
|
run: make setup
|
|
- name: Discover assigned test pairs
|
|
run: |
|
|
. .venv/bin/activate
|
|
PAIRS=$(python3 scripts/distribute_molecule.py --runner-index ${{ matrix.runner-index }} --max-runners 3)
|
|
echo "Assigned pairs: $PAIRS"
|
|
echo "TEST_PAIRS=$PAIRS" >> $GITHUB_ENV
|
|
- name: Run molecule tests
|
|
run: |
|
|
set -e
|
|
. .venv/bin/activate
|
|
export DOCKER_HOST="unix:///run/user/$(id -u)/docker.sock"
|
|
export ANSIBLE_INJECT_INVOCATION=1
|
|
cd ansible/roles/gitea-runner
|
|
for pair in $TEST_PAIRS; do
|
|
IFS='|' read -r scenario platform_name platform_image platform_command <<< "$pair"
|
|
export MOLECULE_PLATFORM_NAME="$platform_name"
|
|
export MOLECULE_PLATFORM_IMAGE="$platform_image"
|
|
if [ -n "$platform_command" ]; then
|
|
export MOLECULE_PLATFORM_COMMAND="$platform_command"
|
|
else
|
|
unset MOLECULE_PLATFORM_COMMAND
|
|
fi
|
|
echo "::group::Molecule: $scenario on $platform_name"
|
|
if [ "$scenario" = "default" ]; then
|
|
ANSIBLE_ALLOW_BROKEN_CONDITIONALS=true molecule test
|
|
else
|
|
ANSIBLE_ALLOW_BROKEN_CONDITIONALS=true molecule test -s "$scenario"
|
|
fi
|
|
echo "::endgroup::"
|
|
done
|