From 9b61177992cfbfd51652fe142d6ceabfb1901041 Mon Sep 17 00:00:00 2001 From: Alexander Peretyatko Date: Thu, 10 Aug 2023 16:06:59 +0700 Subject: [PATCH] Task/40 'Permission tests' job runs even if there aren't tests require permission in the repo Signed-off-by: Alexander Peretyatko --- .github/workflows/build-and-test.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 7f8dbf5..10f9142 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -27,8 +27,11 @@ jobs: - name: Test with permissions if: ${{ !contains(matrix.os, 'windows') }} run: | - count=$(go test ./... --list Perm -tags perm | grep Perm | wc -l) - echo $count - if [ $count -gt 0 ]; then + count=0 + while read -r line ; do + [ -n "$(grep -l "Perm" $line)" ] && count=1 && break + done < <(grep -R "build perm" --include="*_test.go" -l .) + if [ $count == 1 ]; then + echo "Found tests with permissions" sudo -E PATH="$PATH" bash -c "go test -race -run Perm ./... -tags=perm" fi