Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Testing Ideas #608

Draft
wants to merge 11 commits into
base: devel
Choose a base branch
from
5 changes: 4 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ exclude_paths:
- .vagrant/
- changelogs/
- docs/
- tests/integration/

# parseable: true
# quiet: true
# verbosity: 1
Expand Down Expand Up @@ -74,7 +76,8 @@ skip_list:
# - all

# Offline mode disables installation of requirements.yml
offline: true
# offline: true
offline: false

# # Define required Ansible's variables to satisfy syntax check
# extra_vars:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ans-int-test-activation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ env:
COLLECTION_NAME: general
MODULE_NAME: activation

# https://stackoverflow.com/questions/70928424/limit-github-action-workflow-concurrency-on-push-and-pull-request
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Activation Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-bakery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: bakery

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Bakery Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-contact_group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: contact_group

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Contact Group Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-discovery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: discovery

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Discovery Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-downtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: downtime

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Downtime Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-folder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: folder

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Folder Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: host

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Host Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-host_group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: host_group

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Host Group Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-lkp-bakery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: lookup_bakery

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Bakery Lookup Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-lkp-folder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: lookup_folder

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Folder Lookup Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-lkp-folders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: lookup_folders

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Folders Lookup Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-lkp-host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: lookup_host

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Host Lookup Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-lkp-hosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: lookup_hosts

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Hosts Lookup Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-lkp-rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: lookup_rules

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Rule Lookup Modules
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-lkp-rulesets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: lookup_rulesets

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Ruleset Lookup Modules
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-lkp-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: lookup_version

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Version Lookup Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-password.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: password

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Password Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-rule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: rule

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Rule Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-service_group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: service_group

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Service Group Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-tag_group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: tag_group

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Tag Group Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-timeperiod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: timeperiod

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for Timeperiod Module
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ans-int-test-user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
COLLECTION_NAME: general
MODULE_NAME: user

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: Ansible Integration Tests for User Module
on:
workflow_dispatch:
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/ansible-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Resources:
# - https://github.com/ansible/ansible-content-actions
---
name: "Ansible Tests"

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
pull_request:
branches: [main, devel, build/new-testing-ideas]
push:
branches: [main, devel, build/new-testing-ideas]
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

jobs:
changelog:
uses: ansible/ansible-content-actions/.github/workflows/changelog.yaml@main
if: github.event_name == 'pull_request'

ansible-lint:
uses: ansible/ansible-content-actions/.github/workflows/ansible_lint.yaml@main
with:
args: "-c .ansible-lint"

sanity:
uses: ansible/ansible-content-actions/.github/workflows/sanity.yaml@main

## We do not have unit tests (yet)
# unit-galaxy:
# uses: ansible/ansible-content-actions/.github/workflows/unit.yaml@main

integration:
uses: ansible/ansible-content-actions/.github/workflows/integration.yaml@main

all_green:
if: ${{ always() }}
needs:
- changelog
- sanity
- integration
# - unit-galaxy
- ansible-lint
runs-on: ubuntu-latest
steps:
# - run: >-
# python -c "assert 'failure' not in
# set([
# '${{ needs.changelog.result }}',
# '${{ needs.integration.result }}',
# '${{ needs.sanity.result }}',
# '${{ needs.unit-galaxy.result }}'
# '${{ needs.ansible-lint.result }}'
# ])"
- run: >-
python -c "assert 'failure' not in
set([
'${{ needs.changelog.result }}',
'${{ needs.integration.result }}',
'${{ needs.sanity.result }}',
'${{ needs.ansible-lint.result }}'
])"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ playbooks/vars/config.yml
playbooks/test*.yml
playbooks/hosts
playbooks/hosts.bak
venv/
Vagrantfile
Vagrantfile.bak
venv
3 changes: 2 additions & 1 deletion Vagrantfile.kvm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Vagrant.configure("2") do |config|
end
$script = <<-SCRIPT
apt-get -y update --quiet
apt-get -y install python3-pip ca-certificates curl gnupg lsb-release qemu-guest-agent
add-apt-repository -y ppa:deadsnakes
apt-get -y install python3-pip ca-certificates curl gnupg lsb-release qemu-guest-agent python3.8 python3.9 python3.10 python3.11 python3.12
sudo -u vagrant python3 -m pip install pip --upgrade
sudo -u vagrant python3 -m pip install -r /home/vagrant/ansible_collections/checkmk/general/requirements.txt
sudo -u vagrant python3 -m pip install -r /home/vagrant/ansible_collections/checkmk/general/requirements-qa.txt
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ molecule >= 5.0.1
molecule-plugins[docker]
yamllint
pywinrm
netaddr
netaddr
tox-ansible
15 changes: 15 additions & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://ansible.readthedocs.io/projects/tox-ansible/user_guide/#testing-molecule-scenarios

"""Tests for molecule scenarios."""
from __future__ import absolute_import, division, print_function

from pytest_ansible.molecule import MoleculeScenario


def test_integration(molecule_scenario: MoleculeScenario) -> None:
"""Run molecule for each scenario.

:param molecule_scenario: The molecule scenario object
"""
proc = molecule_scenario.test()
assert proc.returncode == 0
Empty file added tox-ansible.ini
Empty file.
Loading