Skip to content

ansible-test images #656

ansible-test images

ansible-test images #656

Workflow file for this run

---
name: ansible-test images
on:
push:
branches:
- main
paths:
- .github/workflows/ansible-test.yml
- ansible-test/**
pull_request:
branches:
- main
paths:
- .github/workflows/ansible-test.yml
- ansible-test/**
workflow_dispatch:
# Run daily (Monday at 08:00 UTC)
schedule:
- cron: '0 8 * * *'
env:
CONTAINER_REGISTRY: quay.io
CONTAINER_IMAGE_NAME: ansible-community/test-image
jobs:
build:
name: 'Build ansible-test images (${{ matrix.name }} with Python ${{ matrix.python }})'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- name: archlinux
python: '3.12'
ansible-core-1: ansible-core
ansible-core-2: devel
test-with-podman: true
test-with-docker: true
- name: debian-bullseye
python: '3.9'
ansible-core-1: ansible-core
ansible-core-2: devel
test-with-podman: true
test-with-docker: true
- name: debian-bookworm
python: '3.11'
ansible-core-1: ansible-core
ansible-core-2: devel
test-with-podman: true
test-with-docker: true
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
env:
ANSIBLE_CORE_1: ${{ matrix.ansible-core-1 }}
run: |
sudo apt-get install podman buildah
pip install "${ANSIBLE_CORE_1}"
- name: Build ${{ matrix.name }} image
env:
NAME: ${{ matrix.name }}
run: |
"${NAME}/build.sh"
podman tag "localhost/test-image:${NAME}" "${CONTAINER_REGISTRY}/${CONTAINER_IMAGE_NAME}:${NAME}"
working-directory: ./ansible-test/
# This is necessary to allow running systemd in rootless containers
- name: Start systemd user service
run: |
loginctl enable-linger runner
sleep 1
- name: Run basic tests with ${{ matrix.name }} image (${{ matrix.ansible-core-1 }}, Python versions ${{ matrix.python }}, Podman)
if: ${{ matrix.test-with-podman }}
env:
NAME: ${{ matrix.name }}
PYTHON_VERSIONS: ${{ matrix.python }}
ANSIBLE_TEST_PREFER_PODMAN: 1
run: |
for PYTHON in ${PYTHON_VERSIONS}; do
ansible-test integration --color -v --python "${PYTHON}" --docker "localhost/test-image:${NAME}" shippable/posix/group1/
done
working-directory: ./.github/ansible-test-tests/ansible_collections/testns/testcol
- name: Copy image from podman to docker
if: ${{ matrix.test-with-docker }}
env:
NAME: ${{ matrix.name }}
run: |
podman push "localhost/test-image:${NAME}" "docker-daemon:localhost/test-image:${NAME}"
- name: Install ansible-core ${{ matrix.ansible-core-2 }}
if: ${{ matrix.test-with-docker }}
env:
ANSIBLE_CORE_2: ${{ matrix.ansible-core-2 }}
run: |
pip install "https://github.com/ansible/ansible/archive/${ANSIBLE_CORE_2}.tar.gz"
- name: Run basic tests with ${{ matrix.name }} image (ansible-core ${{ matrix.ansible-core-2 }}, Python versions ${{ matrix.python }}, Docker)
if: ${{ matrix.test-with-docker }}
env:
NAME: ${{ matrix.name }}
PYTHON_VERSIONS: ${{ matrix.python }}
run: |
for PYTHON in ${PYTHON_VERSIONS}; do
ansible-test integration --color -v --python "${PYTHON}" --docker "localhost/test-image:${NAME}" shippable/posix/group1/
done
working-directory: ./.github/ansible-test-tests/ansible_collections/testns/testcol
- name: Publish container image as ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE_NAME }}:${{ matrix.name }}
if: github.event_name != 'pull_request'
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ env.CONTAINER_REGISTRY }}
image: ${{ env.CONTAINER_IMAGE_NAME }}
tags: ${{ matrix.name }}
username: ${{ secrets.quay_write_user }}
password: ${{ secrets.quay_write_pass }}