Compare commits

...

17 Commits
5.2.1 ... main

Author SHA1 Message Date
Felix Fontein
925eb15ded
Split nox step into prepare and execute. (#1283) 2026-06-14 18:30:50 +02:00
Felix Fontein
74cde23fe2
Add OpenSuSE Tumbleweed to CI. (#1282) 2026-06-11 19:00:42 +02:00
Felix Fontein
ce69e51d73
Fix/improve unit tests (#1281)
* Fix conditional import.

* Don't count lines for code coverage which should never execute.

* Fix tests to use pytest.raises.
2026-06-06 21:27:09 +02:00
Felix Fontein
604747372d
Use ansible-core devel EE on UBI 10 with Python 3.14. (#1279) 2026-06-06 13:27:28 +02:00
Felix Fontein
e401fa14c4 Forgot elif. 2026-06-05 10:48:32 +02:00
Felix Fontein
2778fb6336 Fix AZP CI nox script. 2026-06-05 10:42:39 +02:00
Felix Fontein
97fa83ee03
CI: Move ansible-core 2.18 completely to GHA (#1277)
* Move ansible-core 2.18 completely to GHA.

* Shorten group names.
2026-06-05 07:21:35 +00:00
Felix Fontein
c5a5d7c337
Support ci_coverage and ci_complete in GHA; handle affected unstable tests correctly in PRs. (#1275) 2026-06-05 06:15:53 +02:00
Felix Fontein
f369956247
Fix coverage reporting with AZP. (#1273)
ci_coverage
ci_complete
2026-06-03 21:39:49 +02:00
Felix Fontein
db367985cf
Disable aggregation step; use nicer display names (#1271)
* antsibull-nox takes are of aggregating coverage data.

* Use nicer names.
2026-06-02 08:16:43 +02:00
Felix Fontein
c5831a79f7
Use nox in AZP CI. (#1267) 2026-06-01 07:03:13 +02:00
Felix Fontein
4e4f65abdc
Auto-cancel older PR nox runs. (#1268) 2026-05-31 17:33:16 +02:00
Felix Fontein
42282e7d30
Remove no_log from setup_remote_tmp_dir. (#1263) 2026-05-30 15:27:43 +02:00
Felix Fontein
6485e0269a
Update Azure Pipelines test container. (#1261) 2026-05-30 15:27:32 +02:00
Felix Fontein
aa354397c5
AZP's Docker is no longer compatible with quite a few of the Docker versions needed for tests, so use GHA whenever possible (#1262)
* Move all non-remote tests to GHA.

* GitHub reverted this change.
2026-05-30 13:31:29 +02:00
Felix Fontein
f96a218a55 Use correct c.g branch. 2026-05-30 12:47:56 +02:00
Felix Fontein
ad4a2590fd The next expected release will be 5.3.0. 2026-05-26 21:49:36 +02:00
18 changed files with 295 additions and 329 deletions

View File

@ -37,293 +37,116 @@ variables:
- name: coverageBranches - name: coverageBranches
value: main value: main
- name: entryPoint - name: entryPoint
value: tests/utils/shippable/shippable.sh value: tests/utils/shippable/nox.sh
- name: prepareEntryPoint
value: tests/utils/shippable/nox-prepare.sh
- name: fetchDepth - name: fetchDepth
value: 0 value: 0
resources: resources:
containers: containers:
- container: default - container: default
image: quay.io/ansible/azure-pipelines-test-container:7.0.0 image: quay.io/ansible/azure-pipelines-test-container:8.0.0
pool: Standard pool: Standard
stages: stages:
- stage: remote_2_19
### Sanity & units
- stage: Ansible_devel
displayName: Sanity & Units devel
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
test: 'devel/sanity/1'
- name: Units
test: 'devel/units/1'
- stage: Ansible_2_21
displayName: Sanity & Units 2.21
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
test: '2.21/sanity/1'
- name: Units
test: '2.21/units/1'
- stage: Ansible_2_20
displayName: Sanity & Units 2.20
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
test: '2.20/sanity/1'
- name: Units
test: '2.20/units/1'
- stage: Ansible_2_19
displayName: Sanity & Units 2.19
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
test: '2.19/sanity/1'
- name: Units
test: '2.19/units/1'
- stage: Ansible_2_18
displayName: Sanity & Units 2.18
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: Sanity
test: '2.18/sanity/1'
- name: Units
test: '2.18/units/1'
### Docker
- stage: Docker_devel
displayName: Docker devel
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: devel/linux/{0}
targets:
- name: Fedora 44
test: fedora44
- name: Ubuntu 26.04
test: ubuntu2604
- name: Ubuntu 24.04
test: ubuntu2404
- name: Alpine 3.23
test: alpine323
groups:
- 4
- 5
- stage: Docker_2_21
displayName: Docker 2.21
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.21/linux/{0}
targets:
- name: Fedora 43
test: fedora43
- name: Ubuntu 22.04
test: ubuntu2204
- name: Ubuntu 24.04
test: ubuntu2404
# - name: Alpine 3.23
# test: alpine323
groups:
- 4
- 5
- stage: Docker_2_20
displayName: Docker 2.20
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.20/linux/{0}
targets:
- name: Fedora 42
test: fedora42
- name: Alpine 3.22
test: alpine322
groups:
- 4
- 5
- stage: Docker_2_19
displayName: Docker 2.19
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.19/linux/{0}
targets:
- name: Fedora 41
test: fedora41
- name: Alpine 3.21
test: alpine321
groups:
- 4
- 5
- stage: Docker_2_18
displayName: Docker 2.18
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.18/linux/{0}
targets:
- name: Fedora 40
test: fedora40
- name: Ubuntu 22.04
test: ubuntu2204
- name: Alpine 3.20
test: alpine320
groups:
- 4
- 5
### Community Docker
- stage: Docker_community_devel
displayName: Docker (community images) devel
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: devel/linux-community/{0}
targets:
- name: Debian 11 Bullseye
test: debian-bullseye/3.9
- name: Debian 12 Bookworm
test: debian-bookworm/3.11
- name: Debian 13 Trixie
test: debian-13-trixie/3.13
- name: ArchLinux
test: archlinux/3.14
groups:
- 4
- 5
### Remote
- stage: Remote_devel
displayName: Remote devel
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: devel/{0}
targets:
- name: RHEL 10.1 with Docker SDK, urllib3, requests from sources
test: rhel/10.1-dev-latest
- name: RHEL 9.7
test: rhel/9.7
# For some reason, Ubuntu 24.04 is *extremely* slower than RHEL 9.6
# - name: Ubuntu 24.04
# test: ubuntu/24.04
groups:
- 1
- 2
- 3
- 4
- 5
- stage: Remote_2_21
displayName: Remote 2.21
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.21/{0}
targets:
- name: RHEL 10.1
test: rhel/10.1
# - name: RHEL 9.7
# test: rhel/9.7
groups:
- 1
- 2
- 3
- 4
- 5
- stage: Remote_2_20
displayName: Remote 2.20
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.20/{0}
targets:
- name: RHEL 9.7
test: rhel/9.7
groups:
- 1
- 2
- 3
- 4
- 5
- stage: Remote_2_19
displayName: Remote 2.19 displayName: Remote 2.19
dependsOn: [] dependsOn: []
variables:
entryPoint: tests/utils/shippable/nox.sh
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.19/{0}
targets: targets:
- name: Ubuntu 22.04 - name: Ubuntu 22.04 + group 1
test: ubuntu/22.04 test: ansible-test-integration-2.19-ubuntu-22.04-azp-1
groups: - name: Ubuntu 22.04 + group 2
- 1 test: ansible-test-integration-2.19-ubuntu-22.04-azp-2
- 2 - name: Ubuntu 22.04 + group 3
- 3 test: ansible-test-integration-2.19-ubuntu-22.04-azp-3
- 4 - name: Ubuntu 22.04 + group 4
- 5 test: ansible-test-integration-2.19-ubuntu-22.04-azp-4
- stage: Remote_2_18 - name: Ubuntu 22.04 + group 5
displayName: Remote 2.18 test: ansible-test-integration-2.19-ubuntu-22.04-azp-5
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.18/{0}
targets:
- name: RHEL 9.7
test: rhel/9.7
groups:
- 1
- 2
- 3
- 4
- 5
## Finally - stage: remote_2_20
displayName: Remote 2.20
dependsOn: []
variables:
entryPoint: tests/utils/shippable/nox.sh
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: RHEL 9.7 + group 1
test: ansible-test-integration-2.20-rhel-9.7-azp-1
- name: RHEL 9.7 + group 2
test: ansible-test-integration-2.20-rhel-9.7-azp-2
- name: RHEL 9.7 + group 3
test: ansible-test-integration-2.20-rhel-9.7-azp-3
- name: RHEL 9.7 + group 4
test: ansible-test-integration-2.20-rhel-9.7-azp-4
- name: RHEL 9.7 + group 5
test: ansible-test-integration-2.20-rhel-9.7-azp-5
- stage: remote_2_21
displayName: Remote 2.21
dependsOn: []
variables:
entryPoint: tests/utils/shippable/nox.sh
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: RHEL 10.1 + group 1
test: ansible-test-integration-2.21-rhel-10.1-azp-1
- name: RHEL 10.1 + group 2
test: ansible-test-integration-2.21-rhel-10.1-azp-2
- name: RHEL 10.1 + group 3
test: ansible-test-integration-2.21-rhel-10.1-azp-3
- name: RHEL 10.1 + group 4
test: ansible-test-integration-2.21-rhel-10.1-azp-4
- name: RHEL 10.1 + group 5
test: ansible-test-integration-2.21-rhel-10.1-azp-5
- stage: remote_devel
displayName: Remote devel
dependsOn: []
variables:
entryPoint: tests/utils/shippable/nox.sh
jobs:
- template: templates/matrix.yml
parameters:
targets:
- name: RHEL 10.1 + group 1 + sdk-dev-latest
test: ansible-test-integration-devel-rhel-10.1-azp-1
- name: RHEL 10.1 + group 2 + sdk-dev-latest
test: ansible-test-integration-devel-rhel-10.1-azp-2
- name: RHEL 10.1 + group 3 + sdk-dev-latest
test: ansible-test-integration-devel-rhel-10.1-azp-3
- name: RHEL 10.1 + group 4 + sdk-dev-latest
test: ansible-test-integration-devel-rhel-10.1-azp-4
- name: RHEL 10.1 + group 5 + sdk-dev-latest
test: ansible-test-integration-devel-rhel-10.1-azp-5
- name: RHEL 9.7 + group 1
test: ansible-test-integration-devel-rhel-9.7-azp-1
- name: RHEL 9.7 + group 2
test: ansible-test-integration-devel-rhel-9.7-azp-2
- name: RHEL 9.7 + group 3
test: ansible-test-integration-devel-rhel-9.7-azp-3
- name: RHEL 9.7 + group 4
test: ansible-test-integration-devel-rhel-9.7-azp-4
- name: RHEL 9.7 + group 5
test: ansible-test-integration-devel-rhel-9.7-azp-5
- stage: Summary - stage: Summary
condition: succeededOrFailed() condition: succeededOrFailed()
dependsOn: dependsOn:
- Ansible_devel - remote_2_19
- Ansible_2_21 - remote_2_20
- Ansible_2_20 - remote_2_21
- Ansible_2_19 - remote_devel
- Ansible_2_18
- Remote_devel
- Remote_2_21
- Remote_2_20
- Remote_2_19
- Remote_2_18
- Docker_devel
- Docker_2_21
- Docker_2_20
- Docker_2_19
- Docker_2_18
- Docker_community_devel
jobs: jobs:
- template: templates/coverage.yml - template: templates/coverage.yml

View File

@ -10,11 +10,13 @@ set -o pipefail -eu
entry_point="$1" entry_point="$1"
test="$2" test="$2"
read -r -a coverage_branches <<< "$3" # space separated list of branches to run code coverage on for scheduled builds read -r -a coverage_branches <<< "$3" # space separated list of branches to run code coverage on for scheduled builds
agent_temp_directory="$4"
export COMMIT_MESSAGE export COMMIT_MESSAGE
export COMPLETE export COMPLETE
export COVERAGE export COVERAGE
export IS_PULL_REQUEST export IS_PULL_REQUEST
export COVERAGE_DESTINATION_DIRECTORY="${agent_temp_directory}/coverage"
if [ "${SYSTEM_PULLREQUEST_TARGETBRANCH:-}" ]; then if [ "${SYSTEM_PULLREQUEST_TARGETBRANCH:-}" ]; then
IS_PULL_REQUEST=true IS_PULL_REQUEST=true

View File

@ -23,14 +23,16 @@ jobs:
- checkout: self - checkout: self
fetchDepth: $(fetchDepth) fetchDepth: $(fetchDepth)
path: $(checkoutPath) path: $(checkoutPath)
- bash: .azure-pipelines/scripts/run-tests.sh "$(entryPoint)" "${{ job.test }}" "$(coverageBranches)" - bash: .azure-pipelines/scripts/run-tests.sh "$(prepareEntryPoint)" "${{ job.test }}" "$(coverageBranches)" "$(Agent.TempDirectory)"
displayName: Prepare Tests
- bash: .azure-pipelines/scripts/run-tests.sh "$(entryPoint)" "${{ job.test }}" "$(coverageBranches)" "$(Agent.TempDirectory)"
displayName: Run Tests displayName: Run Tests
- bash: .azure-pipelines/scripts/process-results.sh - bash: .azure-pipelines/scripts/process-results.sh
condition: succeededOrFailed() condition: succeededOrFailed()
displayName: Process Results displayName: Process Results
- bash: .azure-pipelines/scripts/aggregate-coverage.sh "$(Agent.TempDirectory)" # - bash: .azure-pipelines/scripts/aggregate-coverage.sh "$(Agent.TempDirectory)"
condition: eq(variables.haveCoverageData, 'true') # condition: eq(variables.haveCoverageData, 'true')
displayName: Aggregate Coverage Data # displayName: Aggregate Coverage Data
- task: PublishTestResults@2 - task: PublishTestResults@2
condition: eq(variables.haveTestResults, 'true') condition: eq(variables.haveTestResults, 'true')
inputs: inputs:

View File

@ -15,6 +15,11 @@ name: nox
- cron: '0 9 * * *' - cron: '0 9 * * *'
workflow_dispatch: workflow_dispatch:
concurrency:
# Make sure there is at most one active run per PR, but do not cancel any non-PR runs
group: ${{ github.workflow }}-${{ (github.head_ref && github.event.number) || github.run_id }}
cancel-in-progress: true
jobs: jobs:
nox: nox:
uses: ansible-community/antsibull-nox/.github/workflows/reusable-nox-run.yml@main uses: ansible-community/antsibull-nox/.github/workflows/reusable-nox-run.yml@main
@ -30,29 +35,6 @@ jobs:
upload-codecov-pr: false upload-codecov-pr: false
upload-codecov-push: false upload-codecov-push: false
upload-codecov-schedule: true upload-codecov-schedule: true
max-ansible-core: "2.17" allow-coverage-cd-override: true
# For some reason GitHub decided to bump Docker on the ubuntu-24.04 image,
# which is not compatible with podman and various other things.
pre-test-cmd-integration: |-
# See https://docs.docker.com/engine/install/ubuntu/.
# Add Docker's official GPG key:
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt-get install -y --allow-downgrades docker-ce-cli=5:28.0.4-1~ubuntu.24.04~noble docker-ce=5:28.0.4-1~ubuntu.24.04~noble
secrets: secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

View File

@ -9,6 +9,10 @@
"community.internal_test_tools" = "git+https://github.com/ansible-collections/community.internal_test_tools.git,main" "community.internal_test_tools" = "git+https://github.com/ansible-collections/community.internal_test_tools.git,main"
"community.library_inventory_filtering_v1" = "git+https://github.com/ansible-collections/community.library_inventory_filtering.git,stable-1" "community.library_inventory_filtering_v1" = "git+https://github.com/ansible-collections/community.library_inventory_filtering.git,stable-1"
[collection_sources_per_ansible.'2.17']
# community.general's main branch needs ansible-core >= 2.18
"community.general" = "git+https://github.com/ansible-collections/community.general.git,stable-12"
[vcs] [vcs]
vcs = "git" vcs = "git"
development_branch = "main" development_branch = "main"
@ -99,13 +103,28 @@ include_devel = true
[sessions.ansible_test_integration] [sessions.ansible_test_integration]
session_name_template = "ansible-test-integration-{ansible_core}{dash_docker_short}{dash_remote}{dash_python_version}{dash_target_dashized}" session_name_template = "ansible-test-integration-{ansible_core}{dash_docker_short}{dash_remote}{dash_python_version}{dash_target_dashized}"
display_name_template = "Ⓐ{ansible_core}{plus_docker_short}{plus_remote}{plus_py_python_version}{plus_target}{plus_force_docker_sdk_for_python_dev}{plus_force_docker_sdk_for_python_pypi}" display_name_template = "Ⓐ{ansible_core}{plus_docker_nice}{plus_remote_nice}{plus_py_python_version}{plus_target_nice}{plus_force_docker_sdk_for_python_dev}{plus_force_docker_sdk_for_python_pypi}"
description_template = "Run integration tests with ansible-core {ansible_core}{comma_docker_short}{comma_remote}{comma_py_python_version}{comma_target}{comma_force_docker_sdk_for_python_dev}{comma_force_docker_sdk_for_python_pypi}" description_template = "Run integration tests with ansible-core {ansible_core}{comma_docker_nice}{comma_remote_nice}{comma_py_python_version}{comma_target_nice}{comma_force_docker_sdk_for_python_dev}{comma_force_docker_sdk_for_python_pypi}"
retry_on_error = "in-ci"
[sessions.ansible_test_integration.ansible_vars] [sessions.ansible_test_integration.ansible_vars]
force_docker_sdk_for_python_dev = { type = "value", value = false, template_value = "" } force_docker_sdk_for_python_dev = { type = "value", value = false, template_value = "" }
force_docker_sdk_for_python_pypi = { type = "value", value = false, template_value = "" } force_docker_sdk_for_python_pypi = { type = "value", value = false, template_value = "" }
[sessions.ansible_test_integration.nice_target_names]
"azp/1/" = "group 1"
"azp/2/" = "group 2"
"azp/3/" = "group 3"
"azp/4/" = "group 4"
"azp/5/" = "group 5"
[sessions.ansible_test_integration.nice_docker_names]
"quay.io/ansible-community/test-image:debian-bullseye" = "Debian 11"
"quay.io/ansible-community/test-image:debian-bookworm" = "Debian 12"
"quay.io/ansible-community/test-image:debian-13-trixie" = "Debian 13"
"quay.io/ansible-community/test-image:archlinux" = "Arch Linux"
"quay.io/ansible-community/test-image:opensuse-tumbleweed" = "OpenSuSE Tumbleweed"
################################################################################################## ##################################################################################################
# Ansible-core 2.17: # Ansible-core 2.17:
@ -217,6 +236,12 @@ target = [ "azp/4/", "azp/5/" ]
python_version = "3.13" python_version = "3.13"
docker = "quay.io/ansible-community/test-image:debian-13-trixie" docker = "quay.io/ansible-community/test-image:debian-13-trixie"
[[sessions.ansible_test_integration.groups.sessions]]
ansible_core = "devel"
target = [ "azp/4/", "azp/5/" ]
python_version = "3.13"
docker = "quay.io/ansible-community/test-image:opensuse-tumbleweed"
[[sessions.ansible_test_integration.groups.sessions]] [[sessions.ansible_test_integration.groups.sessions]]
ansible_core = "devel" ansible_core = "devel"
target = [ "azp/4/", "azp/5/" ] target = [ "azp/4/", "azp/5/" ]
@ -243,14 +268,14 @@ remote = [
[sessions.ansible_lint] [sessions.ansible_lint]
[[sessions.ee_check.execution_environments]] [[sessions.ee_check.execution_environments]]
name = "devel-ubi-9" name = "devel-ubi-10"
description = "ansible-core devel @ RHEL UBI 9" description = "ansible-core devel @ RHEL UBI 10"
test_playbooks = ["tests/ee/all.yml"] test_playbooks = ["tests/ee/all.yml"]
config.images.base_image.name = "docker.io/redhat/ubi9:latest" config.images.base_image.name = "docker.io/redhat/ubi10:latest"
config.dependencies.ansible_core.package_pip = "https://github.com/ansible/ansible/archive/devel.tar.gz" config.dependencies.ansible_core.package_pip = "https://github.com/ansible/ansible/archive/devel.tar.gz"
config.dependencies.ansible_runner.package_pip = "ansible-runner" config.dependencies.ansible_runner.package_pip = "ansible-runner"
config.dependencies.python_interpreter.package_system = "python3.12 python3.12-pip python3.12-wheel python3.12-cryptography" config.dependencies.python_interpreter.package_system = "python3.14 python3.14-pip python3.14-cryptography"
config.dependencies.python_interpreter.python_path = "/usr/bin/python3.12" config.dependencies.python_interpreter.python_path = "/usr/bin/python3.14"
runtime_environment = {"ANSIBLE_PRIVATE_ROLE_VARS" = "true"} runtime_environment = {"ANSIBLE_PRIVATE_ROLE_VARS" = "true"}
runtime_container_options = [ runtime_container_options = [
# Mount Docker socket into the container so we can talk to Docker outside the container # Mount Docker socket into the container so we can talk to Docker outside the container

View File

@ -7,7 +7,7 @@
namespace: community namespace: community
name: docker name: docker
version: 5.2.1 version: 5.3.0
readme: README.md readme: README.md
authors: authors:
- Ansible Docker Working Group - Ansible Docker Working Group

View File

@ -12,6 +12,7 @@ import nox
try: try:
import antsibull_nox import antsibull_nox
from antsibull_nox.cli import run as run_antsibull_nox
except ImportError: except ImportError:
print("You need to install antsibull-nox in the same Python environment as nox.") print("You need to install antsibull-nox in the same Python environment as nox.")
sys.exit(1) sys.exit(1)
@ -20,6 +21,24 @@ except ImportError:
antsibull_nox.load_antsibull_nox_toml() antsibull_nox.load_antsibull_nox_toml()
@nox.session(name="update-azp-config", python=False)
def update_azp_config(session: nox.Session) -> None:
command = [
"antsibull-nox",
"update-azp-config",
"--exclude-tags",
"docker",
"--min-ansible-core",
"2.19",
]
if antsibull_nox.IN_CI:
command.append("--fail-on-change")
session.debug(" ".join(command))
result = run_antsibull_nox(command)
if result != 0:
session.error(f"Execution failed with status code {result}")
# Allow to run the noxfile with `python noxfile.py`, `pipx run noxfile.py`, or similar. # Allow to run the noxfile with `python noxfile.py`, `pipx run noxfile.py`, or similar.
# Requires nox >= 2025.02.09 # Requires nox >= 2025.02.09
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -7,4 +7,3 @@
ansible.builtin.file: ansible.builtin.file:
path: "{{ remote_tmp_dir }}" path: "{{ remote_tmp_dir }}"
state: absent state: absent
no_log: true

View File

@ -20,7 +20,7 @@ from ansible_collections.community.docker.plugins.inventory.docker_containers im
) )
if t.TYPE_CHECKING: if t.TYPE_CHECKING:
from collections.abc import Callable from collections.abc import Callable # pragma: no cover
@pytest.fixture(scope="module", name="templar") @pytest.fixture(scope="module", name="templar")

View File

@ -43,7 +43,7 @@ from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.c
from .. import fake_api from .. import fake_api
if t.TYPE_CHECKING: if t.TYPE_CHECKING:
from ansible_collections.community.docker.plugins.module_utils._api.auth import ( from ansible_collections.community.docker.plugins.module_utils._api.auth import ( # pragma: no cover
AuthConfig, AuthConfig,
) )

View File

@ -18,7 +18,7 @@ from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.c
from . import fake_stat from . import fake_stat
if t.TYPE_CHECKING: if t.TYPE_CHECKING:
from collections.abc import Callable from collections.abc import Callable # pragma: no cover
CURRENT_VERSION = f"v{DEFAULT_DOCKER_API_VERSION}" CURRENT_VERSION = f"v{DEFAULT_DOCKER_API_VERSION}"

View File

@ -13,9 +13,9 @@ from ansible_collections.community.docker.plugins.module_utils._copy import (
) )
if t.TYPE_CHECKING: if t.TYPE_CHECKING:
from collections.abc import Sequence from collections.abc import Sequence # pragma: no cover
T = t.TypeVar("T") T = t.TypeVar("T") # pragma: no cover
def _simple_generator(sequence: Sequence[T]) -> t.Generator[T]: def _simple_generator(sequence: Sequence[T]) -> t.Generator[T]:

View File

@ -61,12 +61,10 @@ def test_archived_image_manifest_extracts_nothing_when_file_not_present(
def test_archived_image_manifest_raises_when_file_not_a_tar() -> None: def test_archived_image_manifest_raises_when_file_not_a_tar() -> None:
try: with pytest.raises(ImageArchiveInvalidException, match=__file__) as exc_info:
archived_image_manifest(__file__) archived_image_manifest(__file__)
raise AssertionError() assert isinstance(exc_info.value.__cause__, tarfile.ReadError)
except ImageArchiveInvalidException as e: assert str(__file__) in str(exc_info.value)
assert isinstance(e.__cause__, tarfile.ReadError)
assert str(__file__) in str(e)
def test_archived_image_manifest_raises_when_tar_missing_manifest( def test_archived_image_manifest_raises_when_tar_missing_manifest(
@ -74,12 +72,10 @@ def test_archived_image_manifest_raises_when_tar_missing_manifest(
) -> None: ) -> None:
write_irrelevant_tar(tar_file_name) write_irrelevant_tar(tar_file_name)
try: with pytest.raises(ImageArchiveInvalidException) as exc_info:
archived_image_manifest(tar_file_name) archived_image_manifest(tar_file_name)
raise AssertionError() assert isinstance(exc_info.value.__cause__, KeyError)
except ImageArchiveInvalidException as e: assert "manifest.json" in str(exc_info.value.__cause__)
assert isinstance(e.__cause__, KeyError)
assert "manifest.json" in str(e.__cause__)
def test_archived_image_manifest_raises_when_manifest_missing_id( def test_archived_image_manifest_raises_when_manifest_missing_id(
@ -89,9 +85,7 @@ def test_archived_image_manifest_raises_when_manifest_missing_id(
write_imitation_archive_with_manifest(tar_file_name, manifest) write_imitation_archive_with_manifest(tar_file_name, manifest)
try: with pytest.raises(ImageArchiveInvalidException) as exc_info:
archived_image_manifest(tar_file_name) archived_image_manifest(tar_file_name)
raise AssertionError() assert isinstance(exc_info.value.__cause__, KeyError)
except ImageArchiveInvalidException as e: assert "Config" in str(exc_info.value.__cause__)
assert isinstance(e.__cause__, KeyError)
assert "Config" in str(e.__cause__)

View File

@ -17,12 +17,12 @@ from ansible_collections.community.docker.plugins.module_utils._util import (
if t.TYPE_CHECKING: if t.TYPE_CHECKING:
class DAMSpec(t.TypedDict): class DAMSpec(t.TypedDict): # pragma: no cover
av: dict[str, t.Any] av: dict[str, t.Any]
bv: dict[str, t.Any] bv: dict[str, t.Any]
result: bool result: bool
class Spec(t.TypedDict): class Spec(t.TypedDict): # pragma: no cover
a: t.Any a: t.Any
b: t.Any b: t.Any
method: t.Literal["strict", "ignore", "allow_more_present"] method: t.Literal["strict", "ignore", "allow_more_present"]

View File

@ -21,11 +21,13 @@ from ..test_support.docker_image_archive_stubbing import (
) )
if t.TYPE_CHECKING: if t.TYPE_CHECKING:
from collections.abc import Callable from collections.abc import Callable # pragma: no cover
def assert_no_logging(msg: str) -> t.NoReturn: def assert_no_logging(msg: str) -> t.NoReturn:
raise AssertionError(f"Should not have logged anything but logged {msg}") raise AssertionError(
f"Should not have logged anything but logged {msg}"
) # pragma: no cover
def capture_logging(messages: list[str]) -> Callable[[str], None]: def capture_logging(messages: list[str]) -> Callable[[str], None]:

View File

@ -12,7 +12,8 @@ from ansible_collections.community.docker.plugins.modules import (
docker_swarm_service, docker_swarm_service,
) )
APIError = pytest.importorskip("docker.errors.APIError") docker_errors = pytest.importorskip("docker.errors")
APIError = docker_errors.APIError
def test_retry_on_out_of_sequence_error(mocker: t.Any) -> None: def test_retry_on_out_of_sequence_error(mocker: t.Any) -> None:

View File

@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
set -o pipefail -eux
nox_session="$1"
docker images ansible/ansible
docker images quay.io/ansible/*
docker ps
for container in $(docker ps --format '{{.Image}} {{.ID}}' | grep -v -e '^drydock/' -e '^quay.io/ansible/azure-pipelines-test-container:' | sed 's/^.* //'); do
docker rm -f "${container}" || true # ignore errors
done
docker ps
command -v python
python -V
function retry
{
# shellcheck disable=SC2034
for repetition in 1 2 3; do
set +e
"$@"
result=$?
set -e
if [ ${result} == 0 ]; then
return ${result}
fi
echo "@* -> ${result}"
done
echo "Command '@*' failed 3 times!"
exit 255
}
command -v pip
pip --version
pip list --disable-pip-version-check
retry pip install https://github.com/ansible-community/antsibull-nox/archive/main.tar.gz --disable-pip-version-check
export PYTHONIOENCODING='utf-8'
export FORCE_COLOR=1
export ANTSIBULL_NOX_IGNORE_INSTALLED_COLLECTIONS="true"
if [ "${nox_session}" == "extra-sanity-tests" ]; then
nox --verbose --install-only
else
nox --verbose --install-only -e "${nox_session}"
fi

64
tests/utils/shippable/nox.sh Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/env bash
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
set -o pipefail -eux
nox_session="$1"
export PYTHONIOENCODING='utf-8'
if [ -n "${COVERAGE:-}" ]; then
# on-demand coverage reporting triggered by setting the COVERAGE environment variable to a non-empty value
export COVERAGE="--coverage"
elif [[ "${COMMIT_MESSAGE}" =~ ci_coverage ]]; then
# on-demand coverage reporting triggered by having 'ci_coverage' in the latest commit message
export COVERAGE="--coverage"
else
# on-demand coverage reporting disabled (default behavior, always-on coverage reporting remains enabled)
export COVERAGE="--coverage-check"
fi
if [ -n "${COMPLETE:-}" ]; then
# disable change detection triggered by setting the COMPLETE environment variable to a non-empty value
export ANTSIBULL_CHANGE_DETECTION=""
elif [[ "${COMMIT_MESSAGE}" =~ ci_complete ]]; then
# disable change detection triggered by having 'ci_complete' in the latest commit message
export ANTSIBULL_CHANGE_DETECTION=""
elif [ "${IS_PULL_REQUEST:-}" == "true" ]; then
# enable change detection for PRs (default behavior)
export ANTSIBULL_CHANGE_DETECTION="true"
export ANTSIBULL_BASE_BRANCH="${SYSTEM_PULLREQUEST_TARGETBRANCH}"
# Create a branch for the current HEAD, which happens to be a merge commit
git checkout -b "pull-request-branch"
# Name the target branch
git branch "${SYSTEM_PULLREQUEST_TARGETBRANCH}" --track "origin/${SYSTEM_PULLREQUEST_TARGETBRANCH}"
# Show branches
git branch -vv
else
# disable change detection for pushes and scheduled runs
export ANTSIBULL_CHANGE_DETECTION=""
fi
if [[ "${COVERAGE:-}" == "--coverage" ]]; then
export ANTSIBULL_NOX_TIMEOUT=60
else
export ANTSIBULL_NOX_TIMEOUT=50
fi
if [ "${IS_PULL_REQUEST:-}" == "true" ]; then
export ANTSIBULL_NOX_INTEGRATION_ALLOW_UNSTABLE_CHANGED="true"
fi
export FORCE_COLOR=1
export ANTSIBULL_NOX_IGNORE_INSTALLED_COLLECTIONS="true"
export ANTSIBULL_NOX_COVERAGE_DESTINATION="${COVERAGE_DESTINATION_DIRECTORY}"
export ANTSIBULL_NOX_COVERAGE_ANALYSIS_FILE="${COVERAGE_DESTINATION_DIRECTORY}/coverage-analyze-targets.json"
export ANTSIBULL_NOX_COVERAGE_NO_XML="true"
if [ "${nox_session}" == "extra-sanity-tests" ]; then
nox --reuse-existing-virtualenvs --no-install
else
nox --reuse-existing-virtualenvs --no-install -e "${nox_session}" -- ${COVERAGE}
fi