diff --git a/code-style/action.yml b/code-style/action.yml index 4827d5338..e68f1d064 100644 --- a/code-style/action.yml +++ b/code-style/action.yml @@ -89,6 +89,13 @@ inputs: default: true type: boolean + show-diff-on-failure: + description: | + Whether to show the diff when a pre-commit hook fails. + required: false + default: true + type: boolean + runs: using: "composite" steps: @@ -164,7 +171,7 @@ runs: python -m venv .venv env: PIPX_BIN_DIR: ${{ runner.temp }}/pipx/bin - PIPX_HOME : ${{ runner.temp }}/pipx/home + PIPX_HOME: ${{ runner.temp }}/pipx/home - name: "Create a virtual environment" if: env.BUILD_BACKEND == 'pip' @@ -203,7 +210,11 @@ runs: shell: bash run: | source .venv/bin/activate - pre-commit run --all-files --show-diff-on-failure + if [[ ${{ inputs.show-diff-on-failure }} == 'true' ]]; then + pre-commit run --all-files --show-diff-on-failure + else + pre-commit run --all-files + fi # ------------------------------------------------------------------------ diff --git a/tests-pytest/action.yml b/tests-pytest/action.yml index 7bcf0a7fc..3fa6384d2 100644 --- a/tests-pytest/action.yml +++ b/tests-pytest/action.yml @@ -241,16 +241,25 @@ runs: python -m pip install .[tests] fi - - name: "Executing test suite without using xvfb" + - name: "Set up pytest run command" + shell: bash + run: | + if [[ ${{ env.BUILD_BACKEND }} == 'poetry' ]]; then + echo "PYTEST_RUN=$(echo 'poetry run pytest')" >> $GITHUB_ENV + else + echo "PYTEST_RUN=$(echo 'python -m pytest')" >> $GITHUB_ENV + fi + + - name: "Executing test suite" if: inputs.requires-xvfb == 'false' shell: bash run: | ${{ env.ACTIVATE_VENV }} - pytest ${{ inputs.pytest-markers }} ${{ inputs.pytest-extra-args }} ${{ inputs.pytest-postargs }} + ${{ env.PYTEST_RUN }} ${{ inputs.pytest-markers }} ${{ inputs.pytest-extra-args }} ${{ inputs.pytest-postargs }} - name: "Executing test suite using xvfb" if: inputs.requires-xvfb == 'true' shell: bash run: | ${{ env.ACTIVATE_VENV }} - xvfb-run pytest ${{ inputs.pytest-markers }} ${{ inputs.pytest-extra-args }} ${{ inputs.pytest-postargs }} + xvfb-run ${{ env.PYTEST_RUN }} ${{ inputs.pytest-markers }} ${{ inputs.pytest-extra-args }} ${{ inputs.pytest-postargs }}