From 1c12363afc75a3672a0e66e71250d612846487fa Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Wed, 20 Jun 2018 13:38:47 -0700 Subject: [PATCH] Expands cleanup action to handle dev VMs 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. --- devops/clean | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/devops/clean b/devops/clean index 8e3924e85a..6ccdbb8ff6 100755 --- a/devops/clean +++ b/devops/clean @@ -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 } @@ -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"