Skip to content

Commit

Permalink
Add action with README
Browse files Browse the repository at this point in the history
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
c2main committed Nov 22, 2021
1 parent d93fc15 commit 62a3644
Show file tree
Hide file tree
Showing 5 changed files with 287 additions and 20 deletions.
26 changes: 6 additions & 20 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,9 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

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

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

<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
ansible-test-versions-gh-action
Copyright (C) 2021 Cédric Villemain ( https://Data-Bene.io)
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
80 changes: 80 additions & 0 deletions README.md
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)
72 changes: 72 additions & 0 deletions action.yml
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
...
29 changes: 29 additions & 0 deletions get_versions.sh
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}"
100 changes: 100 additions & 0 deletions versions.yml
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

0 comments on commit 62a3644

Please sign in to comment.