From 4f921458180a9e1a9ab0b88a1f171c8827b1f64f Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 14 Aug 2024 14:53:01 +0100 Subject: [PATCH] Remove some testing leftovers from PR #250 (#252) Fixes: #250 --- .github/check-coverage.sh | 10 ++++++++++ .github/workflows/tox.yml | 22 ++++++++-------------- .pre-commit-config.yaml | 11 ++++++++--- tox.ini | 6 ++---- 4 files changed, 28 insertions(+), 21 deletions(-) create mode 100755 .github/check-coverage.sh diff --git a/.github/check-coverage.sh b/.github/check-coverage.sh new file mode 100755 index 00000000..aa7f20a4 --- /dev/null +++ b/.github/check-coverage.sh @@ -0,0 +1,10 @@ +#!/bin/bash -eu +JOBS_PRODUCING_COVERAGE=7 +declare -a FOUND_FILES +# IFS=$'\n' FOUND_FILES=( $(find . -name coverage.xml) ) +while IFS='' read -r line; do FOUND_FILES+=("$line"); done < <(find . -name coverage.xml) + +if [ "${#FOUND_FILES[@]}" -ne "${JOBS_PRODUCING_COVERAGE}" ]; then + echo "::error::Broken CI/CD setup, found ${#FOUND_FILES[@]} coverage.xml file(s) instead of expected ${JOBS_PRODUCING_COVERAGE}. Found: ${FOUND_FILES[*]}" + exit 1 +fi diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index a066b205..37f0fe24 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -19,6 +19,7 @@ concurrency: cancel-in-progress: true env: + ANSIBLE_FORCE_COLOR: 1 FORCE_COLOR: 1 # tox, pytest PY_COLORS: 1 @@ -39,13 +40,12 @@ jobs: other_names: | lint py39:tox -e py39-sanity;tox -e py39-unit;tox -e py39-integration;tox -e coverage - py312:tox -e py312-sanity;tox -e py312-unit;tox -e py312-integration;tox -e coverage - # py310:tox -e py310-sanity;tox -e py310-unit; tox -e py310-integration; tox -e coverage - # py311:tox -e py311-sanity;tox -e py311-unit; tox -e py311-integration; tox -e coverage - # py312:tox -e py312-sanity;tox -e py312-unit; tox -e py312-integration; tox -e coverage - # py39-macos:tox -e py39-sanity;tox -e py39-unit; tox -e py39-integration; tox -e coverage - # py312-macos:tox -e py312-sanity;tox -e py312-unit; tox -e py312-integration; tox -e coverage - # py311-linux-arm64:tox -e py312-sanity;tox -e py312-unit; tox -e py312-integration; tox -e coverage + py310:tox -e py310-sanity;tox -e py310-unit; tox -e py310-integration;tox -e coverage + py311:tox -e py311-sanity;tox -e py311-unit; tox -e py311-integration;tox -e coverage + py312:tox -e py312-sanity;tox -e py312-unit; tox -e py312-integration;tox -e coverage + py39-macos:tox -e py39-sanity;tox -e py39-unit;tox -e py39-integration;tox -e coverage + py312-macos:tox -e py312-sanity;tox -e py312-unit;tox -e py312-integration;tox -e coverage + py311-linux-arm64:tox -e py312-sanity;tox -e py312-unit;tox -e py312-integration;tox -e coverage # ^ arm64 runner is using py311 for matching python version used in AAP 2.5 platforms: linux,macos,linux-arm64:ubuntu-24.04-arm64-2core skip_explode: "1" @@ -183,13 +183,7 @@ jobs: path: . - name: Check for expected number of coverage reports - run: | - JOBS_PRODUCING_COVERAGE=2 - FIND_FILES="find */tests/output/reports -name 'coverage.xml'" - if [ "$($FIND_FILES | wc -l | bc)" -ne "${JOBS_PRODUCING_COVERAGE}" ]; then - echo "::error::Number of coverage.xml files was not the expected one (${JOBS_PRODUCING_COVERAGE}): $($FIND_FILES | xargs echo)" - exit 0 - fi + run: .github/check-coverage.sh - name: Upload coverage data uses: codecov/codecov-action@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 795d7c09..ace19b40 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,9 +7,10 @@ ci: for more information, see https://pre-commit.ci skip: - # These will not run on pre-commit.ci due to required network access: - - ansible-test-sanity - - tox + # These will not run on pre-commit.ci + - ansible-test-sanity # requires network access + - shellcheck # no docker + - tox # requires network access exclude: "^.*\\.md$" repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -18,6 +19,10 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer language_version: python3 + - repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.10.0 + hooks: + - id: shellcheck - repo: https://github.com/streetsidesoftware/cspell-cli rev: v8.13.1 hooks: diff --git a/tox.ini b/tox.ini index 7b2c9480..64bf0f15 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,7 @@ setenv = PIP_NO_BUILD_ISOLATION = 1 PYTHONUNBUFFERED = 1 passenv = + ANSIBLE_FORCE_COLOR CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437 FORCE_COLOR HOME @@ -75,10 +76,7 @@ commands = # risky: not safe for development it affects user setup ansible-galaxy collection install . # use same coverage location as ansible-test: - coverage run --data-file=tests/output/coverage/integration.coverage -m pytest tests/integration -vvv -s {posargs} -k test_url_check_source_sanity - ; sh -c "coverage combine -a -q --data-file=tests/output/coverage/integration.combined tests/output/coverage/integration*.coverage" - ; sh -c "coverage report --data-file=tests/output/coverage/integration.combined --show-missing --skip-empty --include=extensions/*,plugins/*,tests/\*" - ; bash -c "coverage xml --data-file=tests/output/coverage/integration.coverage -o {envdir}/coverage.xml --fail-under=0" + coverage run --data-file=tests/output/coverage/integration.coverage -m pytest tests/integration -vvv -s {posargs} [testenv:unit,py{39,310,311,312,313}-unit] description =