Skip to content

Commit

Permalink
Merge pull request #1034 from gburges/prepush
Browse files Browse the repository at this point in the history
feat: Add prepush precommit hook so if we forget to make pre-push we get wa…
  • Loading branch information
psav authored Aug 30, 2024
2 parents 8267bf5 + 21685ab commit ae50501
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ pipeline {
}

stages {
stage('Did you run pre-push?') {
environment {
TEST_CONTAINER="clowder-ci-prepush-test-${IMAGE_TAG}-${CURR_TIME}"
}
steps {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
docker login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
docker build -f Dockerfile.test --build-arg BASE_IMAGE=${BASE_IMG} -t $TEST_CONTAINER .
docker run -i $TEST_CONTAINER \
./githooks/prepush.sh
'''
}
}

post {
always {
sh 'docker rm -f $TEST_CONTAINER'
}
}
}

stage('Build and Push Base Image') {
steps {
withVault([configuration: configuration, vaultSecrets: secrets]) {
Expand Down
13 changes: 13 additions & 0 deletions githooks/prepush.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

function prepush() {
make pre-push

# If the make command failed, prevent the push
if [[ -n "$(git status -s)" ]]; then
echo "ERROR: Please run 'make pre-push', then 'git add' any changes, and then 'git push' a new commit."
exit 1
fi
}

prepush
7 changes: 7 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ if [ $? != "0" ]; then
pip3 install --user --upgrade crc-bonfire
fi

# Install git precommit hook
HOOKDIR=".git/hooks"
mkdir -p "$HOOKDIR"
cp -r githooks/* "$HOOKDIR/"
chmod +x "$HOOKDIR/"*
echo "Githooks installed"

# Start minikube based on specs
minikube status 2>/dev/null >/dev/null
if [ $? != "0" ]; then
Expand Down

0 comments on commit ae50501

Please sign in to comment.