diff --git a/tests/examples.rs b/tests/examples.rs index 3a2b9ad..64e159b 100644 --- a/tests/examples.rs +++ b/tests/examples.rs @@ -42,3 +42,4 @@ macro_rules! example { example!(simple); example!(bigger); +example!(heroku_deploy); diff --git a/tests/examples/heroku_deploy/expected b/tests/examples/heroku_deploy/expected new file mode 100644 index 0000000..828a010 --- /dev/null +++ b/tests/examples/heroku_deploy/expected @@ -0,0 +1 @@ +All tests passed. diff --git a/tests/examples/heroku_deploy/script b/tests/examples/heroku_deploy/script new file mode 100755 index 0000000..d9e466a --- /dev/null +++ b/tests/examples/heroku_deploy/script @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +if [ -z "$1" ] ; then + echo please, pass in the heroku app as an argument 1>&2 + exit 1 +fi + +if [ -n "$(git status --porcelain)" ] && [ "$2" != "--force" ] ; then + echo exiting, git repo not clean 1>&2 + exit 1 +fi + +if ! cargo test ; then + echo exiting, tests don\'t pass 1>&2 + exit 1 +fi + +heroku container:push web --app "$1" +heroku container:release web --app "$1" diff --git a/tests/examples/heroku_deploy/script.test.yaml b/tests/examples/heroku_deploy/script.test.yaml new file mode 100644 index 0000000..929c741 --- /dev/null +++ b/tests/examples/heroku_deploy/script.test.yaml @@ -0,0 +1,39 @@ +tests: + # exits when the git repo is not clean + - arguments: test-heroku-app + steps: + - command: git status --porcelain + stdout: " M some-changed-file\n" + stderr: "exiting, git repo not clean\n" + exitcode: 1 + + # exits and prints a usage message when no arguments given + - steps: [] + stderr: "please, pass in the heroku app as an argument\n" + exitcode: 1 + + # exits when the tests don't pass + - arguments: test-heroku-app + steps: + - git status --porcelain + - command: cargo test + exitcode: 1 + stderr: "exiting, tests don't pass\n" + exitcode: 1 + + # builds and deploys to heroku + - arguments: test-heroku-app + steps: + - git status --porcelain + - cargo test + - heroku container:push web --app test-heroku-app + - heroku container:release web --app test-heroku-app + + # allows to force deploying of dirty git repo + - arguments: test-heroku-app --force + steps: + - command: git status --porcelain + stdout: " M some-changed-file\n" + - cargo test + - heroku container:push web --app test-heroku-app + - heroku container:release web --app test-heroku-app