From c96592fc0ad6efb4c28d3e97f45ca4e97621ba3a Mon Sep 17 00:00:00 2001 From: Simon Stier <52674635+simontaurus@users.noreply.github.com> Date: Sat, 16 Dec 2023 05:27:54 +0100 Subject: [PATCH] feat: add precheck if any test exists --- .github/workflows/redirect_tests.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/redirect_tests.yml b/.github/workflows/redirect_tests.yml index 76c1443b6..ddb19e8be 100644 --- a/.github/workflows/redirect_tests.yml +++ b/.github/workflows/redirect_tests.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: inputs: search_path: - description: "Subpath to test, e.g. '/osw' ('/*' = all subpaths)" + description: "Subpath(s) to test, e.g. '/osw;/emmo;/pmd' ('/*' = all subpaths)" default: '/*' pull_request: @@ -17,13 +17,21 @@ jobs: with: fetch-depth: 0 + - name: Check if at least one test exists + id: precheck + continue-on-error: true # if 'false' the whole workflow will fail if no test was defined + run: find $(IFS=';' read -ra paths <<< "${{ github.event.inputs.search_path }}"; for path in "${paths[@]}"; do echo ".$path "; done) -type f -name ".htaccess" -print0 | xargs -0 grep "##TEST" + - name: Run apache docker - run: docker run -dit --name apache -e SEARCH_PATH=${{ github.event.inputs.search_path }} -v "$PWD":/usr/local/apache2/htdocs/ -v "$PWD"/.test/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf httpd:2.4 + if: steps.precheck.outcome == 'success' + run: docker run -dit --name apache -e SEARCH_PATH="${{ github.event.inputs.search_path }}" -v "$PWD":/usr/local/apache2/htdocs/ -v "$PWD"/.test/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf httpd:2.4 - name: Install curl + if: steps.precheck.outcome == 'success' run: docker exec -i apache sh -c "apt-get update && apt-get install curl" - name: Run tests + if: steps.precheck.outcome == 'success' run: docker exec -i apache bash < .test/test.sh pull_request_test: @@ -52,12 +60,20 @@ jobs: done echo "SEARCH_PATH=$paths" >> $GITHUB_ENV echo "set SEARCH_PATH to $SEARCH_PATH" + + - name: Check if at least one test exists + id: precheck + continue-on-error: true # if 'false' the whole workflow will fail if no test was defined + run: find $(IFS=';' read -ra paths <<< "$SEARCH_PATH"; for path in "${paths[@]}"; do echo ".$path "; done) -type f -name ".htaccess" -print0 | xargs -0 grep "##TEST" - name: Run apache docker + if: steps.precheck.outcome == 'success' run: docker run -dit --name apache -e SEARCH_PATH="$SEARCH_PATH" -v "$PWD":/usr/local/apache2/htdocs/ -v "$PWD"/.test/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf httpd:2.4 - name: Install curl + if: steps.precheck.outcome == 'success' run: docker exec -i apache sh -c "apt-get update && apt-get install curl" - name: Run tests + if: steps.precheck.outcome == 'success' run: docker exec -i apache bash < .test/test.sh