Skip to content

Commit 36cb2c2

Browse files
authored
[stable-9] Use antsibull-nox instead of extra sanity test runner and extra workfows (#10041)
* Use antsibull-nox instead of extra sanity test runner and extra workflows (#10022) * Use antsibull-nox instead of extra sanity test runner and extra workflows. * Avoid sys.argv[0]. (cherry picked from commit 3ee55c6) * Action group keycloak does not exist in 9.x.y.
1 parent 419893e commit 36cb2c2

25 files changed

+302
-514
lines changed

.azure-pipelines/azure-pipelines.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ stages:
7070
- test: 2
7171
- test: 3
7272
- test: 4
73-
- test: extra
7473
- stage: Sanity_2_18
7574
displayName: Sanity 2.18
7675
dependsOn: []

.github/workflows/import-galaxy.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/nox.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# Copyright (c) Ansible Project
3+
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4+
# SPDX-License-Identifier: GPL-3.0-or-later
5+
6+
name: nox
7+
'on':
8+
push:
9+
branches:
10+
- main
11+
- stable-*
12+
pull_request:
13+
# Run CI once per day (at 08:00 UTC)
14+
schedule:
15+
- cron: '0 8 * * *'
16+
workflow_dispatch:
17+
18+
jobs:
19+
nox:
20+
runs-on: ubuntu-latest
21+
name: "Run extra sanity tests"
22+
steps:
23+
- name: Check out collection
24+
uses: actions/checkout@v4
25+
with:
26+
persist-credentials: false
27+
- name: Run nox
28+
uses: ansible-community/antsibull-nox@main

.github/workflows/reuse.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
99
[![Documentation](https://img.shields.io/badge/docs-brightgreen.svg)](https://docs.ansible.com/ansible/latest/collections/community/general/)
1010
[![Build Status](https://dev.azure.com/ansible/community.general/_apis/build/status/CI?branchName=stable-9)](https://dev.azure.com/ansible/community.general/_build?definitionId=31)
1111
[![EOL CI](https://github.com/ansible-collections/community.general/actions/workflows/ansible-test.yml/badge.svg?branch=stable-9)](https://github.com/ansible-collections/community.general/actions)
12+
[![Nox CI](https://github.com/ansible-collections/community.general/actions/workflows/nox.yml/badge.svg?branch=stable-9)](https://github.com/ansible-collections/community.general/actions)
1213
[![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.general)](https://codecov.io/gh/ansible-collections/community.general)
1314
[![REUSE status](https://api.reuse.software/badge/github.com/ansible-collections/community.general)](https://api.reuse.software/info/github.com/ansible-collections/community.general)
1415

antsibull-nox.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
# SPDX-FileCopyrightText: 2025 Felix Fontein <[email protected]>
4+
5+
[collection_sources]
6+
"ansible.posix" = "git+https://github.com/ansible-collections/ansible.posix.git,main"
7+
"community.crypto" = "git+https://github.com/ansible-collections/community.crypto.git,main"
8+
"community.docker" = "git+https://github.com/ansible-collections/community.docker.git,main"
9+
"community.internal_test_tools" = "git+https://github.com/ansible-collections/community.internal_test_tools.git,main"
10+
11+
[sessions]
12+
13+
[sessions.docs_check]
14+
validate_collection_refs="all"
15+
16+
[sessions.license_check]
17+
18+
[sessions.extra_checks]
19+
run_no_unwanted_files = true
20+
no_unwanted_files_module_extensions = [".py"]
21+
no_unwanted_files_yaml_extensions = [".yml"]
22+
run_action_groups = true
23+
24+
[[sessions.extra_checks.action_groups_config]]
25+
name = "consul"
26+
pattern = "^consul_.*$"
27+
exclusions = [
28+
"consul_acl_bootstrap",
29+
"consul_kv",
30+
]
31+
doc_fragment = "community.general.consul.actiongroup_consul"
32+
33+
[[sessions.extra_checks.action_groups_config]]
34+
name = "proxmox"
35+
pattern = "^proxmox(_.*)?$"
36+
exclusions = []
37+
doc_fragment = "community.general.proxmox.actiongroup_proxmox"
38+
39+
[sessions.build_import_check]
40+
run_galaxy_importer = true

noxfile.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
# SPDX-FileCopyrightText: 2025 Felix Fontein <[email protected]>
4+
5+
# /// script
6+
# dependencies = ["nox>=2025.02.09", "antsibull-nox"]
7+
# ///
8+
9+
import sys
10+
11+
import nox
12+
13+
14+
try:
15+
import antsibull_nox
16+
except ImportError:
17+
print("You need to install antsibull-nox in the same Python environment as nox.")
18+
sys.exit(1)
19+
20+
21+
antsibull_nox.load_antsibull_nox_toml()
22+
23+
24+
@nox.session(name="aliases", python=False, default=True)
25+
def aliases(session: nox.Session) -> None:
26+
session.run("python", "tests/sanity/extra/aliases.py")
27+
28+
29+
@nox.session(name="botmeta", default=True)
30+
def botmeta(session: nox.Session) -> None:
31+
session.install("PyYAML", "voluptuous")
32+
session.run("python", "tests/sanity/extra/botmeta.py")
33+
34+
35+
# Allow to run the noxfile with `python noxfile.py`, `pipx run noxfile.py`, or similar.
36+
# Requires nox >= 2025.02.09
37+
if __name__ == "__main__":
38+
nox.main()

tests/sanity/extra/aliases.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/sanity/extra/aliases.json.license

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/sanity/extra/aliases.py

100755100644
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
from __future__ import (absolute_import, division, print_function)
77
__metaclass__ = type
88

9+
import glob
910
import sys
1011

1112
import yaml
1213

1314

1415
def main():
1516
"""Main entry point."""
16-
paths = sys.argv[1:] or sys.stdin.read().splitlines()
17-
paths = [path for path in paths if path.endswith('/aliases')]
18-
1917
with open('.azure-pipelines/azure-pipelines.yml', 'rb') as f:
2018
azp = yaml.safe_load(f)
2119

@@ -27,6 +25,9 @@ def main():
2725
for group in job['parameters']['groups']:
2826
allowed_targets.add('azp/posix/{0}'.format(group))
2927

28+
paths = glob.glob("tests/integration/targets/*/aliases")
29+
30+
has_errors = False
3031
for path in paths:
3132
targets = []
3233
skip = False
@@ -56,10 +57,14 @@ def main():
5657
if 'targets/setup_' in path:
5758
continue
5859
print('%s: %s' % (path, 'found no targets'))
60+
has_errors = True
5961
for target in targets:
6062
if target not in allowed_targets:
6163
print('%s: %s' % (path, 'found invalid target "{0}"'.format(target)))
64+
has_errors = True
65+
66+
return 1 if has_errors else 0
6267

6368

6469
if __name__ == '__main__':
65-
main()
70+
sys.exit(main())

0 commit comments

Comments
 (0)