Skip to content

Commit

Permalink
Merge pull request #1344 from cfengine/ENT-10989/master
Browse files Browse the repository at this point in the history
ENT-10989: Gather install logs in deployment-test if package fails to install
  • Loading branch information
craigcomstock authored Dec 15, 2023
2 parents 26522a5 + 8d21263 commit fac1ff4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deployment-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions ci/deployment-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down

0 comments on commit fac1ff4

Please sign in to comment.