Skip to content

Commit 62a3644

Browse files
committed
Add action with README
New action in a working state. If ansible provides an endpoint to get the supported versions and all, then this action may be updated from those instead of hardcoding the versions. Doing that for the docker-image can be done by grabbing: https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/_data/completion/docker.txt (taking care of replacing devel by the relevant ansible version)
1 parent d93fc15 commit 62a3644

File tree

5 files changed

+287
-20
lines changed

5 files changed

+287
-20
lines changed

LICENSE

+6-20
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,9 @@ to attach them to the start of each source file to most effectively
631631
state the exclusion of warranty; and each file should have at least
632632
the "copyright" line and a pointer to where the full notice is found.
633633

634-
<one line to give the program's name and a brief idea of what it does.>
635-
Copyright (C) <year> <name of author>
634+
ansible-test-versions-gh-action for setting up job matrix in Ansible
635+
Collection repositories
636+
Copyright (C) 2021 Cédric Villemain ( https://Data-Bene.io)
636637

637638
This program is free software: you can redistribute it and/or modify
638639
it under the terms of the GNU General Public License as published by
@@ -652,23 +653,8 @@ Also add information on how to contact you by electronic and paper mail.
652653
If the program does terminal interaction, make it output a short
653654
notice like this when it starts in an interactive mode:
654655

655-
<program> Copyright (C) <year> <name of author>
656-
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
656+
ansible-test-versions-gh-action
657+
Copyright (C) 2021 Cédric Villemain ( https://Data-Bene.io)
658+
This program comes with ABSOLUTELY NO WARRANTY.
657659
This is free software, and you are welcome to redistribute it
658660
under certain conditions; type `show c' for details.
659-
660-
The hypothetical commands `show w' and `show c' should show the appropriate
661-
parts of the General Public License. Of course, your program's commands
662-
might be different; for a GUI interface, you would use an "about box".
663-
664-
You should also get your employer (if you work as a programmer) or school,
665-
if any, to sign a "copyright disclaimer" for the program, if necessary.
666-
For more information on this, and how to apply and follow the GNU GPL, see
667-
<https://www.gnu.org/licenses/>.
668-
669-
The GNU General Public License does not permit incorporating your program
670-
into proprietary programs. If your program is a subroutine library, you
671-
may consider it more useful to permit linking proprietary applications with
672-
the library. If this is what you want to do, use the GNU Lesser General
673-
Public License instead of this License. But first, please read
674-
<https://www.gnu.org/licenses/why-not-lgpl.html>.

README.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# ansible-test-versions-gh-action for setting up job matrix in Ansible Collection repositories
2+
3+
GitHub Action for setting up job matrix based on expected ansible, python and
4+
docker image support for Ansible Collections.
5+
6+
## Usage
7+
8+
To use the action add the following step to your workflow file (e.g.
9+
`.github/workflows/ansible-test.yml`), example for sanity tests:
10+
11+
```yaml
12+
steps:
13+
- name: Get the job matrix parameters for ansible-test as JSON
14+
uses: data-bene/ansible-test-versions-gh-action@release/v1
15+
id: default-matrix
16+
with:
17+
python-version: '[ "3.9" ]'
18+
strategy:
19+
fail-fast: ${{ inputs.fail-fast }}
20+
matrix:
21+
ansible-core-version: ${{ fromJSON(define-matrix.outputs.ansible-core-version) }}
22+
python-version: ${{ fromJSON(define-matrix.outputs.python-version) }}
23+
target-python-version: ${{ fromJSON(define-matrix.outputs.target-python-version) }}
24+
exclude: ${{ fromJSON(define-matrix.outputs.target-python-exclude) }}
25+
```
26+
27+
And for integration tests:
28+
29+
```yaml
30+
steps:
31+
- name: Get the job matrix parameters for ansible-test as JSON
32+
uses: data-bene/ansible-test-versions-gh-action@release/v1
33+
id: default-matrix
34+
with:
35+
docker-image: '[ "ubuntu2004" ]'
36+
docker-include: '[]'
37+
strategy:
38+
fail-fast: ${{ inputs.fail-fast }}
39+
matrix:
40+
ansible-core-version: ${{ fromJSON(define-matrix.outputs.ansible-core-version) }}
41+
python-version: ${{ fromJSON(define-matrix.outputs.python-version) }}
42+
docker-image: ${{ fromJSON(define-matrix.outputs.docker-image) }}
43+
exclude: ${{ fromJSON(define-matrix.outputs.docker-exclude) }}
44+
include: ${{ fromJSON(define-matrix.outputs.docker-include) }}
45+
46+
```
47+
48+
49+
> **Pro tip**: instead of using branch pointers, like `main`, pin
50+
versions of Actions that you use to tagged versions or SHA-1 commit
51+
identifiers. This will make your workflows more secure and better
52+
reproducible, saving you from sudden and unpleasant surprises.
53+
54+
## inputs
55+
56+
When set the inputs replace the default values, inputs MUST be JSON.
57+
58+
* `ansible-core-version`: Array of ansible versions (required: false)
59+
* `docker-exclude`: Array of matrix excludes for docker (required: false)
60+
* `docker-image`: Array of docker images (required: false)
61+
* `docker-include`: Array of matrix includes for docker (required: false)
62+
* `python-version`: Array of python versions (controler) (required: false)
63+
* `target-python-exclude`: Array of excludes target python versions (required: false)
64+
* `target-python-version`: Array of target python versions (managed) (required: false)
65+
66+
## outputs
67+
68+
JSON outputs:
69+
70+
* `ansible-core-version`: Array of ansible versions
71+
* `docker-exclude`: Array of matrix excludes for docker
72+
* `docker-image`: Array of docker images
73+
* `docker-include`: Array of matrix includes for docker
74+
* `python-version`: Array of python versions (controler)
75+
* `target-python-exclude`: Array of excludes target python versions
76+
* `target-python-version`: Array of target python versions (managed)
77+
78+
# Developed and Sponsored by
79+
80+
[Data Bene](https://data-bene.io)

action.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
name: ansible-test-versions
3+
author: Cédric Villemain <https://Data-Bene.io>
4+
branding:
5+
icon: check-circle
6+
color: gray-dark
7+
description: >-
8+
GitHub Action for setting up job matrix based on expected ansible, python and
9+
docker image support for Ansible Collections.
10+
11+
inputs:
12+
ansible-core-version:
13+
description: Array of ansible versions
14+
required: false
15+
docker-exclude:
16+
description: Array of matrix excludes for docker
17+
required: false
18+
docker-image:
19+
description: Array of docker images
20+
required: false
21+
docker-include:
22+
description: Array of matrix includes for docker
23+
required: false
24+
python-version:
25+
description: Array of python versions (controler)
26+
required: false
27+
target-python-exclude:
28+
description: Array of excludes target python versions
29+
required: false
30+
target-python-version:
31+
description: Array of target python versions (managed)
32+
required: false
33+
34+
outputs:
35+
ansible-core-version:
36+
description: Array of ansible versions
37+
value: ${{ inputs.ansible-core-version || steps.get.outputs.ansible-core-version }}
38+
docker-exclude:
39+
description: Array of matrix excludes for docker
40+
value: ${{ inputs.docker-exclude || steps.get.outputs.docker-exclude }}
41+
docker-image:
42+
description: Array of docker images
43+
value: ${{ inputs.docker-image || steps.get.outputs.docker-image }}
44+
docker-include:
45+
description: Array of matrix includes for docker
46+
value: ${{ inputs.docker-include || steps.get.outputs.docker-include }}
47+
python-version:
48+
description: Array of python versions (controler)
49+
value: ${{ inputs.python-version || steps.get.outputs.python-version }}
50+
target-python-exclude:
51+
description: Array of excludes target python versions
52+
value: ${{ inputs.target-python-exclude || steps.get.outputs.target-python-exclude }}
53+
target-python-version:
54+
description: Array of target python versions (managed)
55+
value: ${{ inputs.target-python-version || steps.get.outputs.target-python-version }}
56+
57+
runs:
58+
using: "composite"
59+
steps:
60+
- run: >
61+
echo -e "
62+
\tansible-test-versions-gh-action \n
63+
\tCopyright (C) 2021 Cédric Villemain ( https://Data-Bene.io) \n
64+
\tThis program comes with ABSOLUTELY NO WARRANTY. \n
65+
\tThis is free software, and you are welcome to redistribute it \n
66+
\tunder certain conditions. \n"
67+
shell: bash
68+
69+
- run: ${{ github.action_path }}/get_versions.sh ${{ github.action_path }}/versions.yml
70+
id: get
71+
shell: bash
72+
...

get_versions.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /usr/bin/env bash
2+
3+
[[ ! -e "$1" ]] && echo "::error file=$1::NOT FOUND" && exit 1
4+
5+
verions_file="$1"
6+
7+
ansible_core_version=$(yq eval -o=json --indent 0 --no-colors --no-doc '.ansible-core-version' "${verions_file}")
8+
docker_exclude=$(yq eval -o=json --indent 0 --no-colors --no-doc '.docker-exclude' "${verions_file}")
9+
docker_image=$(yq eval -o=json --indent 0 --no-colors --no-doc '.docker-image' "${verions_file}")
10+
docker_include=$(yq eval -o=json --indent 0 --no-colors --no-doc '.docker-include' "${verions_file}")
11+
python_version=$(yq eval -o=json --indent 0 --no-colors --no-doc '.python-version' "${verions_file}")
12+
target_python_exclude=$(yq eval -o=json --indent 0 --no-colors --no-doc '.target-python-exclude' "${verions_file}")
13+
target_python_version=$(yq eval -o=json --indent 0 --no-colors --no-doc '.target-python-version' "${verions_file}")
14+
15+
echo "::debug::ansible-core-version=${ansible_core_version}"
16+
echo "::debug::docker-exclude=${docker_exclude}"
17+
echo "::debug::docker-image=${docker_image}"
18+
echo "::debug::docker-include=${docker_include}"
19+
echo "::debug::target-python-exclude=${target_python_exclude}"
20+
echo "::debug::target-python-version=${target_python_version}"
21+
echo "::debug::python-version=${python_version}"
22+
23+
echo "::set-output name=ansible-core-version::${ansible_core_version}"
24+
echo "::set-output name=docker-exclude::${docker_exclude}"
25+
echo "::set-output name=docker-image::${docker_image}"
26+
echo "::set-output name=docker-include::${docker_include}"
27+
echo "::set-output name=python-version::${python_version}"
28+
echo "::set-output name=target-python-exclude::${target_python_exclude}"
29+
echo "::set-output name=target-python-version::${target_python_version}"

versions.yml

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
# https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html#ansible-core-changelogs
3+
ansible-core-version:
4+
- stable-2.9 # EOL May 2022
5+
- stable-2.10 # EOL May 2022
6+
- stable-2.11 # EOL May 2022
7+
- stable-2.12 # EOL May 2023
8+
- devel
9+
10+
python-version:
11+
- 3.8
12+
13+
# devel: https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/_data/completion/docker.txt
14+
docker-image:
15+
- alpine3 # python 3.9
16+
- centos6 # python 2.6
17+
- centos7 # python 2.7
18+
- centos8 # python 3.6
19+
- fedora34 # python 3.9
20+
- opensuse15py2 # python 2.7
21+
- opensuse15 # python 3.6
22+
- ubuntu1804 # python 3.6
23+
- ubuntu2004 # python 3.8
24+
25+
docker-include:
26+
- ansible-core-version: stable-2.9
27+
docker-image: fedora30 # python 3.7
28+
python-version: 3.8
29+
- ansible-core-version: stable-2.9
30+
docker-image: fedora31 # python 3.7
31+
python-version: 3.8
32+
- ansible-core-version: stable-2.9
33+
docker-image: ubuntu1604 # python 2.7
34+
python-version: 3.8
35+
- ansible-core-version: stable-2.10
36+
docker-image: fedora30 # python 3.7
37+
python-version: 3.8
38+
- ansible-core-version: stable-2.10
39+
docker-image: fedora31 # python 3.7
40+
python-version: 3.8
41+
- ansible-core-version: stable-2.10
42+
docker-image: fedora32 # python 3.8
43+
python-version: 3.8
44+
- ansible-core-version: stable-2.10
45+
docker-image: ubuntu1604 # python 2.7
46+
python-version: 3.8
47+
- ansible-core-version: stable-2.11
48+
docker-image: fedora32 # python 3.8
49+
python-version: 3.8
50+
- ansible-core-version: stable-2.11
51+
docker-image: fedora33 # python 3.9
52+
python-version: 3.8
53+
- ansible-core-version: stable-2.12
54+
docker-image: centos6 # python 2.6
55+
python-version: 3.8
56+
- ansible-core-version: stable-2.12
57+
docker-image: fedora33 # python 3.9
58+
python-version: 3.8
59+
- ansible-core-version: devel
60+
docker-image: fedora35 # python 3.10
61+
python-version: 3.8
62+
63+
docker-exclude:
64+
- ansible-core-version: stable-2.9
65+
docker-image: alpine3
66+
- ansible-core-version: stable-2.9
67+
docker-image: fedora34
68+
- ansible-core-version: stable-2.9
69+
docker-image: ubuntu2004
70+
- ansible-core-version: stable-2.10
71+
docker-image: alpine3
72+
- ansible-core-version: stable-2.10
73+
docker-image: fedora34
74+
- ansible-core-version: stable-2.11
75+
docker-image: fedora34
76+
- ansible-core-version: devel
77+
docker-image: centos6
78+
- ansible-core-version: devel
79+
docker-image: centos8
80+
81+
target-python-version:
82+
- 3.9
83+
- 3.8
84+
- 3.7
85+
- 3.6
86+
- 3.5
87+
- 2.7
88+
- 2.6
89+
90+
target-python-exclude:
91+
- ansible-core-version: stable-2.9
92+
target-python-version: 3.9
93+
- ansible-core-version: stable-2.9
94+
target-python-version: 3.10
95+
- ansible-core-version: stable-2.10
96+
target-python-version: 3.10
97+
- ansible-core-version: stable-2.11
98+
target-python-version: 3.10
99+
- ansible-core-version: devel
100+
target-python-version: 2.6

0 commit comments

Comments
 (0)