From 536c342600c2dee905e35a7b016942b04c59cef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Tue, 15 Mar 2022 11:15:39 -0300 Subject: [PATCH] Add support for changing working directory This is useful when testing standalone .sol files which may need Echidna to be run from a specific folder in the solution. --- README.md | 1 + action.yml | 4 ++++ entrypoint.sh | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/README.md b/README.md index c17af0b..f840ca6 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ pages](https://github.com/crytic/echidna/wiki). | `output-file` | Capture echidna-test's output into a file. The path must be relative to the repository root. | `echidna-version` | Version of the Echidna Docker image to use. | `negate-exit-status` | Apply logical NOT to echidna-test's exit status (for testing the action). +| `echidna-workdir` | Path to run echidna-test from. Note that `files` and `config` are relative to this path. ## Outputs diff --git a/action.yml b/action.yml index 4d421e5..f28de30 100644 --- a/action.yml +++ b/action.yml @@ -68,6 +68,9 @@ inputs: description: "Version of the Echidna Docker image to use" required: false default: latest + echidna-workdir: + description: "Path to run echidna-test from. Note that `files` and `config` are relative to this path" + required: false outputs: output-file: @@ -108,3 +111,4 @@ runs: INPUT_SOLC-VERSION: ${{ inputs.solc-version }} INPUT_OUTPUT-FILE: ${{ inputs.output-file }} INPUT_NEGATE-EXIT-STATUS: ${{ inputs.negate-exit-status }} + INPUT_ECHIDNA-WORKDIR: ${{ inputs.echidna-workdir }} diff --git a/entrypoint.sh b/entrypoint.sh index 5385b43..07a8d97 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -47,6 +47,11 @@ if [[ -n "$OUTPUT_FILE" ]]; then exec > >(tee "$OUTPUT_FILE") fi +WORKDIR="$(get 'INPUT_ECHIDNA-WORKDIR')" +if [[ -n "$WORKDIR" ]]; then + cd "$WORKDIR" +fi + if [[ -n "$(get 'INPUT_NEGATE-EXIT-STATUS')" ]]; then ! "${CMD[@]}" else