summaryrefslogtreecommitdiffstats
path: root/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
commit38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch)
tree356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/hetzner/hcloud/.azure-pipelines/scripts
parentAdding upstream version 7.7.0+dfsg. (diff)
downloadansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz
ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/hetzner/hcloud/.azure-pipelines/scripts')
-rwxr-xr-xansible_collections/hetzner/hcloud/.azure-pipelines/scripts/aggregate-coverage.sh8
-rwxr-xr-xansible_collections/hetzner/hcloud/.azure-pipelines/scripts/combine-coverage.py27
-rwxr-xr-xansible_collections/hetzner/hcloud/.azure-pipelines/scripts/publish-codecov.sh26
-rwxr-xr-xansible_collections/hetzner/hcloud/.azure-pipelines/scripts/report-coverage.sh10
-rwxr-xr-xansible_collections/hetzner/hcloud/.azure-pipelines/scripts/run-tests.sh24
-rwxr-xr-xansible_collections/hetzner/hcloud/.azure-pipelines/scripts/time-command.py11
6 files changed, 52 insertions, 54 deletions
diff --git a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/aggregate-coverage.sh b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/aggregate-coverage.sh
index f3113dd0a..c196ab014 100755
--- a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/aggregate-coverage.sh
+++ b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/aggregate-coverage.sh
@@ -13,8 +13,8 @@ options=(--venv --venv-system-site-packages --color -v)
ansible-test coverage combine --export "${agent_temp_directory}/coverage/" "${options[@]}"
-if ansible-test coverage analyze targets generate --help >/dev/null 2>&1; then
- # Only analyze coverage if the installed version of ansible-test supports it.
- # Doing so allows this script to work unmodified for multiple Ansible versions.
- ansible-test coverage analyze targets generate "${agent_temp_directory}/coverage/coverage-analyze-targets.json" "${options[@]}"
+if ansible-test coverage analyze targets generate --help > /dev/null 2>&1; then
+ # Only analyze coverage if the installed version of ansible-test supports it.
+ # Doing so allows this script to work unmodified for multiple Ansible versions.
+ ansible-test coverage analyze targets generate "${agent_temp_directory}/coverage/coverage-analyze-targets.json" "${options[@]}"
fi
diff --git a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/combine-coverage.py b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/combine-coverage.py
index 506ade646..bab3c4226 100755
--- a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/combine-coverage.py
+++ b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/combine-coverage.py
@@ -7,8 +7,7 @@ Keep in mind that Azure Pipelines does not enforce unique job display names (onl
It is up to pipeline authors to avoid name collisions when deviating from the recommended format.
"""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import re
@@ -20,12 +19,12 @@ def main():
"""Main program entry point."""
source_directory = sys.argv[1]
- if '/ansible_collections/' in os.getcwd():
+ if "/ansible_collections/" in os.getcwd():
output_path = "tests/output"
else:
output_path = "test/results"
- destination_directory = os.path.join(output_path, 'coverage')
+ destination_directory = os.path.join(output_path, "coverage")
if not os.path.exists(destination_directory):
os.makedirs(destination_directory)
@@ -34,27 +33,27 @@ def main():
count = 0
for name in os.listdir(source_directory):
- match = re.search('^Coverage (?P<attempt>[0-9]+) (?P<label>.+)$', name)
- label = match.group('label')
- attempt = int(match.group('attempt'))
+ match = re.search("^Coverage (?P<attempt>[0-9]+) (?P<label>.+)$", name)
+ label = match.group("label")
+ attempt = int(match.group("attempt"))
jobs[label] = max(attempt, jobs.get(label, 0))
for label, attempt in jobs.items():
- name = 'Coverage {attempt} {label}'.format(label=label, attempt=attempt)
+ name = f"Coverage {attempt} {label}"
source = os.path.join(source_directory, name)
source_files = os.listdir(source)
for source_file in source_files:
source_path = os.path.join(source, source_file)
- destination_path = os.path.join(destination_directory, source_file + '.' + label)
- print('"%s" -> "%s"' % (source_path, destination_path))
+ destination_path = os.path.join(destination_directory, source_file + "." + label)
+ print(f'"{source_path}" -> "{destination_path}"')
shutil.copyfile(source_path, destination_path)
count += 1
- print('Coverage file count: %d' % count)
- print('##vso[task.setVariable variable=coverageFileCount]%d' % count)
- print('##vso[task.setVariable variable=outputPath]%s' % output_path)
+ print("Coverage file count: %d" % count)
+ print("##vso[task.setVariable variable=coverageFileCount]%d" % count)
+ print("##vso[task.setVariable variable=outputPath]%s" % output_path)
-if __name__ == '__main__':
+if __name__ == "__main__":
main()
diff --git a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/publish-codecov.sh b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/publish-codecov.sh
index 6d184f0b8..5dd7cfde7 100755
--- a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/publish-codecov.sh
+++ b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/publish-codecov.sh
@@ -10,18 +10,18 @@ output_path="$1"
curl --silent --show-error https://ansible-ci-files.s3.us-east-1.amazonaws.com/codecov/codecov.sh > codecov.sh
for file in "${output_path}"/reports/coverage*.xml; do
- name="${file}"
- name="${name##*/}" # remove path
- name="${name##coverage=}" # remove 'coverage=' prefix if present
- name="${name%.xml}" # remove '.xml' suffix
+ name="${file}"
+ name="${name##*/}" # remove path
+ name="${name##coverage=}" # remove 'coverage=' prefix if present
+ name="${name%.xml}" # remove '.xml' suffix
- bash codecov.sh \
- -f "${file}" \
- -n "${name}" \
- -X coveragepy \
- -X gcov \
- -X fix \
- -X search \
- -X xcode \
- || echo "Failed to upload code coverage report to codecov.io: ${file}"
+ bash codecov.sh \
+ -f "${file}" \
+ -n "${name}" \
+ -X coveragepy \
+ -X gcov \
+ -X fix \
+ -X search \
+ -X xcode ||
+ echo "Failed to upload code coverage report to codecov.io: ${file}"
done
diff --git a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/report-coverage.sh b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/report-coverage.sh
index 1bd91bdc9..a397f63e7 100755
--- a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/report-coverage.sh
+++ b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/report-coverage.sh
@@ -5,11 +5,11 @@ set -o pipefail -eu
PATH="${PWD}/bin:${PATH}"
-if ! ansible-test --help >/dev/null 2>&1; then
- # Install the devel version of ansible-test for generating code coverage reports.
- # This is only used by Ansible Collections, which are typically tested against multiple Ansible versions (in separate jobs).
- # Since a version of ansible-test is required that can work the output from multiple older releases, the devel version is used.
- pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
+if ! ansible-test --help > /dev/null 2>&1; then
+ # Install the devel version of ansible-test for generating code coverage reports.
+ # This is only used by Ansible Collections, which are typically tested against multiple Ansible versions (in separate jobs).
+ # Since a version of ansible-test is required that can work the output from multiple older releases, the devel version is used.
+ pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
fi
ansible-test coverage xml --stub --venv --venv-system-site-packages --color -v
diff --git a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/run-tests.sh b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/run-tests.sh
index a947fdf01..25a576cba 100755
--- a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/run-tests.sh
+++ b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/run-tests.sh
@@ -4,7 +4,7 @@
set -o pipefail -eu
entry_point="$1"
-test="$2"
+entry_point_args="$2"
read -r -a coverage_branches <<< "$3" # space separated list of branches to run code coverage on for scheduled builds
export COMMIT_MESSAGE
@@ -13,22 +13,22 @@ export COVERAGE
export IS_PULL_REQUEST
if [ "${SYSTEM_PULLREQUEST_TARGETBRANCH:-}" ]; then
- IS_PULL_REQUEST=true
- COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD^2)
+ IS_PULL_REQUEST=true
+ COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD^2)
else
- IS_PULL_REQUEST=
- COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD)
+ IS_PULL_REQUEST=false
+ COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD)
fi
-COMPLETE=
-COVERAGE=
+COMPLETE=false
+COVERAGE=false
if [ "${BUILD_REASON}" = "Schedule" ]; then
- COMPLETE=yes
+ COMPLETE=true
- if printf '%s\n' "${coverage_branches[@]}" | grep -q "^${BUILD_SOURCEBRANCHNAME}$"; then
- COVERAGE=yes
- fi
+ if printf '%s\n' "${coverage_branches[@]}" | grep -q "^${BUILD_SOURCEBRANCHNAME}$"; then
+ COVERAGE=true
+ fi
fi
-"${entry_point}" "${test}" 2>&1 | "$(dirname "$0")/time-command.py"
+"${entry_point}" "${entry_point_args}" 2>&1 | "$(dirname "$0")/time-command.py"
diff --git a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/time-command.py b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/time-command.py
index 5e8eb8d4c..783e745d8 100755
--- a/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/time-command.py
+++ b/ansible_collections/hetzner/hcloud/.azure-pipelines/scripts/time-command.py
@@ -1,8 +1,7 @@
#!/usr/bin/env python
"""Prepends a relative timestamp to each input line from stdin and writes it to stdout."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
import time
@@ -12,14 +11,14 @@ def main():
"""Main program entry point."""
start = time.time()
- sys.stdin.reconfigure(errors='surrogateescape')
- sys.stdout.reconfigure(errors='surrogateescape')
+ sys.stdin.reconfigure(errors="surrogateescape")
+ sys.stdout.reconfigure(errors="surrogateescape")
for line in sys.stdin:
seconds = time.time() - start
- sys.stdout.write('%02d:%02d %s' % (seconds // 60, seconds % 60, line))
+ sys.stdout.write("%02d:%02d %s" % (seconds // 60, seconds % 60, line))
sys.stdout.flush()
-if __name__ == '__main__':
+if __name__ == "__main__":
main()