-
Notifications
You must be signed in to change notification settings - Fork 25
205 lines (168 loc) · 7 KB
/
ansible-test.yml
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
# README FIRST
# 1. replace "NAMESPACE" and "COLLECTION_NAME" with the correct name in the env section (e.g. with 'community' and 'mycollection')
# 2. If you don't have unit tests remove that section
# 3. If your collection depends on other collections ensure they are installed, see "Install collection dependencies"
# If you need help please ask in #ansible-devel on Freenode IRC
name: CI
on:
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
push:
pull_request:
# Run CI once per day (at 06:00 UTC)
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version
schedule:
- cron: '0 6 * * *'
env:
NAMESPACE: cisco
COLLECTION_NAME: fmcansible
jobs:
###
# Check Build
#
build:
name: Build collection
runs-on: ubuntu-latest
strategy:
matrix:
# ansible: [2.9.17, 2.10.5]
ansible: [2.18.3, 2.17.9, 2.16.14]
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.10
- name: Install ansible-base (v${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/v${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Build a collection tarball
run: pwd && ls -al && find . && ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs"
- name: Store migrated collection artifacts
uses: actions/upload-artifact@v4
with:
name: collection
path: .cache/collection-tarballs
###
# Check Importer
#
importer:
name: Galaxy-importer check
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.10
- name: Install ansible-base (v2.18.3)
run: pip install https://github.com/ansible/ansible/archive/v2.18.3.tar.gz --disable-pip-version-check
- name: Download migrated collection artifacts
uses: actions/download-artifact@v1
with:
name: collection
path: .cache/collection-tarballs
- name: Install the collection tarball
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
- name: Install galaxy-importer
run: pip install galaxy-importer
- name: Create galaxy-importer directory
run: sudo mkdir -p /etc/galaxy-importer
- name: Create galaxy-importer.cfg
run: sudo cp /home/runner/.ansible/collections/ansible_collections/cisco/fmcansible/.github/workflows/galaxy-importer.cfg /etc/galaxy-importer/galaxy-importer.cfg
- name: Run galaxy-importer check
run: python -m galaxy_importer.main .cache/collection-tarballs/cisco-*.tar.gz | tee .cache/collection-tarballs/log.txt && sudo cp ./importer_result.json .cache/collection-tarballs/importer_result.json
- name: Check warnings and errors
run: if grep -E 'ERROR' .cache/collection-tarballs/log.txt; then exit 1; else exit 0; fi
- name: Store galaxy_importer check log file
uses: actions/upload-artifact@v4
with:
name: galaxy-importer-log
path: .cache/collection-tarballs/importer_result.json
###
# Sanity tests (REQUIRED)
#
# https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html
sanity:
name: Sanity (Ⓐ${{ matrix.ansible }})
strategy:
matrix:
ansible:
# - stable-2.9
# - stable-2.10
- stable-2.16
- stable-2.17
- stable-2.18
# It's important that Sanity is tested against all stable-X.Y branches
# Testing against `devel` may fail as new tests are added.
# - stable-2.9 # Only if your collection supports Ansible 2.9
runs-on: ubuntu-latest
steps:
# ansible-test requires the collection to be in a directory in the form
# .../ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/
- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
- name: Set up Python
uses: actions/setup-python@v2
with:
# it is just required to run that once as "ansible-test sanity" in the docker image
# will run on all python versions it supports.
python-version: 3.8
# Install the head of the given branch (devel, stable-2.10)
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Run sanity tests
run: ansible-test sanity --docker -v --color
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
# ansible-test support producing code coverage date
- name: Generate coverage report
# run: ansible-test coverage xml -v --requirements --group-by command --group-by version
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
# See the reports at https://codecov.io/gh/GITHUBORG/REPONAME
- uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false
###
# Unit tests (REQUIRED)
#
# https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html
units:
name: Unit (Ⓐ${{ matrix.ansible }})
strategy:
matrix:
ansible:
# - stable-2.9
# - stable-2.10
- stable-2.16
- stable-2.17
- stable-2.18
# It's important that Sanity is tested against all stable-X.Y branches
# Testing against `devel` may fail as new tests are added.
# - stable-2.9 # Only if your collection supports Ansible 2.9
runs-on: ubuntu-latest
steps:
# ansible-test requires the collection to be in a directory in the form
# .../ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/
- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
- name: Set up Python
uses: actions/setup-python@v2
with:
# it is just required to run that once as "ansible-test sanity" in the docker image
# will run on all python versions it supports.
python-version: 3.8
# Install the head of the given branch (devel, stable-2.10)
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
# Install units
# - name: Install units
# run: pip install units
# Run the unit tests on python 3.5
- name: Run unit tests
run: ansible-test units --docker -v --color
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}