mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-07-25 08:54:51 +00:00
* Fix CI Test Collision (#1162)
* Fix CI concurrency issue
* More CI fixes
* Fix coverage job install
* Install correct test dependencies
(cherry picked from commit d211f316ad)
* Restore cancel-in-progress: true
116 lines
3.5 KiB
YAML
116 lines
3.5 KiB
YAML
---
|
|
name: all_green
|
|
|
|
concurrency:
|
|
group: ${{ github.head_ref || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
on: # yamllint disable-line rule:truthy
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- reopened
|
|
- synchronize
|
|
branches:
|
|
- main
|
|
- stable-*
|
|
push:
|
|
branches:
|
|
- main
|
|
- stable-*
|
|
|
|
jobs:
|
|
linters:
|
|
if: github.event_name == 'pull_request'
|
|
uses: ./.github/workflows/linters.yaml
|
|
|
|
sanity:
|
|
uses: ./.github/workflows/sanity-tests.yaml
|
|
|
|
units:
|
|
uses: ./.github/workflows/unit-tests.yaml
|
|
|
|
coverage:
|
|
name: Unit test coverage
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: ansible_collections/kubernetes/core
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Run unit tests with coverage
|
|
working-directory: ansible_collections/kubernetes/core
|
|
env:
|
|
PYTHONPATH: ${{ github.workspace }}
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
python -m pip install ansible-compat
|
|
python -m pip install https://github.com/ansible/ansible/archive/stable-2.19.tar.gz
|
|
# Same deps as the units matrix (build_install_collection); do not use
|
|
# tests/unit/requirements.txt — its kubernetes pin breaks test_core.py.
|
|
python -m pip install -r requirements.txt -r test-requirements.txt
|
|
python -m coverage run --source=plugins -m pytest tests/unit \
|
|
--ansible-host-pattern localhost
|
|
python -m coverage xml -o coverage.xml
|
|
|
|
- name: Upload coverage artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage
|
|
path: ansible_collections/kubernetes/core/coverage.xml
|
|
|
|
all_green:
|
|
if: ${{ always() }}
|
|
needs:
|
|
- linters
|
|
- sanity
|
|
- units
|
|
- coverage
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- run: |
|
|
python -c "
|
|
import sys
|
|
|
|
required = ['sanity', 'units', 'coverage']
|
|
if '${{ github.event_name }}' == 'pull_request':
|
|
required = ['linters', 'sanity', 'units', 'coverage']
|
|
results = {
|
|
'linters': '${{ needs.linters.result }}',
|
|
'sanity': '${{ needs.sanity.result }}',
|
|
'units': '${{ needs.units.result }}',
|
|
'coverage': '${{ needs.coverage.result }}',
|
|
}
|
|
|
|
for name in required:
|
|
if results[name] == 'failure':
|
|
print(f'all_green: required job failed: {name} results={results}', file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
# cancel-in-progress superseded this run; do not fail (newer run is authoritative)
|
|
if any(v == 'cancelled' for v in results.values()):
|
|
print(
|
|
'all_green: one or more jobs cancelled (usually concurrency); skipping strict gate.',
|
|
results,
|
|
)
|
|
sys.exit(0)
|
|
|
|
not_ok = [j for j in required if results[j] != 'success']
|
|
if not_ok:
|
|
print(f'all_green: required jobs not success: {not_ok} results={results}', file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
for job, status in results.items():
|
|
if job not in required and status not in ('success', 'skipped'):
|
|
print(f'all_green: unexpected {job}={status} results={results}', file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
print('all_green OK', results)
|
|
"
|