-
Notifications
You must be signed in to change notification settings - Fork 27
206 lines (194 loc) · 6.89 KB
/
Copy pathunit_source.yml
File metadata and controls
206 lines (194 loc) · 6.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Unit tests, dependencies from source
on:
workflow_call:
inputs:
collection_pre_install:
required: false
type: string
default: ""
matrix_exclude:
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix
# 2.15 supports Python 3.9-3.11
# 2.16 supports Python 3.10-3.11
# 2.17 supports Python 3.10-3.12
# 2.18 supports Python 3.11-3.13
# 2.19 supports Python 3.11-3.13
# 2.20 supports Python 3.12-3.14
# support for Python 3.14 added and 3.11 removed in 2.20 for control node
# target node supported Python 3.8-3.13 as of 2.18 and 2.19
# target node supported Python 3.9-3.14 as of 2.20
# milestone and devel is switched to 2.22
# 2.22 supports Python 3.13-3.15
# https://docs.ansible.com/ansible/devel/roadmap/ROADMAP_2_20.html
default: >-
[
{
"ansible-version": "devel",
"python-version": "3.11"
},
{
"ansible-version": "devel",
"python-version": "3.12"
},
{
"ansible-version": "devel",
"python-version": "3.14"
},
{
"ansible-version": "milestone",
"python-version": "3.14"
},
{
"ansible-version": "stable-2.20",
"python-version": "3.14"
},
{
"ansible-version": "devel",
"python-version": "3.10"
},
{
"ansible-version": "milestone",
"python-version": "3.11"
},
{
"ansible-version": "milestone",
"python-version": "3.10"
},
{
"ansible-version": "stable-2.21",
"python-version": "3.11"
},
{
"ansible-version": "stable-2.21",
"python-version": "3.10"
},
{
"ansible-version": "stable-2.20",
"python-version": "3.11"
},
{
"ansible-version": "stable-2.20",
"python-version": "3.10"
},
{
"ansible-version": "stable-2.19",
"python-version": "3.14"
},
{
"ansible-version": "stable-2.19",
"python-version": "3.10"
},
{
"ansible-version": "stable-2.18",
"python-version": "3.14"
},
{
"ansible-version": "stable-2.18",
"python-version": "3.10"
},
{
"ansible-version": "stable-2.17",
"python-version": "3.14"
},
{
"ansible-version": "stable-2.17",
"python-version": "3.13"
},
{
"ansible-version": "stable-2.16",
"python-version": "3.14"
},
{
"ansible-version": "stable-2.16",
"python-version": "3.13"
},
{
"ansible-version": "stable-2.16",
"python-version": "3.12"
}
]
required: false
type: string
jobs:
unit_source:
env:
PY_COLORS: "1"
source_directory: "./source"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ansible-version:
# ansible-core 2.15 reached EOL on November 2024
# ansible-core 2.16 will reach EOL on May 2025
- stable-2.16
- stable-2.17
- stable-2.18
- stable-2.19
- stable-2.20
- stable-2.21
- devel
python-version:
# 2.16 supports Python 3.10-3.11
# 2.17 supports Python 3.10-3.12
# 2.18 and 2.19 supports Python 3.11-3.13
# 2.20 supports Python 3.12-3.14
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
exclude: ${{ fromJSON(inputs.matrix_exclude) }}
continue-on-error: ${{ matrix.ansible-version == 'devel' }}
name: "py${{ matrix.python-version }} / ${{ matrix.ansible-version }}"
steps:
- name: Checkout the collection repository
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
with:
path: ${{ env.source_directory }}
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: "0"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# ansible-pylibssh does not have cp312 wheels
# when building from sdist libssh-dev needs to be installed
# extra install step starts
- name: Install build toolchain and openssl headers on Linux
shell: bash
run: sudo apt update && sudo apt install build-essential libssl-dev
if: ${{ matrix.python-version >= 3.12 }}
- name: Install catchsegv and libssh headers on Linux for cythonize+coverage
shell: bash
run: sudo apt update && sudo apt install libssh-dev
if: ${{ matrix.python-version >= 3.12 }}
# extra install step ends
- name: Install ansible-compat, for tests
shell: bash
run: python -m pip install ansible-compat
- name: Install ansible-core (${{ matrix.ansible-version }})
run: python3 -m pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check
- name: Pre install collections dependencies first so the collection install does not
run: ansible-galaxy collection install --pre ${{ inputs.collection_pre_install }} -p /home/runner/collections
if: inputs.collection_pre_install != ''
- name: Read collection metadata from galaxy.yml
id: identify
uses: ansible-network/github_actions/.github/actions/identify_collection@main
with:
source_path: ${{ env.source_directory }}
- name: Build and install the collection
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
with:
install_python_dependencies: true
source_path: ${{ env.source_directory }}
collection_path: ${{ steps.identify.outputs.collection_path }}
tar_file: ${{ steps.identify.outputs.tar_file }}
ansible_version: ${{ matrix.ansible-version }}
- name: Print the ansible version
run: ansible --version
- name: Print the python dependencies
run: python3 -m pip list
- name: Run unit tests
run: python -m pytest tests/unit --showlocals --ansible-host-pattern localhost
working-directory: ${{ steps.identify.outputs.collection_path }}