UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
Commit 9c5a5436 authored by runyontr's avatar runyontr Committed by joshwolf
Browse files

ci: remove scripts and documentation supporting/enforcing conventional commit standards

parent 98312f85
No related branches found
No related tags found
1 merge request!285Remove more scripts supporting conventional commit standards
......@@ -65,7 +65,6 @@ pre vars:
- git fetch && git checkout ${CI_COMMIT_REF_NAME}
- echo "CHART_MR_VERSION=$CHART_MR_VERSION" >> variables.env
- echo "CHART_MA_VERSION=$CHART_MA_VERSION" >> variables.env
# obtain semver differences (subtract master version from mr verison)
- CHART_VERSION_DIFF=$(./scripts/semver_diff.sh $CHART_MR_VERSION $CHART_MA_VERSION)
- IFS=. DIFF_ARR=(${CHART_VERSION_DIFF##*-})
- echo "CHART_VERSION_DIFF=$CHART_VERSION_DIFF" >> variables.env
......
......@@ -33,51 +33,6 @@ Table of Contents:
Big Bang is designed in such a way as to be as easily deployed locally as it is in production. In fact, most contributions begin locally.
## Local Git Setup
### Pre-commit hooks
We would require developers to leverage [conventional commits](https://www.conventionalcommits.org/) when contributing.
In order to help enforce this we are leveraging client-side pre-commit hooks.
This is done using the following tools:
- [husky](https://www.npmjs.com/package/husky)
- [commitlint](https://commitlint.js.org/#/)
#### Local Setup
##### Prereqs
- Install [npm](https://www.npmjs.com/get-npm)
##### Steps
After cloning this git repo run the following command:
```bash
npm install --only=dev
```
This will download `husky` and `commitlint` to your local repo and modify your `.git/hooks` to allow husky to run pre-commit hooks. Once installed it will enforce the usage of convential-commits.
#### Combining Multiple Commits
If you have pushed commits that do not conform to the conventional-commit guide lines, you can combine all of the incorrectly formatted commit messages by using `git rebase`.
A more expansive guide of how this is done can be found [here](https://www.w3docs.com/snippets/git/how-to-combine-multiple-commits-into-one-with-3-steps.html).
Here is a quick tip to squash all commits for a branch named `test`:
```
git checkout test
git reset $(git merge-base origin/master $(git rev-parse --abbrev-ref HEAD))
git add -A
git commit -m "feat: example conventional commit"
git push --force
```
## Iron Bank Images
Per the [charter](https://repo1.dso.mil/platform-one/big-bang/charter), all Big Bang packages will leverage container images from [IronBank](https://ironbank.dso.mil/). In order to pull these images, ImagePullSecrets must be provided to BigBang. To obtain access to these images, follow the guides below. These steps should NOT be used for production since the API keys for a user are only valid when the user is logged into [Registry1](https://registry1.dso.mil)
......
module.exports = {extends: ['@commitlint/config-conventional']};
This diff is collapsed.
{
"name": "umbrella",
"description": "Big Bang is a declarative, continuous delivery tool for core DoD hardened and approved [packages](#packages) into a Kubernetes cluster. Big Bang follows a [GitOps](#gitops) approach to configuration management, using [Flux v2](#flux-v2) to reconcile Git with the cluster. Environments (e.g. dev, prod) and packages (e.g. istio) can be fully configured to suit the deployment needs.",
"repository": {
"type": "git",
"url": "https://repo1.dso.mil/platform-one/big-bang/bigbang.git"
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"husky": "^3.0.0"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}
......@@ -54,4 +54,4 @@ do
done
echo "Waiting on Secrets Kustomization"
kubectl wait --for=condition=Ready --timeout 120s kustomizations.kustomize.toolkit.fluxcd.io -n bigbang secrets
kubectl wait --for=condition=Ready --timeout 300s kustomizations.kustomize.toolkit.fluxcd.io -n bigbang secrets
#!/usr/bin/env bash
# diff the file silently, while still printing errors
git diff --exit-code origin/${CI_DEFAULT_BRANCH}:${CHANGELOG_FILE} ${CHANGELOG_FILE} >/dev/null
differr=$?
# exit code of 0 indicates non changed file
if [ $differr -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 [ $differr -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
# store failure
failure=false
# debug output
echo "Linting all commits between $CI_DEFAULT_BRANCH and $CI_COMMIT_REF_NAME"
echo "--------------------------------------------------------"
# loop over commit sha's for commits that exist in this branch but not the default branch
for sha in $(git log origin/$CI_DEFAULT_BRANCH..origin/$CI_COMMIT_REF_NAME --format=format:%H); do
# get the commit message from the sha
message=$(git log --format=format:%s -n 1 $sha)
# debug output sha and message
echo "Linting commit: $sha - $message"
# lint message and store possible failure
if ! echo "$message" | npx commitlint; then failure=true; fi
done
# if we have a failure
if $failure; then
# guide developer to resolution
echo "--------------------------------------------------------"
echo "You have commits that have failed linting because their content does not follow conventional standards"
echo "You must rebase, squash, or amend; and implement conventional standards on all commits for this branch"
echo "Commit standards guide - https://www.conventionalcommits.org/"
echo "--------------------------------------------------------"
echo "Quick tip - Squash commits for $CI_COMMIT_REF_NAME"
echo "> git checkout $CI_COMMIT_REF_NAME"
echo "> git reset \$(git merge-base $CI_DEFAULT_BRANCH \$(git rev-parse --abbrev-ref HEAD))"
echo "> git add -A"
echo "> git commit -m \"feat: example conventional commit\""
echo "> git push --force"
exit 1
fi
\ No newline at end of file
#!/usr/bin/env bash
# obtain the default chart version
chart_default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)')
# check for command error
if [ $? -ne 0 ]; then
echo "Error: An unknown error has occurred while attempting to retrieve the default version from ${CHART_FILE}"
exit 1
fi
# obtain the local chart version
chart_local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)')
# check for command error
if [ $? -ne 0 ]; then
echo "Error: An unknown error has occurred while attempting to retrieve the local version from ${CHART_FILE}"
exit 1
fi
# obtain the default base git repository tag
basegit_default_tag=$(git show origin/${CI_DEFAULT_BRANCH}:${BASEGIT_FILE} | grep -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} | grep -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 branch chart version (${CHART_FILE}): $chart_default_version"
echo "Local branch chart version (${CHART_FILE}): $chart_local_version"
# assume success
exit_code=0
# error if the versions are not different
if [[ "$chart_default_version" == "$chart_local_version" ]]; then
echo "The version has not been updated in ${CHART_FILE}, please update this file"
exit_code=1
fi
echo "--------------------------------------------------------"
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
echo "The tag has not been updated in ${BASEGIT_FILE}, please update this file"
exit_code=1
fi
# exit with stored code
exit $exit_code
\ 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