From 4d4941aaa285943c5c01e7660ce39008b4ac3da6 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Tue, 9 Jul 2024 12:30:49 +0200 Subject: [PATCH] ci: update gitlab ci config (#529) - Remove outdated jobs - Only run on feature branches - Remove old gitlab ci scripts --- .gitlab-ci.yml | 37 +----------- tests/utils/gitlab/gitlab.sh | 95 ------------------------------- tests/utils/gitlab/integration.sh | 20 ------- tests/utils/gitlab/sanity.sh | 49 ---------------- 4 files changed, 1 insertion(+), 200 deletions(-) delete mode 100755 tests/utils/gitlab/gitlab.sh delete mode 100755 tests/utils/gitlab/integration.sh delete mode 100755 tests/utils/gitlab/sanity.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e6aaa5..c4a39ec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,42 +3,7 @@ include: file: - default.yml - pre-commit.yml - -stages: - - test - - sanity - - integration - -variables: - PYTHON_VERSION: "3.10" - -default: - image: python:$PYTHON_VERSION + - workflows/feature-branches.yml pre-commit: extends: [.pre-commit] - -sanity: - stage: sanity - allow_failure: true - except: - - tags - parallel: - matrix: - - ANSIBLE_VERSION: ["devel", "2.15"] - GROUP: [1] - script: - - bash tests/utils/gitlab/gitlab.sh ${ANSIBLE_VERSION}/sanity/${GROUP} - -integration: - stage: integration - except: - - tags - parallel: - matrix: - - ANSIBLE_VERSION: ["devel"] - GROUP: [1, 2, 3] - script: - - echo "$HCLOUD_TOKEN" >> "$(pwd)/hcloud_token.txt" - - echo "$CI_JOB_ID" >> "$(pwd)/prefix.txt" - - bash tests/utils/gitlab/gitlab.sh ${ANSIBLE_VERSION}/hcloud/${PYTHON_VERSION}/${GROUP} diff --git a/tests/utils/gitlab/gitlab.sh b/tests/utils/gitlab/gitlab.sh deleted file mode 100755 index a96ad2f..0000000 --- a/tests/utils/gitlab/gitlab.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args - -IFS='/:' read -ra args <<< "$1" - -ansible_version="${args[0]}" -# shellcheck disable=SC2034 -script="${args[1]}" - -function join { - local IFS="$1" - shift - echo "$*" -} - -test="$(join / "${args[@]:1}")" -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 1 -} - -command -v pip -pip --version -pip list --disable-pip-version-check -if [ "${ansible_version}" == "devel" ]; then - retry pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check -else - retry pip install "https://github.com/ansible/ansible/archive/stable-${ansible_version}.tar.gz" --disable-pip-version-check -fi -export ANSIBLE_COLLECTIONS_PATH="${HOME}/.ansible" -# shellcheck disable=SC2034 -SHIPPABLE_RESULT_DIR="$(pwd)/shippable" -TEST_DIR="${ANSIBLE_COLLECTIONS_PATH}/ansible_collections/hetzner/hcloud" -rm -rf "${TEST_DIR}" -mkdir -p "${TEST_DIR}" -cp -r "." "${TEST_DIR}" -cd "${TEST_DIR}" - -# STAR: HACK install dependencies -retry pip install -r tests/integration/requirements.txt -c tests/integration/constraints.txt -retry ansible-galaxy -vvv collection install -r tests/requirements.yml - -retry pip install rstcheck -retry ansible-galaxy -vvv collection install community.internal_test_tools -# END: HACK - -export PYTHONIOENCODING='utf-8' - -if [ "${JOB_TRIGGERED_BY_NAME:-}" == "nightly-trigger" ]; then - COMPLETE=yes -fi - -if [ -n "${COMPLETE:-}" ]; then - # disable change detection triggered by setting the COMPLETE environment variable to a non-empty value - export CHANGED="" -elif [[ "${CI_COMMIT_MESSAGE}" =~ ci_complete ]]; then - # disable change detection triggered by having 'ci_complete' in the latest commit message - export CHANGED="" -else - # enable change detection (default behavior) - export CHANGED="" -fi - -export UNSTABLE="--allow-unstable-changed" - -# remove empty core/extras module directories from PRs created prior to the repo-merge -find plugins -type d -empty -print -delete - -ansible-test env --dump --show --timeout "50" --color -v - -group="${args[1]}" -echo "$test" -if [[ "${test}" =~ hcloud ]]; then - group="${args[3]}" - bash tests/utils/gitlab/integration.sh "shippable/hcloud/group${group}/" -else - bash tests/utils/gitlab/sanity.sh "sanity/${group}" -fi diff --git a/tests/utils/gitlab/integration.sh b/tests/utils/gitlab/integration.sh deleted file mode 100755 index c94392b..0000000 --- a/tests/utils/gitlab/integration.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -target="$1" - -HCLOUD_TOKEN=$(cat hcloud_token.txt) -# shellcheck disable=SC2034,SC2154 -changed_all_target="shippable/${cloud}/smoketest/" - -# shellcheck disable=SC2046 -echo "[default] -hcloud_api_token=${HCLOUD_TOKEN} -" >> $(pwd)/tests/integration/cloud-config-hcloud.ini -export SHIPPABLE="true" - -# shellcheck disable=SC2155 -export SHIPPABLE_BUILD_NUMBER="gl-$(cat prefix.txt)" - -# shellcheck disable=SC2155,SC2002 -export SHIPPABLE_JOB_NUMBER="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1)" -ansible-test integration --color --local -vv "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} diff --git a/tests/utils/gitlab/sanity.sh b/tests/utils/gitlab/sanity.sh deleted file mode 100755 index 9f6711b..0000000 --- a/tests/utils/gitlab/sanity.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -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 - ../internal_test_tools/tools/run.py --color - exit -fi - -case "${group}" in - 1) options=(--skip-test pylint --skip-test ansible-doc --skip-test validate-modules) ;; - 2) options=(--test ansible-doc --test validate-modules) ;; - 3) options=(--test pylint plugins/modules/) ;; - 4) options=(--test pylint --exclude plugins/modules/) ;; -esac - -# allow collection migration sanity tests for groups 3 and 4 to pass without updating this script during migration -network_path="lib/ansible/modules/network/" - -if [ -d "${network_path}" ]; then - if [ "${group}" -eq 3 ]; then - options+=(--exclude "${network_path}") - elif [ "${group}" -eq 4 ]; then - options+=("${network_path}") - fi -fi - -pip install pycodestyle -pip install yamllint -pip install voluptuous -pip install pylint==2.5.3 -# shellcheck disable=SC2086 -ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \ - --base-branch "${base_branch}" \ - --exclude plugins/module_utils/vendor/ \ - --exclude scripts/ \ - --exclude tests/utils/ \ - "${options[@]}" --allow-disabled