-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from gardar/ci/testing
feat: role/collection testing with ansible-test and molecule
- Loading branch information
Showing
84 changed files
with
465 additions
and
977 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
profile: production |
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,60 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
lint: | | ||
set -e | ||
yamllint -c ${YAMLLINT_CONFIG_FILE} . | ||
ansible-lint | ||
platforms: | ||
- name: almalinux-8 | ||
image: dokken/almalinux-8 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: centos-7 | ||
image: dokken/centos-7 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /usr/lib/systemd/systemd | ||
- name: centos-stream-8 | ||
image: dokken/centos-stream-8 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: debian-9 | ||
image: dokken/debian-9 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: debian-10 | ||
image: dokken/debian-10 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: debian-11 | ||
image: dokken/debian-11 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: fedora-30 | ||
image: dokken/fedora-30 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
- name: ubuntu-18.04 | ||
image: dokken/ubuntu-18.04 | ||
pre_build_image: true | ||
privileged: true | ||
cgroup_parent: docker.slice | ||
command: /lib/systemd/systemd | ||
verifier: | ||
name: testinfra |
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,23 @@ | ||
--- | ||
extends: default | ||
|
||
rules: | ||
braces: | ||
max-spaces-inside: 1 | ||
level: error | ||
brackets: | ||
max-spaces-inside: 1 | ||
level: error | ||
colons: | ||
max-spaces-after: -1 | ||
level: error | ||
commas: | ||
max-spaces-after: -1 | ||
level: error | ||
empty-lines: | ||
max: 3 | ||
level: error | ||
hyphens: | ||
level: error | ||
line-length: | ||
max: 160 |
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,98 @@ | ||
--- | ||
name: Ansible CI | ||
on: [push, pull_request] | ||
|
||
env: | ||
ANSIBLE_FORCE_COLOR: true | ||
|
||
jobs: | ||
ansible-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Lint collection | ||
uses: ansible/ansible-lint-action@main | ||
|
||
discover-ansible-versions: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
versions: ${{ steps.supported-ansible-versions.outputs.result }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get Ansible versions that the collection supports | ||
id: supported-ansible-versions | ||
uses: mikefarah/yq@master | ||
with: | ||
cmd: yq -o json -I=0 '.requires_ansible | split(",") | .[] |= sub("(.*)", "stable-${1}")' meta/runtime.yml | ||
|
||
ansible-test-sanity: | ||
uses: ./.github/workflows/ansible-test-sanity.yml | ||
needs: | ||
- ansible-lint | ||
- discover-ansible-versions | ||
with: | ||
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }} | ||
|
||
discover-ansible-tests: | ||
runs-on: ubuntu-latest | ||
needs: ansible-lint | ||
outputs: | ||
molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }} | ||
integration-tests: ${{ steps.set-integration-tests.outputs.tests }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get changed roles | ||
id: changed-roles | ||
uses: tj-actions/changed-files@v35 | ||
with: | ||
path: "roles" | ||
diff_relative: "true" | ||
files: "**" | ||
dir_names: "true" | ||
dir_names_max_depth: "1" | ||
since_last_remote_commit: "true" | ||
|
||
- name: Discover role tests | ||
if: steps.changed-roles.outputs.any_changed == 'true' | ||
id: set-molecule-tests | ||
run: | | ||
echo tests="[`for role in ${{ steps.changed-roles.outputs.all_changed_and_modified_files }}; do | ||
for test in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -iname "molecule-${role}-*" -printf "%f\n"); do | ||
echo '{"test":\"'"${test}"'\","name":\"'"${test#*-}\"'"}'; | ||
done | ||
done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT | ||
- name: Discover integration tests | ||
id: set-integration-tests | ||
run: | | ||
echo tests="[`for test in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -not -iname "molecule-*" -printf "%f\n"); do | ||
echo '{"test":\"'"${test}"'\","name":\"'"${test}\"'"}'; | ||
done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT | ||
ansible-test-molecule: | ||
uses: ./.github/workflows/ansible-test-integration.yml | ||
needs: | ||
- discover-ansible-tests | ||
- discover-ansible-versions | ||
if: needs.discover-ansible-tests.outputs.molecule-tests != '[]' && | ||
needs.discover-ansible-tests.outputs.molecule-tests != '' | ||
with: | ||
targets: ${{ needs.discover-ansible-tests.outputs.molecule-tests }} | ||
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }} | ||
|
||
ansible-test-integration: | ||
uses: ./.github/workflows/ansible-test-integration.yml | ||
needs: | ||
- discover-ansible-tests | ||
- discover-ansible-versions | ||
if: | ||
needs.discover-ansible-tests.outputs.integration-tests != '[]' && | ||
needs.discover-ansible-tests.outputs.integration-tests != '' | ||
with: | ||
targets: ${{ needs.discover-ansible-tests.outputs.integration-tests }} | ||
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }} |
This file was deleted.
Oops, something went wrong.
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,39 @@ | ||
--- | ||
name: Ansible Integration Test | ||
on: | ||
workflow_call: | ||
inputs: | ||
targets: | ||
required: true | ||
type: string | ||
ansible-core-versions: | ||
required: false | ||
default: '["stable-2.14"]' | ||
type: string | ||
target-python-versions: | ||
required: false | ||
default: '["default"]' | ||
type: string | ||
|
||
jobs: | ||
ansible-test-integration: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
targets: ${{ fromJson(inputs.targets) }} | ||
ansible-core-versions: ${{ fromJson(inputs.ansible-core-versions) }} | ||
target-python-versions: ${{ fromJson(inputs.target-python-versions) }} | ||
|
||
name: "${{ matrix.targets.name }}-${{ matrix.ansible-core-versions }}" | ||
steps: | ||
- name: "Perform ${{ matrix.targets.test }} integration test with ansible-test" | ||
uses: ansible-community/ansible-test-gh-action@release/v1 | ||
with: | ||
ansible-core-version: ${{ matrix.ansible-core-versions }} | ||
target-python-version: ${{ matrix.target-python-versions }} | ||
controller-python-version: auto | ||
docker-image: "--docker-privileged" # Workaround because ansible-test action doesn't support setting privileged flag | ||
testing-type: integration | ||
target: ${{ matrix.targets.test }} | ||
# coverage: never # https://github.com/ansible-community/ansible-test-gh-action/pull/50 |
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,25 @@ | ||
--- | ||
name: Ansible Sanity Test | ||
on: | ||
workflow_call: | ||
inputs: | ||
ansible-core-versions: | ||
required: false | ||
default: '["stable-2.14"]' | ||
type: string | ||
|
||
jobs: | ||
ansible-test-sanity: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ansible-core-versions: ${{ fromJson(inputs.ansible-core-versions) }} | ||
|
||
name: "sanity-${{ matrix.ansible-core-versions }}" | ||
steps: | ||
- name: "Perform sanity test with ansible-test" | ||
uses: ansible-community/ansible-test-gh-action@release/v1 | ||
with: | ||
ansible-core-version: ${{ matrix.ansible-core-versions }} | ||
testing-type: sanity |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
namespace: prometheus | ||
name: prometheus | ||
version: 0.0.1 | ||
version: 1.0.0 | ||
|
||
readme: README.md | ||
authors: | ||
|
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
requires_ansible: '>=2.9.10' | ||
requires_ansible: "2.9,2.10,2.11,2.12,2.13,2.14" |
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 |
---|---|---|
@@ -1,70 +1 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: bionic | ||
pre_build_image: true | ||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04 | ||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: xenial | ||
pre_build_image: true | ||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04 | ||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: stretch | ||
pre_build_image: true | ||
image: quay.io/paulfantom/molecule-systemd:debian-9 | ||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: buster | ||
pre_build_image: true | ||
image: quay.io/paulfantom/molecule-systemd:debian-10 | ||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: centos7 | ||
pre_build_image: true | ||
image: quay.io/paulfantom/molecule-systemd:centos-7 | ||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
- name: centos8 | ||
pre_build_image: true | ||
image: quay.io/paulfantom/molecule-systemd:centos-8 | ||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
groups: | ||
- python3 | ||
- name: fedora | ||
pre_build_image: true | ||
image: quay.io/paulfantom/molecule-systemd:fedora-30 | ||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" | ||
privileged: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:ro | ||
groups: | ||
- python3 | ||
provisioner: | ||
name: ansible | ||
playbooks: | ||
prepare: prepare.yml | ||
converge: playbook.yml | ||
inventory: | ||
group_vars: | ||
python3: | ||
ansible_python_interpreter: /usr/bin/python3 | ||
verifier: | ||
name: testinfra |
5 changes: 4 additions & 1 deletion
5
roles/alertmanager/molecule/alternative/tests/test_alternative.py
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
Oops, something went wrong.