From a1d2ed3dda3389de779b8250e22a6a1609e7421e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 19 Apr 2025 21:16:51 +0200 Subject: [PATCH] Replace extra sanity test runner with antsibull-nox. --- .azure-pipelines/azure-pipelines.yml | 2 -- .github/workflows/nox.yml | 28 +++++++++++++++ antsibull-nox.toml | 11 ++++++ noxfile.py | 27 ++++++++++++++ tests/sanity/extra/no-unwanted-files.json | 7 ---- tests/sanity/extra/no-unwanted-files.py | 44 ----------------------- tests/utils/shippable/sanity.sh | 13 ------- 7 files changed, 66 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/nox.yml create mode 100644 antsibull-nox.toml create mode 100644 noxfile.py delete mode 100644 tests/sanity/extra/no-unwanted-files.json delete mode 100755 tests/sanity/extra/no-unwanted-files.py diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 4b9f2f49..32a5e64a 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -70,8 +70,6 @@ stages: targets: - name: Sanity test: 'devel/sanity/1' - - name: Sanity Extra # Only on devel - test: 'devel/sanity/extra' - name: Units test: 'devel/units/1' diff --git a/.github/workflows/nox.yml b/.github/workflows/nox.yml new file mode 100644 index 00000000..bed8dff9 --- /dev/null +++ b/.github/workflows/nox.yml @@ -0,0 +1,28 @@ +--- +# 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 + +name: nox +'on': + push: + branches: + - main + - stable-* + pull_request: + # Run CI once per day (at 08:00 UTC) + schedule: + - cron: '0 8 * * *' + workflow_dispatch: + +jobs: + nox: + runs-on: ubuntu-latest + name: "Run extra sanity tests" + steps: + - name: Check out collection + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Run nox + uses: ansible-community/antsibull-nox@main diff --git a/antsibull-nox.toml b/antsibull-nox.toml new file mode 100644 index 00000000..894eca1e --- /dev/null +++ b/antsibull-nox.toml @@ -0,0 +1,11 @@ +# 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 +# SPDX-FileCopyrightText: Ansible Project + +[sessions] + +[sessions.extra_checks] +run_no_unwanted_files = true +no_unwanted_files_module_extensions = [".py"] +no_unwanted_files_yaml_extensions = [".yml"] +run_action_groups = false diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 00000000..bc49dc7c --- /dev/null +++ b/noxfile.py @@ -0,0 +1,27 @@ +# 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 +# SPDX-FileCopyrightText: Ansible Project + +# /// script +# dependencies = ["nox>=2025.02.09", "antsibull-nox"] +# /// + +import sys + +import nox + + +try: + import antsibull_nox +except ImportError: + print("You need to install antsibull-nox in the same Python environment as nox.") + sys.exit(1) + + +antsibull_nox.load_antsibull_nox_toml() + + +# Allow to run the noxfile with `python noxfile.py`, `pipx run noxfile.py`, or similar. +# Requires nox >= 2025.02.09 +if __name__ == "__main__": + nox.main() diff --git a/tests/sanity/extra/no-unwanted-files.json b/tests/sanity/extra/no-unwanted-files.json deleted file mode 100644 index c789a7fd..00000000 --- a/tests/sanity/extra/no-unwanted-files.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "include_symlinks": true, - "prefixes": [ - "plugins/" - ], - "output": "path-message" -} diff --git a/tests/sanity/extra/no-unwanted-files.py b/tests/sanity/extra/no-unwanted-files.py deleted file mode 100755 index 85d693c6..00000000 --- a/tests/sanity/extra/no-unwanted-files.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -"""Prevent unwanted files from being added to the source tree.""" -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -import os -import sys - - -def main(): - """Main entry point.""" - paths = sys.argv[1:] or sys.stdin.read().splitlines() - - allowed_extensions = ( - '.cs', - '.ps1', - '.psm1', - '.py', - ) - - skip_paths = set([ - ]) - - skip_directories = ( - ) - - for path in paths: - if path in skip_paths: - continue - - if any(path.startswith(skip_directory) for skip_directory in skip_directories): - continue - - ext = os.path.splitext(path)[1] - - if ext not in allowed_extensions: - print('%s: extension must be one of: %s' % (path, ', '.join(allowed_extensions))) - - -if __name__ == '__main__': - main() diff --git a/tests/utils/shippable/sanity.sh b/tests/utils/shippable/sanity.sh index c216220e..dd1e68b9 100755 --- a/tests/utils/shippable/sanity.sh +++ b/tests/utils/shippable/sanity.sh @@ -2,25 +2,12 @@ set -o pipefail -eux -declare -a args -IFS='/:' read -ra args <<< "$1" - -group="${args[1]}" - if [ "${BASE_BRANCH:-}" ]; then base_branch="origin/${BASE_BRANCH}" else base_branch="" fi -if [ "${group}" == "extra" ]; then - # ansible-galaxy -vvv collection install community.internal_test_tools - git clone --single-branch --depth 1 https://github.com/ansible-collections/community.internal_test_tools.git ../internal_test_tools - - ../internal_test_tools/tools/run.py --color - exit -fi - # shellcheck disable=SC2086 ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \ --docker --base-branch "${base_branch}" \