Skip to content

ci: do not run ci tests by default, require citest comment or label [citest_skip] #567

ci: do not run ci tests by default, require citest comment or label [citest_skip]

ci: do not run ci tests by default, require citest comment or label [citest_skip] #567

Workflow file for this run

---
name: Ansible Test
on: # yamllint disable-line rule:truthy
pull_request:
types:
- opened
- synchronize
- labeled
issue_comment:
types:
- created
merge_group:
branches:
- main
types:
- checks_requested
push:
branches:
- main
workflow_dispatch:
env:
LSR_ROLE2COLL_NAMESPACE: fedora
LSR_ROLE2COLL_NAME: linux_system_roles
permissions:
contents: read
pull-requests: read
jobs:
ansible_test:
if: |
(
github.event_name == 'issue_comment'
&& github.event.issue.pull_request
&& (contains(github.event.comment.body, '[citest_all]')
|| contains(github.event.comment.body, '[citest_ansible-test]'))
&& (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'),
github.event.comment.author_association)
|| github.event.comment.user.login == 'systemroller')
) || (
github.event_name == 'pull_request'
&& github.event.action == 'opened'
&& (contains(github.event.pull_request.labels.*.name, 'citest_all')
|| contains(github.event.pull_request.labels.*.name, 'citest_ansible-test'))
&& (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'),
github.event.pull_request.author_association)
|| github.event.pull_request.user.login == 'systemroller')
) || (
github.event_name == 'pull_request'
&& github.event.action == 'synchronize'
&& (contains(github.event.pull_request.labels.*.name, 'citest_all')
|| contains(github.event.pull_request.labels.*.name, 'citest_ansible-test'))
&& (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'),
github.event.pull_request.author_association)
|| github.event.sender.login == 'systemroller')
) || (
github.event_name == 'pull_request'
&& github.event.action == 'labeled'
&& (github.event.label.name == 'citest_all'
|| github.event.label.name == 'citest_ansible-test')
&& (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'),
github.event.pull_request.author_association)
|| github.event.sender.login == 'systemroller')
)
runs-on: ubuntu-latest
strategy:
fail-fast: false # get all results, not just the first failure
matrix:
versions:
- { ansible: "2-14", python: "3.9" }
- { ansible: "2-16", python: "3.11" }
- { ansible: "2-17", python: "3.12" }
- { ansible: "2-18", python: "3.12" }
- { ansible: "2-19", python: "3.13" }
- { ansible: "2-20", python: "3.13" }
- { ansible: "milestone", python: "3.13" }
steps:
- name: Update pip, git
run: |
set -euxo pipefail
python3 -m pip install --upgrade pip
sudo apt update
sudo apt install -y git
- name: Get PR head SHA
if: github.event_name == 'issue_comment'
id: head_sha
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
set -euxo pipefail
head_sha=$(gh api "repos/$REPO/pulls/$PR_NUMBER" --jq '.head.sha')
echo "head_sha=$head_sha" >> "$GITHUB_OUTPUT"
- name: Checkout repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
ref: ${{ steps.head_sha.outputs.head_sha || github.sha }}
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@d594be24ed56e586a5796720d51c261e40c20496"
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version: ${{ matrix.versions.python }}
- name: Convert role to collection format
run: tox -e collection
- name: Run ansible-test
run: |
tox \
-x testenv:ansible-test-${{ matrix.versions.ansible }}.basepython="python${{ matrix.versions.python }}" \
-e ansible-test-${{ matrix.versions.ansible }}