Skip to content

Commit

Permalink
Expands cleanup action to handle dev VMs
Browse files Browse the repository at this point in the history
More comprehensive "make clean" behavior, including removal of:

  * Vagrant VMs
  * Molecule VMs
  * temporary git repos cloned by Molecule (for upgrade testing)
  * git-clean even gitignored directories

The output is fairly verbose, so it's obvious to the developer what's
been changed in the environment.
  • Loading branch information
Conor Schaefer committed Jun 28, 2018
1 parent 3ceaddb commit 1c12363
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions devops/clean
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,33 @@ function remove_unwanted_files() {
install_files/ansible-base/mon-ssh-aths \
build/*.deb

# Remove extraneous copies of the git repos, pulled in
# via the Molecule upgrade testing scenario.
rm -rf molecule/upgrade/.molecule/sd-orig \
molecule/vagrant_packager/.molecule/sd-orig

# Python bytecode, left over from tests or local app runs.
find -type f -iname '*.pyc' -delete
find "$PWD" -type f -iname '*.pyc' -delete

# Ansible playbook retry files, which are never used.
find -type f -iname '*.retry' -delete
find "$PWD" -type f -iname '*.retry' -delete

# Static assests generated by local dev, as well as
# virtualenv for securedrop-admin script.
rm -rvf securedrop/static/.webassets-cache .venv

# Any and all git-ignored files, if present. Includes e.g.
# deb packages in build/
git clean -f -x
# Any Vagrant VMs should be destroyed. We check for the .vagrant/
# directory, because it'll be created by vagrant otherwise, breaking
# idempotence for the cleanup action.
if hash vagrant &> /dev/null && [[ -d .vagrant/ ]]
then
printf "Removing vagrant VMs\\n"
vagrant destroy -f > /dev/null
fi

# Any and all git-ignored files and directories, if present. Includes e.g.
# deb packages in build/, and VM information stored locally.
git clean -x -d -f
}


Expand All @@ -42,7 +56,6 @@ WARNING_MESSAGE
# We want to avoid mistakes here, so force developers
# to type 'yes' in order to confirm and proceed with cleanup.
read -r -p "To proceed, type 'yes': " user_confirmation
printf "\\n"
case "${user_confirmation}" in
yes ) remove_unwanted_files;;
* ) printf "Action declined, exiting...\\n"
Expand Down

0 comments on commit 1c12363

Please sign in to comment.