-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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)
- Loading branch information
Showing
5 changed files
with
287 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# ansible-test-versions-gh-action for setting up job matrix in Ansible Collection repositories | ||
|
||
GitHub Action for setting up job matrix based on expected ansible, python and | ||
docker image support for Ansible Collections. | ||
|
||
## Usage | ||
|
||
To use the action add the following step to your workflow file (e.g. | ||
`.github/workflows/ansible-test.yml`), example for sanity tests: | ||
|
||
```yaml | ||
steps: | ||
- name: Get the job matrix parameters for ansible-test as JSON | ||
uses: data-bene/ansible-test-versions-gh-action@release/v1 | ||
id: default-matrix | ||
with: | ||
python-version: '[ "3.9" ]' | ||
strategy: | ||
fail-fast: ${{ inputs.fail-fast }} | ||
matrix: | ||
ansible-core-version: ${{ fromJSON(define-matrix.outputs.ansible-core-version) }} | ||
python-version: ${{ fromJSON(define-matrix.outputs.python-version) }} | ||
target-python-version: ${{ fromJSON(define-matrix.outputs.target-python-version) }} | ||
exclude: ${{ fromJSON(define-matrix.outputs.target-python-exclude) }} | ||
``` | ||
And for integration tests: | ||
```yaml | ||
steps: | ||
- name: Get the job matrix parameters for ansible-test as JSON | ||
uses: data-bene/ansible-test-versions-gh-action@release/v1 | ||
id: default-matrix | ||
with: | ||
docker-image: '[ "ubuntu2004" ]' | ||
docker-include: '[]' | ||
strategy: | ||
fail-fast: ${{ inputs.fail-fast }} | ||
matrix: | ||
ansible-core-version: ${{ fromJSON(define-matrix.outputs.ansible-core-version) }} | ||
python-version: ${{ fromJSON(define-matrix.outputs.python-version) }} | ||
docker-image: ${{ fromJSON(define-matrix.outputs.docker-image) }} | ||
exclude: ${{ fromJSON(define-matrix.outputs.docker-exclude) }} | ||
include: ${{ fromJSON(define-matrix.outputs.docker-include) }} | ||
|
||
``` | ||
|
||
|
||
> **Pro tip**: instead of using branch pointers, like `main`, pin | ||
versions of Actions that you use to tagged versions or SHA-1 commit | ||
identifiers. This will make your workflows more secure and better | ||
reproducible, saving you from sudden and unpleasant surprises. | ||
|
||
## inputs | ||
|
||
When set the inputs replace the default values, inputs MUST be JSON. | ||
|
||
* `ansible-core-version`: Array of ansible versions (required: false) | ||
* `docker-exclude`: Array of matrix excludes for docker (required: false) | ||
* `docker-image`: Array of docker images (required: false) | ||
* `docker-include`: Array of matrix includes for docker (required: false) | ||
* `python-version`: Array of python versions (controler) (required: false) | ||
* `target-python-exclude`: Array of excludes target python versions (required: false) | ||
* `target-python-version`: Array of target python versions (managed) (required: false) | ||
|
||
## outputs | ||
|
||
JSON outputs: | ||
|
||
* `ansible-core-version`: Array of ansible versions | ||
* `docker-exclude`: Array of matrix excludes for docker | ||
* `docker-image`: Array of docker images | ||
* `docker-include`: Array of matrix includes for docker | ||
* `python-version`: Array of python versions (controler) | ||
* `target-python-exclude`: Array of excludes target python versions | ||
* `target-python-version`: Array of target python versions (managed) | ||
|
||
# Developed and Sponsored by | ||
|
||
[Data Bene](https://data-bene.io) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
name: ansible-test-versions | ||
author: Cédric Villemain <https://Data-Bene.io> | ||
branding: | ||
icon: check-circle | ||
color: gray-dark | ||
description: >- | ||
GitHub Action for setting up job matrix based on expected ansible, python and | ||
docker image support for Ansible Collections. | ||
inputs: | ||
ansible-core-version: | ||
description: Array of ansible versions | ||
required: false | ||
docker-exclude: | ||
description: Array of matrix excludes for docker | ||
required: false | ||
docker-image: | ||
description: Array of docker images | ||
required: false | ||
docker-include: | ||
description: Array of matrix includes for docker | ||
required: false | ||
python-version: | ||
description: Array of python versions (controler) | ||
required: false | ||
target-python-exclude: | ||
description: Array of excludes target python versions | ||
required: false | ||
target-python-version: | ||
description: Array of target python versions (managed) | ||
required: false | ||
|
||
outputs: | ||
ansible-core-version: | ||
description: Array of ansible versions | ||
value: ${{ inputs.ansible-core-version || steps.get.outputs.ansible-core-version }} | ||
docker-exclude: | ||
description: Array of matrix excludes for docker | ||
value: ${{ inputs.docker-exclude || steps.get.outputs.docker-exclude }} | ||
docker-image: | ||
description: Array of docker images | ||
value: ${{ inputs.docker-image || steps.get.outputs.docker-image }} | ||
docker-include: | ||
description: Array of matrix includes for docker | ||
value: ${{ inputs.docker-include || steps.get.outputs.docker-include }} | ||
python-version: | ||
description: Array of python versions (controler) | ||
value: ${{ inputs.python-version || steps.get.outputs.python-version }} | ||
target-python-exclude: | ||
description: Array of excludes target python versions | ||
value: ${{ inputs.target-python-exclude || steps.get.outputs.target-python-exclude }} | ||
target-python-version: | ||
description: Array of target python versions (managed) | ||
value: ${{ inputs.target-python-version || steps.get.outputs.target-python-version }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- run: > | ||
echo -e " | ||
\tansible-test-versions-gh-action \n | ||
\tCopyright (C) 2021 Cédric Villemain ( https://Data-Bene.io) \n | ||
\tThis program comes with ABSOLUTELY NO WARRANTY. \n | ||
\tThis is free software, and you are welcome to redistribute it \n | ||
\tunder certain conditions. \n" | ||
shell: bash | ||
- run: ${{ github.action_path }}/get_versions.sh ${{ github.action_path }}/versions.yml | ||
id: get | ||
shell: bash | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#! /usr/bin/env bash | ||
|
||
[[ ! -e "$1" ]] && echo "::error file=$1::NOT FOUND" && exit 1 | ||
|
||
verions_file="$1" | ||
|
||
ansible_core_version=$(yq eval -o=json --indent 0 --no-colors --no-doc '.ansible-core-version' "${verions_file}") | ||
docker_exclude=$(yq eval -o=json --indent 0 --no-colors --no-doc '.docker-exclude' "${verions_file}") | ||
docker_image=$(yq eval -o=json --indent 0 --no-colors --no-doc '.docker-image' "${verions_file}") | ||
docker_include=$(yq eval -o=json --indent 0 --no-colors --no-doc '.docker-include' "${verions_file}") | ||
python_version=$(yq eval -o=json --indent 0 --no-colors --no-doc '.python-version' "${verions_file}") | ||
target_python_exclude=$(yq eval -o=json --indent 0 --no-colors --no-doc '.target-python-exclude' "${verions_file}") | ||
target_python_version=$(yq eval -o=json --indent 0 --no-colors --no-doc '.target-python-version' "${verions_file}") | ||
|
||
echo "::debug::ansible-core-version=${ansible_core_version}" | ||
echo "::debug::docker-exclude=${docker_exclude}" | ||
echo "::debug::docker-image=${docker_image}" | ||
echo "::debug::docker-include=${docker_include}" | ||
echo "::debug::target-python-exclude=${target_python_exclude}" | ||
echo "::debug::target-python-version=${target_python_version}" | ||
echo "::debug::python-version=${python_version}" | ||
|
||
echo "::set-output name=ansible-core-version::${ansible_core_version}" | ||
echo "::set-output name=docker-exclude::${docker_exclude}" | ||
echo "::set-output name=docker-image::${docker_image}" | ||
echo "::set-output name=docker-include::${docker_include}" | ||
echo "::set-output name=python-version::${python_version}" | ||
echo "::set-output name=target-python-exclude::${target_python_exclude}" | ||
echo "::set-output name=target-python-version::${target_python_version}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
# https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html#ansible-core-changelogs | ||
ansible-core-version: | ||
- stable-2.9 # EOL May 2022 | ||
- stable-2.10 # EOL May 2022 | ||
- stable-2.11 # EOL May 2022 | ||
- stable-2.12 # EOL May 2023 | ||
- devel | ||
|
||
python-version: | ||
- 3.8 | ||
|
||
# devel: https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/_data/completion/docker.txt | ||
docker-image: | ||
- alpine3 # python 3.9 | ||
- centos6 # python 2.6 | ||
- centos7 # python 2.7 | ||
- centos8 # python 3.6 | ||
- fedora34 # python 3.9 | ||
- opensuse15py2 # python 2.7 | ||
- opensuse15 # python 3.6 | ||
- ubuntu1804 # python 3.6 | ||
- ubuntu2004 # python 3.8 | ||
|
||
docker-include: | ||
- ansible-core-version: stable-2.9 | ||
docker-image: fedora30 # python 3.7 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.9 | ||
docker-image: fedora31 # python 3.7 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.9 | ||
docker-image: ubuntu1604 # python 2.7 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.10 | ||
docker-image: fedora30 # python 3.7 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.10 | ||
docker-image: fedora31 # python 3.7 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.10 | ||
docker-image: fedora32 # python 3.8 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.10 | ||
docker-image: ubuntu1604 # python 2.7 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.11 | ||
docker-image: fedora32 # python 3.8 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.11 | ||
docker-image: fedora33 # python 3.9 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.12 | ||
docker-image: centos6 # python 2.6 | ||
python-version: 3.8 | ||
- ansible-core-version: stable-2.12 | ||
docker-image: fedora33 # python 3.9 | ||
python-version: 3.8 | ||
- ansible-core-version: devel | ||
docker-image: fedora35 # python 3.10 | ||
python-version: 3.8 | ||
|
||
docker-exclude: | ||
- ansible-core-version: stable-2.9 | ||
docker-image: alpine3 | ||
- ansible-core-version: stable-2.9 | ||
docker-image: fedora34 | ||
- ansible-core-version: stable-2.9 | ||
docker-image: ubuntu2004 | ||
- ansible-core-version: stable-2.10 | ||
docker-image: alpine3 | ||
- ansible-core-version: stable-2.10 | ||
docker-image: fedora34 | ||
- ansible-core-version: stable-2.11 | ||
docker-image: fedora34 | ||
- ansible-core-version: devel | ||
docker-image: centos6 | ||
- ansible-core-version: devel | ||
docker-image: centos8 | ||
|
||
target-python-version: | ||
- 3.9 | ||
- 3.8 | ||
- 3.7 | ||
- 3.6 | ||
- 3.5 | ||
- 2.7 | ||
- 2.6 | ||
|
||
target-python-exclude: | ||
- ansible-core-version: stable-2.9 | ||
target-python-version: 3.9 | ||
- ansible-core-version: stable-2.9 | ||
target-python-version: 3.10 | ||
- ansible-core-version: stable-2.10 | ||
target-python-version: 3.10 | ||
- ansible-core-version: stable-2.11 | ||
target-python-version: 3.10 | ||
- ansible-core-version: devel | ||
target-python-version: 2.6 |