Three changes: 1. CI: add set -e and fail-fast: true to stop on first molecule failure instead of continuing (all pairs fail for same reason anyway) 2. Docker APT repo: use copy module to write sources.list directly instead of apt_repository module which wasn't picking up the repo 3. Fix arch mapping: ansible_facts returns x86_64, Docker repo needs amd64 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
70 lines
2.1 KiB
YAML
70 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
|
|
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
|