From 427fb8d0b528412b252a96b9904faf23ba1c074a Mon Sep 17 00:00:00 2001 From: LuoChen Date: Thu, 1 Aug 2024 09:26:55 +0800 Subject: [PATCH] chore: improve github action test script (support debug) --- .github/workflows/python-package.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 9122a79..aebe3e0 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -28,7 +28,7 @@ jobs: run: | python -m pip install --upgrade pip poetry python -m pip install flake8 pytest pytest-xdist pytest-cov pyright - - name: Install The Tested Package + - name: Install This Package run: | if [[ "${{ github.event.head_commit.message }}" == "version:"* ]]; then echo "This is a version bump commit. Installing the package from built wheel." @@ -44,12 +44,19 @@ jobs: run: | if [[ "${{ github.event.head_commit.message }}" == "version:"* ]]; then echo "This is a version bump commit, run test without coverage." - pytest -n0 -s + COV_ARG="" else echo "This is not a version bump commit, run test with coverage." - export DEBUG=true - pytest -n0 -s --cov=src --cov-report=term --cov-report=xml + COV_ARG="--cov=src --cov-report=term --cov-report=xml" fi + + export DEBUG=$RUNNER_DEBUG + if [ -n "$DEBUG" ]; then + DBG_ARG="-n0 -s" + else + DBG_ARG="" + fi + pytest $DBG_ARG $COV_ARG - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: