From ee4ef2317d5d8dedf08edf012ff4dcd1dbab6e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Thu, 25 Jun 2020 07:27:39 +0200 Subject: [PATCH] Extend sanity tests to multiple ansible versions --- .gitlab-ci.yml | 104 +++++++++++++++++++++++++---- galaxy.yml | 3 +- shippable.yml | 27 ++++++-- tests/sanity/ignore-2.10.txt | 5 -- tests/sanity/ignore-2.9.txt | 5 -- tests/utils/gitlab/gitlab.sh | 18 ++++- tests/utils/shippable/shippable.sh | 18 +++-- 7 files changed, 143 insertions(+), 37 deletions(-) delete mode 100644 tests/sanity/ignore-2.10.txt delete mode 100644 tests/sanity/ignore-2.9.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7c39fc7..740ab73 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,47 +2,127 @@ stages: - sanity - integration -test:sanity1-devel-py38: +test-sanity-devel-1/4: stage: sanity image: python:3.8-buster except: - tags script: - - bash tests/utils/gitlab/gitlab.sh sanity/1 + - bash tests/utils/gitlab/gitlab.sh devel/sanity/1 tags: - hc-bladerunner -test:sanity2-devel-py38: +test-sanity-devel-2/4: stage: sanity image: python:3.8-buster except: - tags script: - - bash tests/utils/gitlab/gitlab.sh sanity/2 + - bash tests/utils/gitlab/gitlab.sh devel/sanity/2 tags: - hc-bladerunner -test:sanity3-devel-py38: +test-sanity-devel-3/4: stage: sanity image: python:3.8-buster except: - tags script: - - bash tests/utils/gitlab/gitlab.sh sanity/3 + - bash tests/utils/gitlab/gitlab.sh devel/sanity/3 tags: - hc-bladerunner -test:sanity4-devel-py38: +test-sanity-devel-4/4: stage: sanity image: python:3.8-buster except: - tags script: - - bash tests/utils/gitlab/gitlab.sh sanity/4 + - bash tests/utils/gitlab/gitlab.sh devel/sanity/4 tags: - hc-bladerunner -test:integration1-devel-py38: +test-sanity-210-1/4: + stage: sanity + image: python:3.8-buster + except: + - tags + script: + - bash tests/utils/gitlab/gitlab.sh 2.10/sanity/1 + tags: + - hc-bladerunner + +test-sanity-210-2/4: + stage: sanity + image: python:3.8-buster + except: + - tags + script: + - bash tests/utils/gitlab/gitlab.sh 2.10/sanity/2 + tags: + - hc-bladerunner + +test-sanity-210-3/4: + stage: sanity + image: python:3.8-buster + except: + - tags + script: + - bash tests/utils/gitlab/gitlab.sh 2.10/sanity/3 + tags: + - hc-bladerunner + +test-sanity-210-4/4: + stage: sanity + image: python:3.8-buster + except: + - tags + script: + - bash tests/utils/gitlab/gitlab.sh 2.10/sanity/4 + tags: + - hc-bladerunner + +test-sanity-29-1/4: + stage: sanity + image: python:3.8-buster + except: + - tags + script: + - bash tests/utils/gitlab/gitlab.sh 2.9/sanity/1 + tags: + - hc-bladerunner + +test-sanity-29-2/4: + stage: sanity + image: python:3.8-buster + except: + - tags + script: + - bash tests/utils/gitlab/gitlab.sh 2.9/sanity/2 + tags: + - hc-bladerunner + +test-sanity-29-3/4: + stage: sanity + image: python:3.8-buster + except: + - tags + script: + - bash tests/utils/gitlab/gitlab.sh 2.9/sanity/3 + tags: + - hc-bladerunner + +test-sanity-29-4/4: + stage: sanity + image: python:3.8-buster + except: + - tags + script: + - bash tests/utils/gitlab/gitlab.sh 2.9/sanity/4 + tags: + - hc-bladerunner + +test-integration-devel-1/2: stage: integration image: python:3.8-buster except: @@ -50,12 +130,12 @@ test:integration1-devel-py38: script: - echo "$HCLOUD_TOKEN" >> "$(pwd)/hcloud_token.txt" - echo "py38-$CI_JOB_ID" >> "$(pwd)/prefix.txt" - - bash tests/utils/gitlab/gitlab.sh integration/1 + - bash tests/utils/gitlab/gitlab.sh devel/hcloud/3.8/1 tags: - hc-bladerunner -test:integration2-devel-py38: +test-integration-devel-2/2: stage: integration image: python:3.8-buster except: @@ -63,6 +143,6 @@ test:integration2-devel-py38: script: - echo "$HCLOUD_TOKEN" >> "$(pwd)/hcloud_token.txt" - echo "py39-$CI_JOB_ID" >> "$(pwd)/prefix.txt" - - bash tests/utils/gitlab/gitlab.sh integration/2 + - bash tests/utils/gitlab/gitlab.sh devel/hcloud/3.8/2 tags: - hc-bladerunner diff --git a/galaxy.yml b/galaxy.yml index 603332d..36dcf81 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -4,9 +4,8 @@ version: 0.1.0 readme: README.md authors: - Lukas Kaemmerling (github.com/LKaemmerling) -description: null +description: A Collection for managing Hetzner Cloud resources license: GPL-3.0-or-later -license_file: COPYING tags: null dependencies: ansible.netcommon: '>=0.0.1' diff --git a/shippable.yml b/shippable.yml index 9e8572e..6b2acc9 100644 --- a/shippable.yml +++ b/shippable.yml @@ -8,13 +8,28 @@ matrix: exclude: - env: T=none include: - - env: T=sanity/1 - - env: T=sanity/2 - - env: T=sanity/3 - - env: T=sanity/4 + - env: T=devel/sanity/1 + - env: T=devel/sanity/2 + - env: T=devel/sanity/3 + - env: T=devel/sanity/4 - - env: T=hcloud/3.8/1 - - env: T=hcloud/3.8/2 + - env: T=devel/hcloud/3.8/1 + - env: T=devel/hcloud/3.8/2 + + + - env: T=2.10/sanity/1 + - env: T=2.10/sanity/2 + - env: T=2.10/sanity/3 + - env: T=2.10/sanity/4 + + - env: T=2.10/hcloud/3.8/1 + - env: T=2.10/hcloud/3.8/2 + + + - env: T=2.9/sanity/1 + - env: T=2.9/sanity/2 + - env: T=2.9/sanity/3 + - env: T=2.9/sanity/4 branches: except: diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt deleted file mode 100644 index c70dfdb..0000000 --- a/tests/sanity/ignore-2.10.txt +++ /dev/null @@ -1,5 +0,0 @@ -plugins/modules/hcloud_network_info.py validate-modules:return-syntax-error -plugins/modules/hcloud_server.py validate-modules:parameter-list-no-elements -plugins/modules/hcloud_server_network.py validate-modules:parameter-list-no-elements -plugins/doc_fragments/hcloud.py future-import-boilerplate -plugins/doc_fragments/hcloud.py metaclass-boilerplate \ No newline at end of file diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt deleted file mode 100644 index c70dfdb..0000000 --- a/tests/sanity/ignore-2.9.txt +++ /dev/null @@ -1,5 +0,0 @@ -plugins/modules/hcloud_network_info.py validate-modules:return-syntax-error -plugins/modules/hcloud_server.py validate-modules:parameter-list-no-elements -plugins/modules/hcloud_server_network.py validate-modules:parameter-list-no-elements -plugins/doc_fragments/hcloud.py future-import-boilerplate -plugins/doc_fragments/hcloud.py metaclass-boilerplate \ No newline at end of file diff --git a/tests/utils/gitlab/gitlab.sh b/tests/utils/gitlab/gitlab.sh index 4c91c97..d5941dc 100755 --- a/tests/utils/gitlab/gitlab.sh +++ b/tests/utils/gitlab/gitlab.sh @@ -6,7 +6,16 @@ declare -a args IFS='/:' read -ra args <<< "$1" -test="${args[0]}" +ansible_version="${args[0]}" +script="${args[1]}" + +function join { + local IFS="$1"; + shift; + echo "$*"; +} + +test="$(join / "${args[@]:1}")" command -v python python -V @@ -29,8 +38,11 @@ function retry command -v pip pip --version pip list --disable-pip-version-check -retry pip install https://github.com/ansible/ansible/archive/devel.tar.gz --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_PATHS="${HOME}/.ansible" SHIPPABLE_RESULT_DIR="$(pwd)/shippable" TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/hetzner/hcloud" diff --git a/tests/utils/shippable/shippable.sh b/tests/utils/shippable/shippable.sh index 866fd6c..bd1f7ca 100755 --- a/tests/utils/shippable/shippable.sh +++ b/tests/utils/shippable/shippable.sh @@ -5,9 +5,16 @@ set -o pipefail -eux declare -a args IFS='/:' read -ra args <<< "$1" -script="${args[0]}" +ansible_version="${args[0]}" +script="${args[1]}" -test="$1" +function join { + local IFS="$1"; + shift; + echo "$*"; +} + +test="$(join / "${args[@]:1}")" docker images ansible/ansible docker images quay.io/ansible/* @@ -45,8 +52,11 @@ function retry command -v pip pip --version pip list --disable-pip-version-check -retry pip install https://github.com/ansible/ansible/archive/devel.tar.gz --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_PATHS="${HOME}/.ansible" SHIPPABLE_RESULT_DIR="$(pwd)/shippable" TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/hetzner/hcloud"