Skip to content

Commit f716aea

Browse files
authored
Move some tests to GH Actions (#1748)
stable-2.x: Backport move some tests to GH Actions SUMMARY Backport #1747: Move some tests to GH Actions. ISSUE TYPE Feature Pull Request COMPONENT NAME ADDITIONAL INFORMATION #1746
1 parent 28cee6b commit f716aea

File tree

2 files changed

+201
-0
lines changed

2 files changed

+201
-0
lines changed

.github/workflows/ansible-test.yml

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# README FIRST
2+
# 1. If you don't have unit tests, remove that section.
3+
# 2. If your collection depends on other collections ensure they are installed,
4+
# add them to the "test-deps" input.
5+
# 3. For the comprehensive list of the inputs supported by the
6+
# ansible-community/ansible-test-gh-action GitHub Action, see
7+
# https://github.com/marketplace/actions/ansible-test.
8+
# 4. If you want to prevent merging PRs that do not pass all tests,
9+
# make sure to add the "check" job to your repository branch
10+
# protection once this workflow is added.
11+
# It is also possible to tweak which jobs are allowed to fail. See
12+
# https://github.com/marketplace/actions/alls-green#gotchas for more detail.
13+
# 5. If you need help please ask in #ansible-community on the Libera.chat IRC
14+
# network.
15+
16+
name: CI
17+
on:
18+
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
19+
push:
20+
branches:
21+
- main
22+
- stable-2.x
23+
pull_request:
24+
# Run CI once per day (at 07:12 UTC)
25+
# This ensures that even if there haven't been commits that we are still
26+
# testing against latest version of ansible-test for each ansible-core
27+
# version
28+
schedule:
29+
- cron: '12 7 * * *'
30+
31+
concurrency:
32+
group: >-
33+
${{ github.workflow }}-${{
34+
github.event.pull_request.number || github.sha
35+
}}
36+
cancel-in-progress: true
37+
38+
jobs:
39+
40+
###
41+
# Sanity tests (REQUIRED)
42+
#
43+
# https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html
44+
45+
sanity:
46+
name: Sanity (Ⓐ${{ matrix.ansible }})
47+
strategy:
48+
matrix:
49+
ansible:
50+
# It's important that Sanity is tested against all stable-X.Y branches
51+
# Testing against `devel` may fail as new tests are added.
52+
# An alternative to `devel` is the `milestone` branch with
53+
# gets synchronized with `devel` every few weeks and therefore
54+
# tends to be a more stable target. Be aware that it is not updated
55+
# around creation of a new stable branch, this might cause a problem
56+
# that two different versions of ansible-test use the same sanity test
57+
# ignore.txt file.
58+
# The commented branches below are EOL,
59+
# do you really need your collection to support them if it still does?
60+
# - stable-2.9 # Only if your collection supports Ansible 2.9
61+
# - stable-2.10 # Only if your collection supports ansible-base 2.10
62+
# - stable-2.11 # Only if your collection supports ansible-core 2.11
63+
# - stable-2.12
64+
- stable-2.13
65+
- stable-2.14
66+
- stable-2.15
67+
# - devel
68+
- milestone
69+
# Ansible-test on various stable branches does not yet work well with cgroups v2.
70+
# Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04
71+
# image for these stable branches. The list of branches where this is necessary will
72+
# shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28
73+
# for the latest list.
74+
runs-on: >-
75+
${{ contains(fromJson(
76+
'["stable-2.9", "stable-2.10", "stable-2.11"]'
77+
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
78+
steps:
79+
# Run sanity tests inside a Docker container.
80+
# The docker container has all the pinned dependencies that are
81+
# required and all Python versions Ansible supports.
82+
- name: Perform sanity testing
83+
# See the documentation for the following GitHub action on
84+
# https://github.com/ansible-community/ansible-test-gh-action/blob/main/README.md
85+
uses: ansible-community/ansible-test-gh-action@release/v1
86+
with:
87+
ansible-core-version: ${{ matrix.ansible }}
88+
testing-type: sanity
89+
# OPTIONAL If your sanity tests require code
90+
# from other collections, install them like this
91+
# test-deps: >-
92+
# ansible.netcommon
93+
# ansible.utils
94+
# OPTIONAL If set to true, will test only against changed files,
95+
# which should improve CI performance. See limitations on
96+
# https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection
97+
pull-request-change-detection: true
98+
99+
###
100+
# Unit tests (OPTIONAL)
101+
#
102+
# https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html
103+
104+
units:
105+
# Ansible-test on various stable branches does not yet work well with cgroups v2.
106+
# Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04
107+
# image for these stable branches. The list of branches where this is necessary will
108+
# shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28
109+
# for the latest list.
110+
runs-on: >-
111+
${{ contains(fromJson(
112+
'["stable-2.9", "stable-2.10", "stable-2.11"]'
113+
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
114+
name: Units (Ⓐ${{ matrix.ansible }})
115+
strategy:
116+
# As soon as the first unit test fails, cancel the others to free up the CI queue
117+
fail-fast: true
118+
matrix:
119+
ansible:
120+
# The commented branches below are EOL,
121+
# do you really need your collection to support them if it still does?
122+
# - stable-2.9 # Only if your collection supports Ansible 2.9
123+
# - stable-2.10 # Only if your collection supports ansible-base 2.10
124+
# - stable-2.11 # Only if your collection supports ansible-core 2.11
125+
# - stable-2.12
126+
- stable-2.13
127+
- stable-2.14
128+
- stable-2.15
129+
# - devel
130+
- milestone
131+
132+
steps:
133+
- name: >-
134+
Perform unit testing against
135+
Ansible version ${{ matrix.ansible }}
136+
# See the documentation for the following GitHub action on
137+
# https://github.com/ansible-community/ansible-test-gh-action/blob/main/README.md
138+
uses: ansible-community/ansible-test-gh-action@release/v1
139+
with:
140+
ansible-core-version: ${{ matrix.ansible }}
141+
testing-type: units
142+
# OPTIONAL If your unit tests require code
143+
# from other collections, install them like this
144+
test-deps: >-
145+
ansible.netcommon
146+
ansible.utils
147+
# OPTIONAL If set to true, will test only against changed files,
148+
# which should improve CI performance. See limitations on
149+
# https://github.com/ansible-community/ansible-test-gh-action#pull-request-change-detection
150+
pull-request-change-detection: true
151+
152+
check: # This job does nothing and is only used for the branch protection
153+
# or multi-stage CI jobs, like making sure that all tests pass before
154+
# a publishing job is started.
155+
if: always()
156+
157+
needs:
158+
- sanity
159+
- units
160+
161+
runs-on: ubuntu-latest
162+
163+
steps:
164+
- name: Decide whether the needed jobs succeeded or failed
165+
uses: re-actors/alls-green@release/v1
166+
with:
167+
jobs: ${{ toJSON(needs) }}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Lint extra docsite docs and links
2+
on:
3+
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
4+
push:
5+
branches:
6+
- main
7+
- stable-2.x
8+
pull_request:
9+
# Run CI once per day (at 07:12 UTC)
10+
# 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
11+
schedule:
12+
- cron: '12 7 * * *'
13+
14+
jobs:
15+
docsite:
16+
name: Lint extra docsite docs and links
17+
permissions:
18+
contents: read
19+
runs-on: ubuntu-latest
20+
steps:
21+
22+
- name: Check out code
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v3
27+
with:
28+
python-version: '3.10'
29+
30+
- name: Install antsibull-docs
31+
run: pip install antsibull-docs --disable-pip-version-check
32+
33+
- name: Run collection docs linter
34+
run: antsibull-docs lint-collection-docs .

0 commit comments

Comments
 (0)