From c6a5c8658004d46b63b89be3cdb71662d84f38d3 Mon Sep 17 00:00:00 2001 From: Ioannis Filippidis Date: Fri, 17 Jun 2022 15:58:33 +0200 Subject: [PATCH] BUG: rm quotes (`'`) from around env-var values because GitHub Actions inserts the quotes in the values of the environment variables that are created from the assignments that are printed by the script `setup_shell_env.py`. For example, the line in the file `release.yml`: ```yaml asset_path: tools/installer/${{ env.INSTALLER }} ``` results, when interpreted by GitHub Actions, in the value: ``` asset_path: tools/installer/'tlaps-1.5.0-x86_64-linux-gnu-inst.bin' ``` which raises in CI the error: ``` Error: ENOENT: no such file or directory, stat 'tools/installer/'tlaps-1.5.0-x86_64-linux-gnu-inst.bin'' ``` --- .github/workflows/setup_shell_env.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/setup_shell_env.py b/.github/workflows/setup_shell_env.py index 64351e86..1eacbf9d 100644 --- a/.github/workflows/setup_shell_env.py +++ b/.github/workflows/setup_shell_env.py @@ -38,10 +38,21 @@ def _make_shell_definitions(kv: dict) -> str: `kv=dict(NAME='value')`, returns the string`"NAME='value'"`. """ + any_blanks = any(map( + _contains_blanks, + kv.values())) + if any_blanks: + raise ValueError(kv) return '\n'.join( - f"{name}='{value}'" + f'{name}={value}' for name, value in kv.items()) +def _contains_blanks(value: str) -> bool: + """Return `True` if blankspace in `value`.""" + value_ = ''.join(value.split()) + return len(value) != len(value_) + + if __name__ == '__main__': _main()