From 17eb0d8a605b11a8246c73e0e8fe8da07bcfb6a4 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sun, 7 Feb 2021 17:40:59 -0800 Subject: [PATCH] [ci]: 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 3e84bb2b37c..7a836765d7e 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 06b46dbaccd..409af73da12 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"