Skip to content

Commit

Permalink
Merge pull request #76 from h0tw1r3/improve-smoke-test
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbreen28 authored Feb 21, 2024
2 parents 60f589d + 59d393c commit f383d74
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ on:
description: push to registry (default branch only)
type: boolean
default: true
provision_task:
description: provision task (docker or docker_exp)
type: string
default: "docker"
puppet_litmus:
description: gem options (JSON Hash)
type: string
Expand All @@ -46,5 +50,6 @@ jobs:
dockerfile: ${{ inputs.dockerfile }}
refresh: ${{ inputs.refresh == true }}
push: ${{ inputs.push == true }}
provision_task: ${{ inputs.provision_task }}
puppet_litmus: ${{ inputs.puppet_litmus }}
provision_module: ${{ inputs.provision_module }}
11 changes: 10 additions & 1 deletion .github/workflows/template_build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ on:
push:
type: boolean
default: true
provision_task:
default: "docker"
type: string
puppet_litmus:
default: ""
type: string
provision_module:
default: ""
type: string


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -56,6 +60,8 @@ jobs:
case key
when %r{puppet_litmus|provision_module}
!valid_json?(val) || val.match?(%r{[();]})
when 'provision_task'
!/^docker(_exp)?$/.match?(val)
end
end
inputs.each do |key, value|
Expand Down Expand Up @@ -219,9 +225,12 @@ jobs:
bundle exec bolt module show
echo ::endgroup::
echo ::group::rake listmus:provision
bundle exec rake litmus:provision[docker,${IMAGE_TAG}]
bundle exec rake litmus:provision[${{ inputs.provision_task }},${IMAGE_TAG}]
echo ::endgroup::
echo "testing bolt command"
bundle exec bolt command run 'last' -t all
echo "testing bolt task"
bundle exec bolt task run litmusimage::smoke -t all
# Previous step should always continue on error
# so docker logs will be added to the output
Expand Down
9 changes: 9 additions & 0 deletions tests/smoke/tasks/smoke.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"supports_noop": false,
"description": "Very simple smoke test",
"parameters": { },
"input_method": "environment",
"implementations": [
{ "name": "smoke.sh", "requirements": [ "shell" ] }
]
}
28 changes: 28 additions & 0 deletions tests/smoke/tasks/smoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -o pipefail -o errtrace -o errexit -o nounset -o functrace

traperror() {
local el=${1:=??} ec=${2:=??} lc="$BASH_COMMAND"
errorexit "ERROR in $(basename $0) : $el error $ec : $lc" ${2:=1}
}
trap 'traperror ${LINENO} ${?}' ERR

errorexit() {
echo >&2 $1
if [ -z ${2+x} ] ; then
exit 1
else
exit $2
fi
}

main() {
if [[ $(id -un) != 'root' ]]; then
errorexit "must be root" 1
fi

echo "ipsum lorem success"
}

main "$@"

0 comments on commit f383d74

Please sign in to comment.