diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf4c017b8..b565b1aff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,9 +6,13 @@ stages: - deploy-extended variables: - KUBESPRAY_VERSION: v2.27.0 FAILFASTCI_NAMESPACE: 'kargo-ci' GITLAB_REPOSITORY: 'kargo-ci/kubernetes-sigs-kubespray' + GIT_CONFIG_COUNT: 1 + GIT_CONFIG_KEY_0: user.key + GIT_CONFIG_VALUE_0: "ci@kubespray.io" + GIT_CONFIG_KEY_1: user.name + GIT_CONFIG_VALUE_1: "CI" ANSIBLE_FORCE_COLOR: "true" MAGIC: "ci check this" GS_ACCESS_KEY_ID: $GS_KEY @@ -52,7 +56,6 @@ before_script: needs: - pipeline-image - ci-not-authorized - - check-galaxy-version # lint - pre-commit # lint - vagrant-validate # lint diff --git a/.gitlab-ci/lint.yml b/.gitlab-ci/lint.yml index 1fc50fe9a..c94a153f8 100644 --- a/.gitlab-ci/lint.yml +++ b/.gitlab-ci/lint.yml @@ -24,13 +24,3 @@ vagrant-validate: script: - ./tests/scripts/vagrant-validate.sh except: ['triggers', 'master'] - - -# TODO: convert to pre-commit hook -check-galaxy-version: - needs: [] - stage: test - tags: [ffci] - image: python:3 - script: - - tests/scripts/check_galaxy_version.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f298e502..585d4fe23 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,6 +70,14 @@ repos: - pathlib - pyaml + - id: check-galaxy-version + name: Verify correct version for galaxy.yml + entry: scripts/galaxy_version.py + language: python + pass_filenames: false + additional_dependencies: + - ruamel.yaml + - id: jinja-syntax-check name: jinja-syntax-check entry: tests/scripts/check-templates.py diff --git a/RELEASE.md b/RELEASE.md index 27495311a..2f1a5975e 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -12,7 +12,6 @@ The Kubespray Project is released on an as-needed basis. The process is as follo 1. (For major releases) On the `master` branch: bump the version in `galaxy.yml` to the next expected major release (X.y.0 with y = Y + 1), make a Pull Request. 1. (For minor releases) On the `release-X.Y` branch: bump the version in `galaxy.yml` to the next expected minor release (X.Y.z with z = Z + 1), make a Pull Request. 1. The corresponding version of [quay.io/kubespray/kubespray:vX.Y.Z](https://quay.io/repository/kubespray/kubespray) and [quay.io/kubespray/vagrant:vX.Y.Z](https://quay.io/repository/kubespray/vagrant) container images are built and tagged. See the following `Container image creation` section for the details. -1. (Only for major releases) The `KUBESPRAY_VERSION` in `.gitlab-ci.yml` is upgraded to the version we just released # TODO clarify this, this variable is for testing upgrades. 1. The release issue is closed 1. An announcement email is sent to `dev@kubernetes.io` with the subject `[ANNOUNCE] Kubespray $VERSION is released` 1. The topic of the #kubespray channel is updated with `vX.Y.Z is released! | ...` diff --git a/scripts/galaxy_version.py b/scripts/galaxy_version.py new file mode 100755 index 000000000..c04432651 --- /dev/null +++ b/scripts/galaxy_version.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +import subprocess +import ruamel.yaml +import os + +last_tag = ( + subprocess.Popen( + ["git", "describe", "--tags", "--abbrev=0"], stdout=subprocess.PIPE + ) + .communicate()[0] + .rstrip() + .decode("utf-8") + .removeprefix("v") + .split(".") +) +# Use CI provided base ref if available, else use HEAD to guess +git_branch = os.getenv( + "GITHUB_BASE_REF", + ( + subprocess.Popen( + ["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE + ) + .communicate()[0] + .rstrip() + .decode("utf-8") + ), +) +if git_branch.startswith("release"): + version_comp_index = 2 +else: + version_comp_index = 1 + +last_tag[version_comp_index] = str(int(last_tag[version_comp_index]) + 1) +new_tag = ".".join(last_tag) + +yaml = ruamel.yaml.YAML() +yaml.indent(mapping=2, sequence=4, offset=2) +yaml.explicit_start = True + +with open( + "galaxy.yml", +) as galaxy_yml: + config = yaml.load(galaxy_yml) + +config["version"] = new_tag + +with open("galaxy.yml", "w") as galaxy_yml: + yaml.dump(config, galaxy_yml) diff --git a/tests/scripts/check_galaxy_version.sh b/tests/scripts/check_galaxy_version.sh deleted file mode 100755 index d663f121f..000000000 --- a/tests/scripts/check_galaxy_version.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -e - -version_from_galaxy=$(grep "^version:" galaxy.yml | awk '{print $2}') - -# TODO: compute the next expected version somehow -if [[ $KUBESPRAY_VERSION == "v${version_from_galaxy}" ]] -then - echo "Please update galaxy.yml version to match the next KUBESPRAY_VERSION." - echo "Be sure to remove the \"v\" to adhere to semantic versioning" - exit 1 -fi diff --git a/tests/scripts/rebase.sh b/tests/scripts/rebase.sh index 36cb7f613..6ea59e317 100755 --- a/tests/scripts/rebase.sh +++ b/tests/scripts/rebase.sh @@ -1,15 +1,6 @@ -#!/bin/bash -set -euxo pipefail +#!/bin/sh +set -ex -KUBESPRAY_NEXT_VERSION=2.$(( ${KUBESPRAY_VERSION:3:2} + 1 )) - -# Rebase PRs on master (or release branch) to get latest changes -if [[ $CI_COMMIT_REF_NAME == pr-* ]]; then - git config user.email "ci@kubespray.io" - git config user.name "CI" - if [[ -z "`git branch -a --list origin/release-$KUBESPRAY_NEXT_VERSION`" ]]; then - git pull --rebase origin master - else - git pull --rebase origin release-$KUBESPRAY_NEXT_VERSION - fi +if [ "${GITHUB_BASE_REF}" ]; then + git pull --rebase origin $GITHUB_BASE_REF fi diff --git a/tests/scripts/testcases_run.sh b/tests/scripts/testcases_run.sh index 1d97bbf4c..bf50d79b1 100755 --- a/tests/scripts/testcases_run.sh +++ b/tests/scripts/testcases_run.sh @@ -17,7 +17,7 @@ fi # Check out latest tag if testing upgrade if [ "${UPGRADE_TEST}" != "false" ]; then - git fetch --all && git checkout "$KUBESPRAY_VERSION" + git fetch --all && git checkout $(git describe --tags --abbrev=0) # Checkout the current tests/ directory ; even when testing old version, # we want the up-to-date test setup/provisionning git checkout "${CI_COMMIT_SHA}" -- tests/