From 515ef2a0b04a7d4eba9c2f3cd123ccf859078cb7 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Wed, 6 Dec 2023 09:42:37 -0600 Subject: [PATCH] Gather install logs in deployment-test if package fails to install Ticket: ENT-10989 Changelog: none (cherry picked from commit 8d21263e83bbf038080831d3265798dfdb0c9e70) --- .github/workflows/deployment-tests.yml | 2 +- ci/deployment-tests.sh | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/deployment-tests.yml b/.github/workflows/deployment-tests.yml index 3a18161fa..f6c56095e 100644 --- a/.github/workflows/deployment-tests.yml +++ b/.github/workflows/deployment-tests.yml @@ -133,7 +133,7 @@ jobs: key: packages-${{ env.PACKAGE_SHA }} - name: Save artifacts - if: ${{ success() || failure() && steps.build_package.conclusion != 'success' }} + if: success() || failure() uses: actions/upload-artifact@v3 with: name: artifacts diff --git a/ci/deployment-tests.sh b/ci/deployment-tests.sh index 4707a4dce..8efedc28d 100755 --- a/ci/deployment-tests.sh +++ b/ci/deployment-tests.sh @@ -11,22 +11,28 @@ COMPUTED_ROOT="$(readlink -e "$(dirname "$0")/../../")" NTECH_ROOT=${NTECH_ROOT:-$COMPUTED_ROOT} USER=${USER:-$(whoami)} -if [ ! -d /var/cfengine ]; then - # ci and local buildscripts should place built packages in $NTECH_ROOT/packages - sudo dpkg -i "$NTECH_ROOT"/packages/cfengine-nova-hub*deb -fi +# prepare artifacts dir +sudo mkdir -p "${NTECH_ROOT}/artifacts" +sudo chown "$USER" "${NTECH_ROOT}/artifacts" -# now that cfengine is probably installed, run cf-support if there is an error trap failure ERR - function failure() { - sudo mkdir -p "${NTECH_ROOT}/artifacts" - sudo chown "$USER" "${NTECH_ROOT}/artifacts" cd "${NTECH_ROOT}/artifacts" - sudo cf-support --yes > $$.cfsupportlog 2>&1 || cat $$.cfsupportlog + if command cf-support; then + sudo cf-support --yes > $$.cfsupportlog 2>&1 || cat $$.cfsupportlog + else + cp /var/log/CFEngine-Install* . # ${NTECH_ROOT}/artifacts cd previously + fi rm $$.cfsupportlog } +if [ ! -d /var/cfengine ]; then + # ci and local buildscripts should place built packages in $NTECH_ROOT/packages + sudo dpkg -i "$NTECH_ROOT"/packages/cfengine-nova-hub*deb +fi + + + AGENT_LOG="${NTECH_ROOT}/artifacts/agent.log" if [ -f "$AGENT_LOG" ]; then mv "$AGENT_LOG" "${AGENT_LOG}.$(date +%s)"