From 518606f95a1ff81b12b905b46dc4640fe3fa22aa Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Tue, 11 May 2021 08:57:41 +0200 Subject: [PATCH] add working_directory option --- .github/workflows/test.yml | 10 ++++++++++ README.md | 3 +++ action.yml | 3 +++ entrypoint.sh | 19 +++++++++++++++++-- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fac66e2..96dfa74 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,16 @@ jobs: uses: ./ with: src: tests/src + test-with-working-directory: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: Run unit tests + uses: ./ + with: + working_directory: tests + src: src test-with-ext-arg: runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index aecb9d2..e8890e6 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,8 @@ To use your test data along with Octave packages, you can see [this example conf ## Arguments +All file and directory paths are interpreted as relative to the working directory, which defaults to the Github Workspace. Optionally, the working-directory can be changed with the argument `working_directory`, see below. + | Input | Description | Usage | | - | - | - | | `tests` | files or directories containing the MOxUnit test cases | *Optional*, defaults to the root directory of the repo. All subdirectories are added recursively. | @@ -95,3 +97,4 @@ To use your test data along with Octave packages, you can see [this example conf | `cover_html_dir` | store coverage HTML output in directory | *Optional* | | `cover_junit_xml_file` | store test results in junit XML file | *Optional* | | `cover_json_file` | store coverage report in json file for processing by coveralls.io | *Optional* | +| `working_directory` | relative path to a working directory under the github workspace, defaults to `.`. | *Optional* | \ No newline at end of file diff --git a/action.yml b/action.yml index 131036d..967f9f7 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,8 @@ inputs: description: 'list of Octave packages to load (image, io, optim, parallel, statistics, struct)' ext: description: 'other directories e.g. external dependencies' + working_directory: + description: 'relative path to an optional working directory under the github workspace' runs: using: 'docker' @@ -43,6 +45,7 @@ runs: - ${{ inputs.data }} - ${{ inputs.pkg }} - ${{ inputs.ext }} + - ${{ inputs.working_directory }} branding: icon: check-circle diff --git a/entrypoint.sh b/entrypoint.sh index 0ece071..c2e1f50 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -13,6 +13,21 @@ COVER_JSON_FILE=$9 DATA=$10 PKG=$11 EXT=$12 +WDIR=$13 + +#################### +# Switch directory # +#################### + + +if [ -z $WDIR ] ; then + WDIR="." +fi +cd $WDIR + +########################### +# Prepare Octave commands # +########################### # Create an Octave expression to set up the environment SETUP="" @@ -70,9 +85,9 @@ else SETUP="$SETUP $PKG_LIST pkg list;" fi -########################### +################## # Run unit tests # -########################### +################## # prepare test case argument if [ -z $TESTS ] ; then