Updating the Circle build to support branches with multiple commits
This commit is contained in:
@@ -11,43 +11,67 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: Check if Packer files were modified
|
name: Check if Packer files were modified
|
||||||
command: |
|
command: |
|
||||||
export COMMIT_ID="$(echo $CIRCLE_COMPARE_URL | cut -d '/' -f 7)"
|
## This handles the cases where there are multiple commits
|
||||||
if [ "$(git diff-tree --no-commit-id --name-only -r $COMMIT_ID | grep -c \"^Packer/\")" -gt 0 ]; then
|
if echo "$CIRCLE_COMPARE_URL" | grep '\.\.'; then
|
||||||
export PACKER_MODIFIED=1
|
if [ "$(git diff-tree --no-commit-id --name-only -r $(git rev-parse origin/HEAD) $(echo $CIRCLE_COMPARE_URL | cut -d '.' -f 5) | grep -c ^Packer/)" -gt 0 ]; then
|
||||||
|
export PACKER_MODIFIED=1
|
||||||
|
else
|
||||||
|
export PACKER_MODIFIED=0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
export PACKER_MODIFIED=0
|
## This handles the cases where there is only a single commit
|
||||||
|
export COMMIT_ID="$(echo $CIRCLE_COMPARE_URL | cut -d '/' -f 7)"
|
||||||
|
if [ "$(git diff-tree --no-commit-id --name-only -r $COMMIT_ID | grep -c ^Packer/)" -gt 0 ]; then
|
||||||
|
export PACKER_MODIFIED=1
|
||||||
|
else
|
||||||
|
export PACKER_MODIFIED=0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo "PACKER_MODIFIED=$PACKER_MODIFIED"
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Check if Vagrant files were modified
|
name: Check if Vagrant files were modified
|
||||||
command: |
|
command: |
|
||||||
export COMMIT_ID="$(echo $CIRCLE_COMPARE_URL | cut -d '/' -f 7)"
|
if echo "$CIRCLE_COMPARE_URL" | grep '\.\.'; then
|
||||||
if [ "$(git diff-tree --no-commit-id --name-only -r $COMMIT_ID | grep -c \"^Vagrant/\")" -gt 0 ]; then
|
if [ "$(git diff-tree --no-commit-id --name-only -r $(git rev-parse origin/HEAD) $(echo $CIRCLE_COMPARE_URL | cut -d '.' -f 5) | grep -c ^Vagrant/)" -gt 0 ]; then
|
||||||
export VAGRANT_MODIFIED=1
|
export VAGRANT_MODIFIED=1
|
||||||
|
else
|
||||||
|
export VAGRANT_MODIFIED=0
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
export VAGRANT_MODIFIED=0
|
export COMMIT_ID="$(echo $CIRCLE_COMPARE_URL | cut -d '/' -f 7)"
|
||||||
|
if [ "$(git diff-tree --no-commit-id --name-only -r $COMMIT_ID | grep -c \"^Vagrant/\")" -gt 0 ]; then
|
||||||
|
export VAGRANT_MODIFIED=1
|
||||||
|
else
|
||||||
|
export VAGRANT_MODIFIED=0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo "VAGRANT_MODIFIED=$VAGRANT_MODIFIED"
|
||||||
|
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Choose which build gets run
|
name: Choose which build gets run
|
||||||
command: |
|
command: |
|
||||||
if [[ "$PACKER_MODIFIED" -eq 1 ]] && [[ "$VAGRANT_MODIFIED" -eq 1 ]]; then
|
if [[ "$PACKER_MODIFIED" -eq 1 ]] && [[ "$VAGRANT_MODIFIED" -eq 1 ]]; then
|
||||||
|
echo "Running the test suite for Packer and Vagrant changes"
|
||||||
chmod +x ci/circle_workflows/packer_and_vagrant_changes.sh
|
chmod +x ci/circle_workflows/packer_and_vagrant_changes.sh
|
||||||
ci/circle_workflows/packer_and_vagrant_changes.sh
|
ci/circle_workflows/packer_and_vagrant_changes.sh
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [[ "$PACKER_MODIFIED" -eq 1 ]] && [[ "$VAGRANT_MODIFIED" -eq 1 ]]; then
|
if [[ "$PACKER_MODIFIED" -eq 1 ]] && [[ "$VAGRANT_MODIFIED" -eq 1 ]]; then
|
||||||
|
echo "Running the default test suite (Vagrant-only)"
|
||||||
chmod +x ci/circle_workflows/vagrant_changes.sh
|
chmod +x ci/circle_workflows/vagrant_changes.sh
|
||||||
ci/circle_workflows/vagrant_changes.sh
|
ci/circle_workflows/vagrant_changes.sh
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ "$PACKER_MODIFIED" -eq 1 ]; then
|
if [ "$PACKER_MODIFIED" -eq 1 ]; then
|
||||||
|
echo "Running the test suite for Packer-only changes"
|
||||||
chmod +x ci/circle_workflows/packer_changes.sh
|
chmod +x ci/circle_workflows/packer_changes.sh
|
||||||
ci/circle_workflows/packer_changes.sh
|
ci/circle_workflows/packer_changes.sh
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ "$VAGRANT_MODIFIED" -eq 1 ]; then
|
if [ "$VAGRANT_MODIFIED" -eq 1 ]; then
|
||||||
|
echo "Running the test suite for Vagrant-only changes"
|
||||||
chmod +x ci/circle_workflows/vagrant_changes.sh
|
chmod +x ci/circle_workflows/vagrant_changes.sh
|
||||||
ci/circle_workflows/vagrant_changes.sh
|
ci/circle_workflows/vagrant_changes.sh
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user