Debian Codegraph @

ansible_collections/amazon/aws/.github/workflows/all_green_check.yml

raw
1 ---
2 name: all_green
3
4 concurrency:
5 group: ${{ github.head_ref || github.ref }}
6 cancel-in-progress: true
7
8 on: # yamllint disable-line rule:truthy
9 pull_request:
10 types:
11 - opened
12 - reopened
13 - synchronize
14 branches:
15 - main
16 - stable-*
17 push:
18 branches:
19 - main
20 - stable-*
21
22 jobs:
23 linters:
24 if: github.event_name == 'pull_request'
25 uses: ./.github/workflows/linters.yml
26 ansible-test:
27 uses: ./.github/workflows/ansible-test.yml
28 coverage:
29 name: Unit test coverage
30 runs-on: ubuntu-latest
31 steps:
32 - name: Checkout repository
33 uses: actions/checkout@v4
34
35 - name: Set up Python
36 uses: actions/setup-python@v5
37 with:
38 python-version: "3.14"
39
40 - name: Install tox
41 run: python -m pip install --upgrade pip tox
42
43 - name: Run unit tests with coverage (tox)
44 run: tox -e ansible2.20-py314-with_constraints
45
46 - name: Rewrite coverage paths to be repo-relative
47 run: |
48 COVERAGE_FILE=$(find .tox -name coverage.xml -type f 2>/dev/null | head -1)
49 if [[ -z "$COVERAGE_FILE" ]]; then
50 echo "::error::coverage.xml not found under .tox"
51 exit 1
52 fi
53 # Coverage XML uses absolute paths; use absolute prefix so the replacement matches
54 COVERAGE_FILE=$(realpath "$COVERAGE_FILE")
55 # Ensure path stays within workspace (avoid symlink escape)
56 case "$COVERAGE_FILE" in
57 "$GITHUB_WORKSPACE"/*) ;;
58 *) echo "::error::coverage.xml path outside workspace"; exit 1 ;;
59 esac
60 export COLLECTION_PATH=$(dirname "$COVERAGE_FILE")
61 export COVERAGE_FILE
62 echo "COVERAGE_FILE=$COVERAGE_FILE" >> $GITHUB_ENV
63 - name: Upload coverage artifact
64 uses: actions/upload-artifact@v4
65 with:
66 name: coverage
67 path: ${{ env.COVERAGE_FILE }}
68
69 all_green:
70 if: ${{ always() }}
71 needs:
72 - linters
73 - ansible-test
74 - coverage
75 runs-on: ubuntu-latest
76 steps:
77 - run: |
78 python -c "
79 required = ['ansible-test', 'coverage']
80 if '${{ github.event_name }}' == 'pull_request':
81 required = ['linters', 'ansible-test', 'coverage']
82 results = {'linters': '${{ needs.linters.result }}', 'ansible-test': '${{ needs.ansible-test.result }}',
83 'coverage': '${{ needs.coverage.result }}'}
84 ok = all(results[j] == 'success' for j in required)
85 skipped_ok = all(results[j] in ('success', 'skipped') for j in results)
86 assert ok and skipped_ok, f'required={required} results={results}'
87 "