From: Don Zickus on gitlab.com Merge Request: https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2519
This change uses the update git push changes for ark-create-release.sh. The behavior moves the git push for gitlab-ci.yml to the script itself. No expected behavior fallout, but there are some odd legacy cases that may cause a subtle change.
Dependent on part2.
Signed-off-by: Don Zickus dzickus@redhat.com
--- redhat/scripts/ci/ark-ci-env.sh | 30 +++++++++++ redhat/scripts/ci/ark-create-release.sh | 74 +++++++++++----------------- redhat/scripts/ci/ark-update-configs.sh | 85 ++++++++++++++++++-------------- redhat/Makefile | 12 +--- .gitlab-ci.yml | 17 +----- 5 files changed, 112 insertions(+), 106 deletions(-)
From: Don Zickus dzickus@redhat.com
CI: Move os-build tracking to common area
Future changes will use also use os-build, move the tracking to a common area to reduce code duplication.
Signed-off-by: Don Zickus dzickus@redhat.com
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index blahblah..blahblah 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -83,12 +83,12 @@ ark_merge_request: - git remote add gitlab git@gitlab.com:cki-project/kernel-ark.git - gpg2 --import "$TORVALDS_GPG_KEY" - git checkout --track origin/master && git describe + - git checkout --track origin/os-build && git describe - export PROJECT_ID="$CI_PROJECT_ID"
merge_upstream: extends: .scheduled_setup script: - - git checkout --track origin/os-build && git describe - make dist-merge-upstream-push || exit 1 retry: 2 rules: @@ -100,7 +100,6 @@ rawhide_release: script: - git checkout --track origin/ark-latest && git describe - git checkout --track origin/ark-infra && git describe - - git checkout --track origin/os-build && git describe - redhat/scripts/ci/ark-create-release.sh "master" "$CI_PROJECT_ID" || exit_code=$? - if [ $exit_code -eq 3 ]; then echo "Tag exists, halting" && exit 0; fi; - if [ $exit_code -ne 0 ]; then echo "Unable to create release tag" && exit 1; fi;
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2519
From: Don Zickus dzickus@redhat.com
CI: Remove stale TAG and Makefile cruft
The TAG variable turned into _TAG but the ci scripts were never updated to reflect that. No one noticed for over a year, therefore it must not be important.
Also dist-merge-upstream had a branch check as a safety valve to prevent accidentally losing changes to testing by switching branches. Later a 'git-tree-check' was added to prevent the script from running on a dirty tree. The latter is more useful than the former. Remove the former.
Signed-off-by: Don Zickus dzickus@redhat.com
diff --git a/redhat/Makefile b/redhat/Makefile index blahblah..blahblah 100644 --- a/redhat/Makefile +++ b/redhat/Makefile @@ -795,22 +795,14 @@ git-tree-check: { echo -e "Dirty tree, please clean before merging.\n"; exit 1; }
dist-merge-upstream: git-tree-check - @if test "$(shell $(GIT) branch --show-current)" != "$(DIST_BRANCH)"; then \ - echo -e "Please checkout $(DIST_BRANCH) branch before merging.\n"; \ - exit 1; \ - fi; - - @# If TAG is empty, script defaults to master:HEAD - @$(GIT) checkout $(DIST_BRANCH) - @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG) + @cd ..; $(REDHAT)/scripts/ci/ark-update-configs.sh
dist-merge-upstream-push: export DIST_PUSH="1" dist-merge-upstream-push: dist-merge-upstream
dist-fedora-release: git-tree-check
- @# If TAG is empty, script defaults to master:HEAD - @cd ..; $(REDHAT)/scripts/ci/ark-create-release.sh $(TAG) || \ + @cd ..; $(REDHAT)/scripts/ci/ark-create-release.sh || \ (echo "Unable to create release tag"; exit 1)
dist-fedora-release-push: export DIST_PUSH="1"
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2519
From: Don Zickus dzickus@redhat.com
CI: Call script directly
Originally I thought it would be safer to use a Makefile to control the variables to the ci scripts. Now I realize I lose the ability to pass arguments unless I use environment variables.
Let's call the script directly in preparation for use arguments when expanding to other use cases.
No behaviour changes expected.
Signed-off-by: Don Zickus dzickus@redhat.com
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index blahblah..blahblah 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -89,7 +89,7 @@ ark_merge_request: merge_upstream: extends: .scheduled_setup script: - - make dist-merge-upstream-push || exit 1 + - DIST_PUSH=1 redhat/scripts/ci/ark-update-configs.sh || exit 1 retry: 2 rules: - if: '$CI_PIPELINE_SOURCE == "schedule" && $RAWHIDE_RELEASE == "false"'
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2519
From: Don Zickus dzickus@redhat.com
CI: Introduce simple environment script
Simple code re-use across the ci scripts. The same variables and setup functions are used. Update the ci scripts to source the new script.
This changes the API to ark-create-release.sh, so modify the call to the script to accept the defaults, which mimics current behaviour.
Signed-off-by: Don Zickus dzickus@redhat.com
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index blahblah..blahblah 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -100,7 +100,7 @@ rawhide_release: script: - git checkout --track origin/ark-latest && git describe - git checkout --track origin/ark-infra && git describe - - redhat/scripts/ci/ark-create-release.sh "master" "$CI_PROJECT_ID" || exit_code=$? + - redhat/scripts/ci/ark-create-release.sh || exit_code=$? - if [ $exit_code -eq 3 ]; then echo "Tag exists, halting" && exit 0; fi; - if [ $exit_code -ne 0 ]; then echo "Unable to create release tag" && exit 1; fi; - git push gitlab os-build diff --git a/redhat/scripts/ci/ark-ci-env.sh b/redhat/scripts/ci/ark-ci-env.sh new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/scripts/ci/ark-ci-env.sh @@ -0,0 +1,30 @@ +#! /bin/sh + +die() +{ + echo "$1" + exit 1 +} + +ci_pre_check() +{ + if test -n "${TO_PUSH}" && test -z "${GITLAB_URL}"; then + die "Please run 'git remote add gitlab <url>' to enable git-push." + fi + git diff-index --quiet HEAD || die "Dirty tree, please clean before merging." +} + +# Common variables for all CI scripts +UPSTREAM_REF=${1:-"master"} +BRANCH=${2:-"os-build"} +PROJECT_ID=${PROJECT_ID:-"13604247"} +TO_PUSH=${DIST_PUSH:-""} +GITLAB_URL="$(git remote get-url gitlab 2>/dev/null)" + +ci_pre_check + +export UPSTREAM_REF +export BRANCH +export PROJECT_ID +export TO_PUSH +export GITLAB_URL diff --git a/redhat/scripts/ci/ark-create-release.sh b/redhat/scripts/ci/ark-create-release.sh index blahblah..blahblah 100755 --- a/redhat/scripts/ci/ark-create-release.sh +++ b/redhat/scripts/ci/ark-create-release.sh @@ -7,8 +7,9 @@
set -e
-UPSTREAM_REF=${1-master} -PROJECT_ID=${2:-13604247} +# source common CI functions and variables +# shellcheck source=./redhat/scripts/ci/ark-ci-env.sh +. "$(dirname "$0")"/ark-ci-env.sh
# Detect if there's one or more prior releases for this upstream ref. if git describe "$UPSTREAM_REF" | grep -q -c '-g'; then diff --git a/redhat/scripts/ci/ark-update-configs.sh b/redhat/scripts/ci/ark-update-configs.sh index blahblah..blahblah 100755 --- a/redhat/scripts/ci/ark-update-configs.sh +++ b/redhat/scripts/ci/ark-update-configs.sh @@ -18,8 +18,9 @@
set -e
-UPSTREAM_REF=${1:-master} -test -n "$PROJECT_ID" || PROJECT_ID="${2:-13604247}" +# source common CI functions and variables +# shellcheck source=./redhat/scripts/ci/ark-ci-env.sh +. "$(dirname "$0")"/ark-ci-env.sh
ISSUE_DESCRIPTION="A merge conflict has occurred and must be resolved manually.
@@ -31,8 +32,7 @@ To resolve this, do the following: 4. git push "
-git checkout os-build -BRANCH="$(git branch --show-current)" +git checkout "${BRANCH}" if ! git merge -m "Merge '$UPSTREAM_REF' into '$BRANCH'" "$UPSTREAM_REF"; then git merge --abort printf "Merge conflict; halting!\n"
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2519
kernel@lists.fedoraproject.org