[OS-BUILD PATCH 4/9] CI: Introduce simple environment script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Don Zickus <dzickus@xxxxxxxxxx>

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@xxxxxxxxxx>

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/2518
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux