mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 03:43:09 +00:00
feat(ci): add workflow for running ansible-test and molecule
Signed-off-by: gardar <gardar@users.noreply.github.com>
This commit is contained in:
parent
c29734e418
commit
d2ff013bb3
4 changed files with 116 additions and 18 deletions
52
.github/workflows/ansible-ci.yml
vendored
Normal file
52
.github/workflows/ansible-ci.yml
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
name: Ansible CI
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
ANSIBLE_FORCE_COLOR: true
|
||||
|
||||
jobs:
|
||||
ansible-lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out codebase
|
||||
uses: actions/checkout@v3
|
||||
- name: Lint collection
|
||||
uses: ansible/ansible-lint-action@main
|
||||
|
||||
ansible-test-sanity:
|
||||
uses: ./.github/workflows/ansible-test-sanity.yml
|
||||
needs: ansible-lint
|
||||
with:
|
||||
ansible-core-versions: '["stable-2.9","stable-2.10","stable-2.11","stable-2.12","stable-2.13","stable-2.14"]'
|
||||
|
||||
discover-ansible-tests:
|
||||
runs-on: ubuntu-latest
|
||||
needs: ansible-lint
|
||||
outputs:
|
||||
molecule-tests: ${{ steps.set-tests.outputs.ansible-test-molecule }}
|
||||
integration-tests: ${{ steps.set-tests.outputs.ansible-test-integration }}
|
||||
steps:
|
||||
- name: Check out codebase
|
||||
uses: actions/checkout@v3
|
||||
- name: Discover tests
|
||||
id: set-tests
|
||||
run: |
|
||||
echo ansible-test-molecule="[`for x in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -iname "molecule-*" -printf "%f\n"); do echo '{"test":\"'"${x}"'\","name":\"'"${x#*-}\"'"}'; done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT
|
||||
echo ansible-test-integration="[`for x in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -not -iname "molecule-*" -printf "%f\n"); do echo '{"test":\"'"${x}"'\","name":\"'"${x}\"'"}'; done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT
|
||||
|
||||
ansible-test-molecule:
|
||||
uses: ./.github/workflows/ansible-test-integration.yml
|
||||
needs: discover-ansible-tests
|
||||
if: needs.discover-ansible-tests.outputs.molecule-tests != '[]'
|
||||
with:
|
||||
targets: ${{ needs.discover-ansible-tests.outputs.molecule-tests }}
|
||||
ansible-core-versions: '["stable-2.9","stable-2.10","stable-2.11","stable-2.12","stable-2.13","stable-2.14"]'
|
||||
|
||||
ansible-test-integration:
|
||||
uses: ./.github/workflows/ansible-test-integration.yml
|
||||
needs: discover-ansible-tests
|
||||
if: needs.discover-ansible-tests.outputs.integration-tests != '[]'
|
||||
with:
|
||||
targets: ${{ needs.discover-ansible-tests.outputs.integration-tests }}
|
||||
ansible-core-versions: '["stable-2.9","stable-2.10","stable-2.11","stable-2.12","stable-2.13","stable-2.14"]'
|
18
.github/workflows/ansible-lint.yml
vendored
18
.github/workflows/ansible-lint.yml
vendored
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
name: Ansible Lint
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
ANSIBLE_FORCE_COLOR: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Lint roles
|
||||
uses: ansible/ansible-lint-action@main
|
||||
with:
|
||||
path: roles
|
39
.github/workflows/ansible-test-integration.yml
vendored
Normal file
39
.github/workflows/ansible-test-integration.yml
vendored
Normal file
|
@ -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
|
25
.github/workflows/ansible-test-sanity.yml
vendored
Normal file
25
.github/workflows/ansible-test-sanity.yml
vendored
Normal file
|
@ -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
|
Loading…
Reference in a new issue