From d843d6ed1235f3e8f912893f93457a6f0657ec02 Mon Sep 17 00:00:00 2001 From: lguohan Date: Mon, 8 Feb 2021 08:06:36 -0800 Subject: [PATCH] [ci]: restructure repo clean up to make it robust (#6716) restructure repo clean up to make it robust Signed-off-by: Guohan Lu --- .azure-pipelines/build-template.yml | 9 ++++++++- .azure-pipelines/cleanup.yml | 17 +++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.azure-pipelines/build-template.yml b/.azure-pipelines/build-template.yml index 3e84bb2b37c1..7a836765d7e8 100644 --- a/.azure-pipelines/build-template.yml +++ b/.azure-pipelines/build-template.yml @@ -61,10 +61,17 @@ jobs: displayName: ${{ parameters.platform }} timeoutInMinutes: ${{ parameters.timeout }} steps: + - template: cleanup.yml - checkout: self + clean: true submodules: recursive displayName: 'Checkout code' - - template: cleanup.yml + - script: | + git submodule foreach --recursive 'git clean -xfdf || true' + git submodule foreach --recursive 'git reset --hard || true' + git submodule foreach --recursive 'git remote update || true' + git submodule update --init --recursive + displayName: 'Reset submodules' - script: | set -e sudo modprobe overlay diff --git a/.azure-pipelines/cleanup.yml b/.azure-pipelines/cleanup.yml index 06b46dbaccd6..409af73da123 100644 --- a/.azure-pipelines/cleanup.yml +++ b/.azure-pipelines/cleanup.yml @@ -1,18 +1,15 @@ steps: - script: | - sudo kill -9 `sudo cat /var/run/march/docker.pid` || true - sudo rm -f /var/run/march/docker.pid || true - sudo rm -rf fsroot || true - git clean -xfdf || true - git reset --hard || true - git submodule foreach --recursive 'git clean -xfdf || true' || true - git submodule foreach --recursive 'git reset --hard || true' || true - git submodule foreach --recursive 'git remote update || true' || true - git submodule update --init --recursive || true + if sudo [ -f /var/run/march/docker.pid ] ; then + pid=`sudo cat /var/run/march/docker.pid` ; sudo kill $pid + fi + sudo rm -f /var/run/march/docker.pid + sudo rm -rf /data/march/docker # clean native docker build if sudo [ -f dockerfs/var/run/docker.pid ] ; then pid=`sudo cat dockerfs/var/run/docker.pid` ; sudo kill $pid fi - sudo rm -rf /data/march/docker + sudo rm -rf dockerfs + sudo rm -rf fsroot displayName: "Clean Workspace"