From 3a26978408478b4c661b8400e544d5b1884c9155 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:28:32 -0700 Subject: [PATCH 01/24] ci: added linting for changelog and version --- .gitlab-ci.yml | 23 +++++++++++++++++++---- CHANGELOG => CHANGELOG.md | 0 scripts/lint_changelog.sh | 21 +++++++++++++++++++++ scripts/lint_version.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 4 deletions(-) rename CHANGELOG => CHANGELOG.md (100%) create mode 100755 scripts/lint_changelog.sh create mode 100755 scripts/lint_version.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd188b803b..63e782707d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,15 +37,30 @@ variables: # Pre Stage Jobs # +changelog: + image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 + stage: .pre + allow_failure: true + variables: + CHANGELOG_FILE: CHANGELOG.md + script: + - ./scripts/lint_changelog.sh + +version: + image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 + stage: .pre + allow_failure: true + variables: + CHART_FILE: chart/Chart.yaml + script: + - ./scripts/lint_version.sh + commitlint: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 stage: .pre allow_failure: true script: - - dnf module install -y nodejs - - npm install --only=dev - - git fetch --all - - ./scripts/commitlint.sh + - ./scripts/lint_version.sh pre vars: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 diff --git a/CHANGELOG b/CHANGELOG.md similarity index 100% rename from CHANGELOG rename to CHANGELOG.md diff --git a/scripts/lint_changelog.sh b/scripts/lint_changelog.sh new file mode 100755 index 0000000000..62df767edb --- /dev/null +++ b/scripts/lint_changelog.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# diff the file silently, while still printing errors +git diff --exit-code ${CI_DEFAULT_BRANCH}:${CHANGELOG_FILE} ${CHANGELOG_FILE} >/dev/null + +# exit code of 0 indicates non changed file +if [ $? -eq 0 ]; then + echo "No changes were detected in ${CHANGELOG_FILE}, please update this file" + exit 1 +fi + +# exit code other than 0 and 1 is an error +# IE - different file names between branches +# check for this and fail accordingly +if [ $? -ne 1 ]; then + echo "Error: An unknown error has occurred while linting ${CHANGELOG_FILE}" + exit 1 +fi + +# default to success +exit 0 \ No newline at end of file diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh new file mode 100755 index 0000000000..af7af82590 --- /dev/null +++ b/scripts/lint_version.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# obtain the default version +default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'version: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred when attempting to retrieve the default version" + exit 1 +fi + +# obtain the local version +local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred when attempting to retrieve the local version" + exit 1 +fi + +# debug print +echo "Default version: $default_version" +echo "Local version: $local_version" + +# error if the versions are not different +if [[ "$default_version" == "$local_version" ]]; then + echo "The version has not been updated in ${CHART_FILE}, please update this file" +fi \ No newline at end of file -- GitLab From c03703ed68331120e0452524ea80eaf30cdb0c32 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:30:25 -0700 Subject: [PATCH 02/24] ci: added linting for changelog and version --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 63e782707d..4035fdd248 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,7 +60,10 @@ commitlint: stage: .pre allow_failure: true script: - - ./scripts/lint_version.sh + - dnf module install -y nodejs + - npm install --only=dev + - git fetch --all + - ./scripts/commitlint.sh pre vars: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 -- GitLab From 24ebe5fb1f24be11e5467d3cef24f9685053096a Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:30:53 -0700 Subject: [PATCH 03/24] ci: added linting for changelog and version --- .gitlab-ci.yml | 4 ++-- scripts/{commitlint.sh => lint_commits.sh} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename scripts/{commitlint.sh => lint_commits.sh} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4035fdd248..0278b535b6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -55,7 +55,7 @@ version: script: - ./scripts/lint_version.sh -commitlint: +commits: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 stage: .pre allow_failure: true @@ -63,7 +63,7 @@ commitlint: - dnf module install -y nodejs - npm install --only=dev - git fetch --all - - ./scripts/commitlint.sh + - ./scripts/lint_commits.sh pre vars: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 diff --git a/scripts/commitlint.sh b/scripts/lint_commits.sh similarity index 100% rename from scripts/commitlint.sh rename to scripts/lint_commits.sh -- GitLab From 8f95f87888eb5dea5ac9985945163dbda79cf138 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:31:50 -0700 Subject: [PATCH 04/24] ci: added linting for changelog and version --- scripts/lint_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index af7af82590..840fea9b2e 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -5,7 +5,7 @@ default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'versi # check for command error if [ $? -ne 0 ]; then - echo "Error: An unknown error has occurred when attempting to retrieve the default version" + echo "Error: An unknown error has occurred when attempting to retrieve the default version from ${CHART_FILE}" exit 1 fi @@ -14,7 +14,7 @@ local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then - echo "Error: An unknown error has occurred when attempting to retrieve the local version" + echo "Error: An unknown error has occurred when attempting to retrieve the local version from ${CHART_FILE}" exit 1 fi -- GitLab From 530a5a47b9862f1d138bbebbacf78cf3e9d256de Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:32:37 -0700 Subject: [PATCH 05/24] ci: added linting for changelog and version --- scripts/lint_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 840fea9b2e..5a76fd21c7 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # obtain the default version -default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'version: \K(.*)') +default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -10,7 +10,7 @@ if [ $? -ne 0 ]; then fi # obtain the local version -local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') +local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then -- GitLab From 92f81f629dc06112185b5999265d01fc90a20a54 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:34:00 -0700 Subject: [PATCH 06/24] ci: added linting for changelog and version --- scripts/lint_changelog.sh | 2 +- scripts/lint_version.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint_changelog.sh b/scripts/lint_changelog.sh index 62df767edb..cd52786548 100755 --- a/scripts/lint_changelog.sh +++ b/scripts/lint_changelog.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # diff the file silently, while still printing errors -git diff --exit-code ${CI_DEFAULT_BRANCH}:${CHANGELOG_FILE} ${CHANGELOG_FILE} >/dev/null +git diff --exit-code origin/${CI_DEFAULT_BRANCH}:${CHANGELOG_FILE} ${CHANGELOG_FILE} >/dev/null # exit code of 0 indicates non changed file if [ $? -eq 0 ]; then diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 5a76fd21c7..d4300ab6e5 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # obtain the default version -default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') +default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then -- GitLab From 79ae92de9eb37dab495f73e33072e364d8e75fcd Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:35:26 -0700 Subject: [PATCH 07/24] ci: added linting for changelog and version --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0278b535b6..b3d5bb250c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,6 +44,7 @@ changelog: variables: CHANGELOG_FILE: CHANGELOG.md script: + - git fetch --all - ./scripts/lint_changelog.sh version: @@ -53,6 +54,7 @@ version: variables: CHART_FILE: chart/Chart.yaml script: + - git fetch --all - ./scripts/lint_version.sh commits: -- GitLab From 0555c0237bca427c6f7457268c6cd60185a9c451 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:36:25 -0700 Subject: [PATCH 08/24] ci: added linting for changelog and version --- scripts/lint_version.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index d4300ab6e5..32355d2071 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -25,4 +25,8 @@ echo "Local version: $local_version" # error if the versions are not different if [[ "$default_version" == "$local_version" ]]; then echo "The version has not been updated in ${CHART_FILE}, please update this file" -fi \ No newline at end of file + exit 1 +fi + +# default to success +exit 0 \ No newline at end of file -- GitLab From 487a6ff21ae42bce0a0e44b973af8fbe78f379ee Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:40:39 -0700 Subject: [PATCH 09/24] ci: added linting for changelog and version --- scripts/lint_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 32355d2071..81aa0476cb 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -5,7 +5,7 @@ default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP # check for command error if [ $? -ne 0 ]; then - echo "Error: An unknown error has occurred when attempting to retrieve the default version from ${CHART_FILE}" + echo "Error: An unknown error has occurred while attempting to retrieve the default version from ${CHART_FILE}" exit 1 fi @@ -14,7 +14,7 @@ local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then - echo "Error: An unknown error has occurred when attempting to retrieve the local version from ${CHART_FILE}" + echo "Error: An unknown error has occurred while attempting to retrieve the local version from ${CHART_FILE}" exit 1 fi -- GitLab From 2ee9de1797e56232952516651f739794316d2f94 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Wed, 20 Jan 2021 17:56:11 -0700 Subject: [PATCH 10/24] Added basegitrepository.yaml tag check --- .gitlab-ci.yml | 1 + scripts/lint_version.sh | 52 +++++++++++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b3d5bb250c..b91a8b2b04 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,6 +53,7 @@ version: allow_failure: true variables: CHART_FILE: chart/Chart.yaml + BASEGIT_FILE: base/gitrepository.yaml script: - git fetch --all - ./scripts/lint_version.sh diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 81aa0476cb..34c63c39be 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# obtain the default version -default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') +# obtain the default chart version +chart_default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -9,8 +9,8 @@ if [ $? -ne 0 ]; then exit 1 fi -# obtain the local version -local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)') +# obtain the local chart version +chart_local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -18,15 +18,47 @@ if [ $? -ne 0 ]; then exit 1 fi +# obtain the default base git repository tag +basegit_default_tag=$(git show origin/${CI_DEFAULT_BRANCH}:${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred while attempting to retrieve the default tag from ${BASEGIT_FILE}" + exit 1 +fi + +# obtain the local base git repository tag +basegit_local_tag=$(cat ${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred while attempting to retrieve the local tag from ${BASEGIT_FILE}" + exit 1 +fi + # debug print -echo "Default version: $default_version" -echo "Local version: $local_version" +echo "Default chart version: $chart_default_version" +echo "Local chart version: $chart_local_version" + +# assume success +exit_code=0 # error if the versions are not different -if [[ "$default_version" == "$local_version" ]]; then +if [[ "$chart_default_version" == "$chart_local_version" ]]; then echo "The version has not been updated in ${CHART_FILE}, please update this file" - exit 1 + exit_code=1 +fi + +echo "--" + +echo "Default base git repository version: $basegit_default_tag" +echo "Local base git repository version: $basegit_local_tag" + +# error if the versions are not different +if [[ "$chart_default_version" == "$chart_local_version" ]]; then + echo "The tag has not been updated in ${CHART_FILE}, please update this file" + exit_code=1 fi -# default to success -exit 0 \ No newline at end of file +# exit with stored code +exit $exit_code \ No newline at end of file -- GitLab From 100eb7085843aa00345cfdcd960f6179ceab444d Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Wed, 20 Jan 2021 17:57:10 -0700 Subject: [PATCH 11/24] Changed ggrep to grep --- scripts/lint_version.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 34c63c39be..e619551db1 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # obtain the default chart version -chart_default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'version: \K(.*)') +chart_default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -10,7 +10,7 @@ if [ $? -ne 0 ]; then fi # obtain the local chart version -chart_local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') +chart_local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -19,7 +19,7 @@ if [ $? -ne 0 ]; then fi # obtain the default base git repository tag -basegit_default_tag=$(git show origin/${CI_DEFAULT_BRANCH}:${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') +basegit_default_tag=$(git show origin/${CI_DEFAULT_BRANCH}:${BASEGIT_FILE} | grep -oP 'tag: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -28,7 +28,7 @@ if [ $? -ne 0 ]; then fi # obtain the local base git repository tag -basegit_local_tag=$(cat ${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') +basegit_local_tag=$(cat ${BASEGIT_FILE} | grep -oP 'tag: \K(.*)') # check for command error if [ $? -ne 0 ]; then -- GitLab From f60390b776722c286c8fced9dcfafb4ead401be5 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:28:32 -0700 Subject: [PATCH 12/24] ci: added linting for changelog and version --- .gitlab-ci.yml | 23 +++++++++++++++++++---- CHANGELOG => CHANGELOG.md | 0 scripts/lint_changelog.sh | 21 +++++++++++++++++++++ scripts/lint_version.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 4 deletions(-) rename CHANGELOG => CHANGELOG.md (100%) create mode 100755 scripts/lint_changelog.sh create mode 100755 scripts/lint_version.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd188b803b..63e782707d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,15 +37,30 @@ variables: # Pre Stage Jobs # +changelog: + image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 + stage: .pre + allow_failure: true + variables: + CHANGELOG_FILE: CHANGELOG.md + script: + - ./scripts/lint_changelog.sh + +version: + image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 + stage: .pre + allow_failure: true + variables: + CHART_FILE: chart/Chart.yaml + script: + - ./scripts/lint_version.sh + commitlint: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 stage: .pre allow_failure: true script: - - dnf module install -y nodejs - - npm install --only=dev - - git fetch --all - - ./scripts/commitlint.sh + - ./scripts/lint_version.sh pre vars: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 diff --git a/CHANGELOG b/CHANGELOG.md similarity index 100% rename from CHANGELOG rename to CHANGELOG.md diff --git a/scripts/lint_changelog.sh b/scripts/lint_changelog.sh new file mode 100755 index 0000000000..62df767edb --- /dev/null +++ b/scripts/lint_changelog.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# diff the file silently, while still printing errors +git diff --exit-code ${CI_DEFAULT_BRANCH}:${CHANGELOG_FILE} ${CHANGELOG_FILE} >/dev/null + +# exit code of 0 indicates non changed file +if [ $? -eq 0 ]; then + echo "No changes were detected in ${CHANGELOG_FILE}, please update this file" + exit 1 +fi + +# exit code other than 0 and 1 is an error +# IE - different file names between branches +# check for this and fail accordingly +if [ $? -ne 1 ]; then + echo "Error: An unknown error has occurred while linting ${CHANGELOG_FILE}" + exit 1 +fi + +# default to success +exit 0 \ No newline at end of file diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh new file mode 100755 index 0000000000..af7af82590 --- /dev/null +++ b/scripts/lint_version.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# obtain the default version +default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'version: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred when attempting to retrieve the default version" + exit 1 +fi + +# obtain the local version +local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred when attempting to retrieve the local version" + exit 1 +fi + +# debug print +echo "Default version: $default_version" +echo "Local version: $local_version" + +# error if the versions are not different +if [[ "$default_version" == "$local_version" ]]; then + echo "The version has not been updated in ${CHART_FILE}, please update this file" +fi \ No newline at end of file -- GitLab From 3eb8ff13a546c1efe201562c04424aed6fba68b9 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:30:25 -0700 Subject: [PATCH 13/24] ci: added linting for changelog and version --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 63e782707d..4035fdd248 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,7 +60,10 @@ commitlint: stage: .pre allow_failure: true script: - - ./scripts/lint_version.sh + - dnf module install -y nodejs + - npm install --only=dev + - git fetch --all + - ./scripts/commitlint.sh pre vars: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 -- GitLab From c42a5cda092afe6df63cd293ed70a1d718eb63e2 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:30:53 -0700 Subject: [PATCH 14/24] ci: added linting for changelog and version --- .gitlab-ci.yml | 4 ++-- scripts/{commitlint.sh => lint_commits.sh} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename scripts/{commitlint.sh => lint_commits.sh} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4035fdd248..0278b535b6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -55,7 +55,7 @@ version: script: - ./scripts/lint_version.sh -commitlint: +commits: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 stage: .pre allow_failure: true @@ -63,7 +63,7 @@ commitlint: - dnf module install -y nodejs - npm install --only=dev - git fetch --all - - ./scripts/commitlint.sh + - ./scripts/lint_commits.sh pre vars: image: registry.dsop.io/platform-one/big-bang/pipeline-templates/pipeline-templates/pre-envs:ubi8.3 diff --git a/scripts/commitlint.sh b/scripts/lint_commits.sh similarity index 100% rename from scripts/commitlint.sh rename to scripts/lint_commits.sh -- GitLab From e9866f855d9a68b487e9a6d45570011a1b9e05da Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:31:50 -0700 Subject: [PATCH 15/24] ci: added linting for changelog and version --- scripts/lint_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index af7af82590..840fea9b2e 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -5,7 +5,7 @@ default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'versi # check for command error if [ $? -ne 0 ]; then - echo "Error: An unknown error has occurred when attempting to retrieve the default version" + echo "Error: An unknown error has occurred when attempting to retrieve the default version from ${CHART_FILE}" exit 1 fi @@ -14,7 +14,7 @@ local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then - echo "Error: An unknown error has occurred when attempting to retrieve the local version" + echo "Error: An unknown error has occurred when attempting to retrieve the local version from ${CHART_FILE}" exit 1 fi -- GitLab From 8098108445cf1afe844cbb323111cb25e96636c9 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:32:37 -0700 Subject: [PATCH 16/24] ci: added linting for changelog and version --- scripts/lint_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 840fea9b2e..5a76fd21c7 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # obtain the default version -default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'version: \K(.*)') +default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -10,7 +10,7 @@ if [ $? -ne 0 ]; then fi # obtain the local version -local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') +local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then -- GitLab From e9838f9e046bc1d2e295771771fb801ce23b08ca Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:34:00 -0700 Subject: [PATCH 17/24] ci: added linting for changelog and version --- scripts/lint_changelog.sh | 2 +- scripts/lint_version.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint_changelog.sh b/scripts/lint_changelog.sh index 62df767edb..cd52786548 100755 --- a/scripts/lint_changelog.sh +++ b/scripts/lint_changelog.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # diff the file silently, while still printing errors -git diff --exit-code ${CI_DEFAULT_BRANCH}:${CHANGELOG_FILE} ${CHANGELOG_FILE} >/dev/null +git diff --exit-code origin/${CI_DEFAULT_BRANCH}:${CHANGELOG_FILE} ${CHANGELOG_FILE} >/dev/null # exit code of 0 indicates non changed file if [ $? -eq 0 ]; then diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 5a76fd21c7..d4300ab6e5 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # obtain the default version -default_version=$(git show ${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') +default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then -- GitLab From 65cc93b1422673d338d544590b989c06e294a905 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:35:26 -0700 Subject: [PATCH 18/24] ci: added linting for changelog and version --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0278b535b6..b3d5bb250c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,6 +44,7 @@ changelog: variables: CHANGELOG_FILE: CHANGELOG.md script: + - git fetch --all - ./scripts/lint_changelog.sh version: @@ -53,6 +54,7 @@ version: variables: CHART_FILE: chart/Chart.yaml script: + - git fetch --all - ./scripts/lint_version.sh commits: -- GitLab From 5b5aca50cfda6bd0734108a815045809d92724be Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:36:25 -0700 Subject: [PATCH 19/24] ci: added linting for changelog and version --- scripts/lint_version.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index d4300ab6e5..32355d2071 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -25,4 +25,8 @@ echo "Local version: $local_version" # error if the versions are not different if [[ "$default_version" == "$local_version" ]]; then echo "The version has not been updated in ${CHART_FILE}, please update this file" -fi \ No newline at end of file + exit 1 +fi + +# default to success +exit 0 \ No newline at end of file -- GitLab From 89ec6a6aa21853f0776b4089679d67b7c6543f39 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Tue, 19 Jan 2021 11:40:39 -0700 Subject: [PATCH 20/24] ci: added linting for changelog and version --- scripts/lint_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 32355d2071..81aa0476cb 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -5,7 +5,7 @@ default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP # check for command error if [ $? -ne 0 ]; then - echo "Error: An unknown error has occurred when attempting to retrieve the default version from ${CHART_FILE}" + echo "Error: An unknown error has occurred while attempting to retrieve the default version from ${CHART_FILE}" exit 1 fi @@ -14,7 +14,7 @@ local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then - echo "Error: An unknown error has occurred when attempting to retrieve the local version from ${CHART_FILE}" + echo "Error: An unknown error has occurred while attempting to retrieve the local version from ${CHART_FILE}" exit 1 fi -- GitLab From 3d80c3604722c01493bce72d10b8854a73fe40ac Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Wed, 20 Jan 2021 17:56:11 -0700 Subject: [PATCH 21/24] Added basegitrepository.yaml tag check --- .gitlab-ci.yml | 1 + scripts/lint_version.sh | 52 +++++++++++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b3d5bb250c..b91a8b2b04 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,6 +53,7 @@ version: allow_failure: true variables: CHART_FILE: chart/Chart.yaml + BASEGIT_FILE: base/gitrepository.yaml script: - git fetch --all - ./scripts/lint_version.sh diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 81aa0476cb..34c63c39be 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# obtain the default version -default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') +# obtain the default chart version +chart_default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -9,8 +9,8 @@ if [ $? -ne 0 ]; then exit 1 fi -# obtain the local version -local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)') +# obtain the local chart version +chart_local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -18,15 +18,47 @@ if [ $? -ne 0 ]; then exit 1 fi +# obtain the default base git repository tag +basegit_default_tag=$(git show origin/${CI_DEFAULT_BRANCH}:${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred while attempting to retrieve the default tag from ${BASEGIT_FILE}" + exit 1 +fi + +# obtain the local base git repository tag +basegit_local_tag=$(cat ${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred while attempting to retrieve the local tag from ${BASEGIT_FILE}" + exit 1 +fi + # debug print -echo "Default version: $default_version" -echo "Local version: $local_version" +echo "Default chart version: $chart_default_version" +echo "Local chart version: $chart_local_version" + +# assume success +exit_code=0 # error if the versions are not different -if [[ "$default_version" == "$local_version" ]]; then +if [[ "$chart_default_version" == "$chart_local_version" ]]; then echo "The version has not been updated in ${CHART_FILE}, please update this file" - exit 1 + exit_code=1 +fi + +echo "--" + +echo "Default base git repository version: $basegit_default_tag" +echo "Local base git repository version: $basegit_local_tag" + +# error if the versions are not different +if [[ "$chart_default_version" == "$chart_local_version" ]]; then + echo "The tag has not been updated in ${CHART_FILE}, please update this file" + exit_code=1 fi -# default to success -exit 0 \ No newline at end of file +# exit with stored code +exit $exit_code \ No newline at end of file -- GitLab From fe61db78898a62141e6e65478f16ce693080a654 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Wed, 20 Jan 2021 17:57:10 -0700 Subject: [PATCH 22/24] Changed ggrep to grep --- scripts/lint_version.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 34c63c39be..e619551db1 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # obtain the default chart version -chart_default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'version: \K(.*)') +chart_default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -10,7 +10,7 @@ if [ $? -ne 0 ]; then fi # obtain the local chart version -chart_local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') +chart_local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -19,7 +19,7 @@ if [ $? -ne 0 ]; then fi # obtain the default base git repository tag -basegit_default_tag=$(git show origin/${CI_DEFAULT_BRANCH}:${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') +basegit_default_tag=$(git show origin/${CI_DEFAULT_BRANCH}:${BASEGIT_FILE} | grep -oP 'tag: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -28,7 +28,7 @@ if [ $? -ne 0 ]; then fi # obtain the local base git repository tag -basegit_local_tag=$(cat ${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') +basegit_local_tag=$(cat ${BASEGIT_FILE} | grep -oP 'tag: \K(.*)') # check for command error if [ $? -ne 0 ]; then -- GitLab From 2a102c70c4fea51e8ec9884876475f245c5f4f88 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Wed, 20 Jan 2021 18:00:24 -0700 Subject: [PATCH 23/24] Formatting --- scripts/lint_version.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index e619551db1..5d8f2cd52d 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -37,8 +37,8 @@ if [ $? -ne 0 ]; then fi # debug print -echo "Default chart version: $chart_default_version" -echo "Local chart version: $chart_local_version" +echo "Default branch chart version (${CHART_FILE}): $chart_default_version" +echo "Local branch chart version (${CHART_FILE}): $chart_local_version" # assume success exit_code=0 @@ -49,14 +49,14 @@ if [[ "$chart_default_version" == "$chart_local_version" ]]; then exit_code=1 fi -echo "--" +echo "--------------------------------------------------------" -echo "Default base git repository version: $basegit_default_tag" -echo "Local base git repository version: $basegit_local_tag" +echo "Default branch base git repository version (${BASEGIT_FILE}): $basegit_default_tag" +echo "Local branch base git repository version (${BASEGIT_FILE}): $basegit_local_tag" # error if the versions are not different if [[ "$chart_default_version" == "$chart_local_version" ]]; then - echo "The tag has not been updated in ${CHART_FILE}, please update this file" + echo "The tag has not been updated in ${BASEGIT_FILE}, please update this file" exit_code=1 fi -- GitLab From 0e6b3bd99e2b51fcf832ce7ae61f764e2db0b485 Mon Sep 17 00:00:00 2001 From: Zachariah Dzielinski <dzielinski_zachariah@bah.com> Date: Wed, 20 Jan 2021 18:16:22 -0700 Subject: [PATCH 24/24] Formatting --- scripts/lint_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 5d8f2cd52d..4d5d53f3c3 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -51,8 +51,8 @@ fi echo "--------------------------------------------------------" -echo "Default branch base git repository version (${BASEGIT_FILE}): $basegit_default_tag" -echo "Local branch base git repository version (${BASEGIT_FILE}): $basegit_local_tag" +echo "Default branch base git repository tag (${BASEGIT_FILE}): $basegit_default_tag" +echo "Local branch base git repository tag (${BASEGIT_FILE}): $basegit_local_tag" # error if the versions are not different if [[ "$chart_default_version" == "$chart_local_version" ]]; then -- GitLab