Skip to content

Run tests

Run tests #132

Workflow file for this run

name: Run tests
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
pull_request:
branches: [main]
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
workflow_call:
inputs:
integration_test_path:
default: tests/integration/targets
required: false
type: string
pytest_addopts:
default: ""
required: false
type: string
jobs:
ansible-lint:
uses: ./.github/workflows/ansible-lint.yml
integration:
env:
PY_COLORS: "1"
source_directory: "./source"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ansible-version:
- stable-2.15
- stable-2.16
- stable-2.17
python-version:
- "3.10"
- "3.11"
- "3.12"
exclude:
- ansible-version: stable-2.15
python-version: "3.12"
name: "py${{ matrix.python-version }} / ${{ matrix.ansible-version }}"
steps:
- name: Checkout the collection repository
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
with:
path: ${{ env.source_directory }}
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: "0"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install wheel now for faster builds
run: python3 -m pip install wheel --upgrade
- name: Install ansible-core (${{ matrix.ansible-version }})
run: python3 -m pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check
- name: Read collection metadata from galaxy.yml
id: identify
uses: ansible-network/github_actions/.github/actions/identify_collection@main
with:
source_path: ${{ env.source_directory }}
- name: Build and install the collection
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
with:
install_python_dependencies: true
source_path: ${{ env.source_directory }}
collection_path: ${{ steps.identify.outputs.collection_path }}
tar_file: ${{ steps.identify.outputs.tar_file }}
ansible_version: ${{ matrix.ansible-version }}
- name: Print the ansible version
run: ansible --version
- name: Print the python dependencies
run: python3 -m pip list
- name: Run integration tests
run: >-
python -m pytest tests/integration
${{ inputs.pytest_addopts }}
env:
ANSIBLE_FORCE_COLOR: "1"
working-directory: ${{ steps.identify.outputs.collection_path }}
# uncomment for more verbose output
# comment out the above step
# - name: Run integration tests using molecule
# run: >-
# molecule --debug test
# env:
# ANSIBLE_FORCE_COLOR: "1"
# working-directory: "${{ steps.identify.outputs.collection_path }}/extensions"
- name: Upload logs
if: always()
uses: actions/upload-artifact@v3
with:
name: logs
path: /home/runner/test_logs/
sanity:
uses: ansible-network/github_actions/.github/workflows/sanity.yml@main
all_green:
if: ${{ always() && (github.event_name != 'schedule') }}
needs:
- integration
- sanity
runs-on: ubuntu-latest
steps:
- run: >-
python -c "assert set([
'${{ needs.integration.result }}',
'${{ needs.sanity.result }}'
]) == {'success'}"