UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
Commit 3a269784 authored by Zachariah Dzielinski's avatar Zachariah Dzielinski
Browse files

ci: added linting for changelog and version

parent 471f7971
No related branches found
No related tags found
1 merge request!158Linting for changelog and version
Pipeline #136042 failed
......@@ -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
......
File moved
#!/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
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment