diff --git a/.github/workflows/test-working-directory.yml b/.github/workflows/test-working-directory.yml index 7d03f1494..f7c1e03f4 100644 --- a/.github/workflows/test-working-directory.yml +++ b/.github/workflows/test-working-directory.yml @@ -33,11 +33,10 @@ jobs: revision: HEAD - name: Check that test.py was not found + if: always() && steps.no-work-dir.outputs.exitcode != '2' run: | - if [ "${{ steps.no-work-dir.outputs.exitcode }}" != "2" ]; then - echo "::error::Darker should have failed with exit code 2" - exit 1 - fi + echo "::error::Darker should have failed with exit code 2" + exit 1 - name: Run Darker with correct working-directory id: right-workdir @@ -50,19 +49,17 @@ jobs: src: test.py revision: HEAD - - name: Verify file was reformatted - if: always() + - name: Verify exit code 1 when reformatting is needed + if: always() && steps.right-workdir.outputs.exitcode != '1' + run: | + echo "::error::Darker should have exited with code 1" + exit 1 + + - name: Verify diff output + if: always() && !contains(steps.right-workdir.outputs.stdout, '@@') run: | - if [ "${{ steps.right-workdir.outputs.exitcode }}" != "1" ]; then - echo "::error::Darker should have exited with code 1" - exit 1 - fi - if [[ "${{ steps.right-workdir.outputs.stdout }}" == *"@@"* ]]; then - echo "Darker correctly output a reformatting diff" - else - echo "::error::Darker did not output a diff as expected" - exit 1 - fi + echo "::error::Darker did not output a diff as expected" + exit 1 - name: Run Darker with incorrect working-directory (should not reformat) if: always() @@ -77,12 +74,10 @@ jobs: revision: HEAD - name: Check that Darker failed with a non-existing working-directory - if: always() + if: always() && steps.wrong-work-dir.outputs.exitcode != '21' run: | - if [ "${{ steps.wrong-work-dir.outputs.exitcode }}" != "21" ]; then - echo "::error::Darker should have exited with code 21" - exit 1 - fi + echo "::error::Darker should have exited with code 21" + exit 1 - name: Test file not found error id: file-not-found @@ -96,12 +91,10 @@ jobs: src: non_existent_file.py - name: Check file not found error code - if: always() + if: always() && steps.file-not-found.outputs.exitcode != '2' run: | - if [ "${{ steps.file-not-found.outputs.exitcode }}" != "2" ]; then - echo "::error::Darker should have exited with code 2" - exit 1 - fi + echo "::error::Darker should have exited with code 2" + exit 1 - name: Test invalid arguments error id: invalid-arguments @@ -113,12 +106,10 @@ jobs: options: --invalid-option - name: Check invalid arguments error code - if: always() + if: always() && steps.invalid-arguments.outputs.exitcode != '3' run: | - if [ "${{ steps.invalid-arguments.outputs.exitcode }}" != "3" ]; then - echo "::error::Darker should have exited with code 3" - exit 1 - fi + echo "::error::Darker should have exited with code 3" + exit 1 - name: Test missing dependencies error id: missing-deps @@ -131,9 +122,7 @@ jobs: src: test.py - name: Check missing dependencies error code - if: always() + if: always() && steps.missing-deps.outputs.exitcode != '4' run: | - if [ "${{ steps.missing-deps.outputs.exitcode }}" != "4" ]; then - echo "::error::Darker should have exited with code 4" - exit 1 - fi + echo "::error::Darker should have exited with code 4" + exit 1