-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from skx/7-allow-name-to-be-specified
Allow the script-name to be specified in the workflow file.
- Loading branch information
Showing
3 changed files
with
122 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,74 @@ | ||
#!/bin/bash | ||
# | ||
# The core of our action, it will be invoked with the name of the script | ||
# to execute - If the script doesn't exist then that is a fatal error. | ||
# | ||
# The script used to default to `.github/run-tests.sh`, but now the | ||
# name is passed as the first argument. | ||
# | ||
|
||
# | ||
# Terminate upon errors | ||
# | ||
set -e | ||
|
||
|
||
# | ||
# Get the name of the script to run. | ||
# | ||
script=$1 | ||
|
||
|
||
# | ||
# If the script is present .. | ||
# | ||
if [ -e .github/run-tests.sh ]; then | ||
|
||
# | ||
# Ensure it is executable. | ||
# | ||
chmod 755 .github/run-tests.sh | ||
|
||
# | ||
# Run it. | ||
# | ||
.github/run-tests.sh | ||
|
||
# | ||
# If the script exits with a non-zero status-code | ||
# then it will terminate this script due to the use | ||
# of `set -e`. | ||
# | ||
# So when we reach this point we know: | ||
# | ||
# 1. We've executed the test-script. | ||
# | ||
# 2. The test-script passed. | ||
# | ||
# Exit cleanly because we're done. | ||
# | ||
exit 0 | ||
# If the argument is empty that is a fatal error. | ||
# | ||
if [ -z "${script}" ]; then | ||
echo "You must specify the script to execute as an argument." | ||
exit 1 | ||
fi | ||
|
||
|
||
# | ||
# If the script does not exist that is a fatal-error. | ||
# | ||
if [ ! -e "${script}" ]; then | ||
echo "The supplied testing-script does not exist: ${script}" | ||
exit 1 | ||
fi | ||
|
||
|
||
# | ||
# Ensure the script is executable. | ||
# | ||
chmod 755 "${script}" | ||
|
||
|
||
# | ||
# Run it. | ||
# | ||
${script} | ||
|
||
|
||
# | ||
# If the script exits with a non-zero status-code | ||
# then it will terminate this script due to the use | ||
# of `set -e`. | ||
# | ||
# So when we reach this point we know: | ||
# | ||
# 1. We've executed the test-script. | ||
# | ||
# 2. The test-script passed. | ||
# | ||
# Exit cleanly because we're done. | ||
# | ||
exit 0 | ||
|
||
|
||
# | ||
# There is no test-script within the repository. | ||
# | ||
# Show that, and exit with a failure-code. | ||
# | ||
echo "The repository does not contain a test-script '.github/run-tests.sh'" | ||
exit 1 | ||
|