From ef2c71caa1f3299f6ebb412c81c57a26aae6908a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 23 Oct 2024 20:27:44 +0200 Subject: [PATCH 1/3] Fix discovering executable files on macOS macOS has BSD version of the find utility, which doesn't support the `-perm /111` expression, but it does support `-perm +111` (which the GNU version has since deprecated). --- .github/workflows/scandir.yml | 10 +++++++--- action.yaml | 6 +++++- testfiles/scandir/exec | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100755 testfiles/scandir/exec diff --git a/.github/workflows/scandir.yml b/.github/workflows/scandir.yml index c971c91..e43a7f7 100644 --- a/.github/workflows/scandir.yml +++ b/.github/workflows/scandir.yml @@ -31,11 +31,15 @@ jobs: - name: Verify check run: | - expect="testfiles/scandir/run[[:space:]]me.bash" + expect1="testfiles/scandir/run[[:space:]]me.bash" + expect2="testfiles/scandir/exec" notexpect="testfiles/test.bash" - if [[ ! "${{ steps.one.outputs.files }}" =~ $expect ]];then - echo "::error:: Expected file $expect not found in ${{ steps.one.outputs.files }}" + if [[ ! "${{ steps.one.outputs.files }}" =~ $expect1 ]];then + echo "::error:: Expected file $expect1 not found in ${{ steps.one.outputs.files }}" + exit 1 + if [[ ! "${{ steps.one.outputs.files }}" =~ $expect2 ]];then + echo "::error:: Expected file $expect2 not found in ${{ steps.one.outputs.files }}" exit 1 elif [[ "${{ steps.one.outputs.files }}" =~ $notexpect ]];then echo "::error:: Expected file $notexpect found in ${{ steps.one.outputs.files }}" diff --git a/action.yaml b/action.yaml index 130781e..e46c41c 100644 --- a/action.yaml +++ b/action.yaml @@ -195,12 +195,16 @@ runs: ')' \ -print0) + perm_executable="/111" + # BSD find on macOS does not support the slash syntax for permissions. + [ "$(uname -s)" = "Darwin" ] && perm_executable="+111" + while IFS= read -r -d '' file; do head -n1 "$file" | grep -Eqs "$shebangregex" || continue filepaths+=("$file") done < <(find "${INPUT_SCANDIR}" \ ${INPUT_EXCLUDE_ARGS} \ - -type f ! -name '*.*' -perm /111 \ + -type f ! -name '*.*' -perm "$perm_executable" \ -print0) if [[ -n "${INPUT_CHECK_TOGETHER}" ]]; then diff --git a/testfiles/scandir/exec b/testfiles/scandir/exec new file mode 100755 index 0000000..807a675 --- /dev/null +++ b/testfiles/scandir/exec @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echo "I am executable" \ No newline at end of file From 8b8bcee750d939e2d093f99b5b2a28e296acfa57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 24 Oct 2024 18:37:53 +0200 Subject: [PATCH 2/3] Fix test for macOS executable discovery --- .github/workflows/scandir.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scandir.yml b/.github/workflows/scandir.yml index e43a7f7..923e1ef 100644 --- a/.github/workflows/scandir.yml +++ b/.github/workflows/scandir.yml @@ -38,7 +38,7 @@ jobs: if [[ ! "${{ steps.one.outputs.files }}" =~ $expect1 ]];then echo "::error:: Expected file $expect1 not found in ${{ steps.one.outputs.files }}" exit 1 - if [[ ! "${{ steps.one.outputs.files }}" =~ $expect2 ]];then + elif [[ ! "${{ steps.one.outputs.files }}" =~ $expect2 ]];then echo "::error:: Expected file $expect2 not found in ${{ steps.one.outputs.files }}" exit 1 elif [[ "${{ steps.one.outputs.files }}" =~ $notexpect ]];then From f6ecd046182d32eddcfa773236704d943ada2ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 24 Oct 2024 18:43:48 +0200 Subject: [PATCH 3/3] Add newline to the end of test file --- testfiles/scandir/exec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testfiles/scandir/exec b/testfiles/scandir/exec index 807a675..d117d69 100755 --- a/testfiles/scandir/exec +++ b/testfiles/scandir/exec @@ -1,3 +1,3 @@ #!/usr/bin/env bash -echo "I am executable" \ No newline at end of file +echo "I am executable"