From 139d57ef620803b0df56421ade9dfa13507fa5aa Mon Sep 17 00:00:00 2001 From: Vicente Cheng Date: Fri, 27 Sep 2024 01:05:03 +0800 Subject: [PATCH] ci: make sure the if-condition works Signed-off-by: Vicente Cheng (cherry picked from commit 78e0d91590162ae82ebf8457f691f090afa8196a) --- .github/workflows/basic-ci.yaml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/basic-ci.yaml b/.github/workflows/basic-ci.yaml index 55bf4b49..908df020 100644 --- a/.github/workflows/basic-ci.yaml +++ b/.github/workflows/basic-ci.yaml @@ -11,6 +11,7 @@ on: env: LIBVIRT_DEFAULT_URI: "qemu:///system" + VM_DEPLOYED: false jobs: validation: @@ -46,6 +47,7 @@ jobs: pushd ndm-vagrant-k3s yq e -i ".cluster_size = 1" settings.yaml ./new-cluster.sh + echo "VM_DEPLOYED=true" >> "$GITHUB_ENV" yq e -i ".longhorn_version = \"1.7.1\"" settings.yaml ./scripts/deploy_longhorn.sh cp ../ci/scripts/deploy_ndm.sh ./deploy_ndm.sh @@ -78,12 +80,20 @@ jobs: echo Running integration tests NDM_HOME=`pwd` go test -v ./tests/... - name: "Get NDM logs" - if: steps.vm_deploy.conclusion == 'success' + if: always() run: | + if [ ${{ env.VM_DEPLOYED }} != 'true' ]; then + echo "VM is not deployed, skip getting logs" + exit 0 + fi ./ci/scripts/get-debug-info.sh - name: "Tear Down / Cleanup" - if: steps.vm_deploy.conclusion == 'success' + if: always() run: | + if [ ${{ env.VM_DEPLOYED }} != 'true' ]; then + echo "VM is not deployed, skip VM destroy" + exit 0 + fi pushd ndm-vagrant-k3s vagrant destroy -f --parallel popd