From 7acca7985733aad8b906205a7b0f57c2d9b85065 Mon Sep 17 00:00:00 2001 From: Bosen Qu Date: Wed, 27 Dec 2023 04:46:58 +0000 Subject: [PATCH] Add additional CI summary on coverage, and reconfigure ruff --- .github/workflows/{python-app.yml => ci.yml} | 22 +++++++++++++------- Makefile | 16 +++++++------- pyproject.toml | 14 ++++++++++++- tests/features/basic.feature | 2 +- tests/features/person.feature | 2 +- 5 files changed, 36 insertions(+), 20 deletions(-) rename .github/workflows/{python-app.yml => ci.yml} (76%) diff --git a/.github/workflows/python-app.yml b/.github/workflows/ci.yml similarity index 76% rename from .github/workflows/python-app.yml rename to .github/workflows/ci.yml index 5466367..bf356f6 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Python application +name: Python Application CI on: push: @@ -7,9 +7,10 @@ on: branches: [ "master" ] permissions: - contents: read actions: read checks: write + contents: read + pull-requests: write jobs: test: @@ -31,19 +32,24 @@ jobs: - name: Run unit and feature tests run: make test-ci - name: Create test report - uses: dorny/test-reporter@v1 + uses: n-ryu/test-reporter@v0.0.2 if: always() with: name: Test report path: "reports/**/*.xml" reporter: java-junit list-tests: "failed" - - name: Create test Summary - uses: test-summary/action@v2 - if: always() - with: - paths: "reports/**/*.xml" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Create test summary + uses: test-summary/action@v2 + if: always() + with: + paths: "reports/**/*.xml" + - name: Add coverage report to summary + if: always() + run: | + echo "**Test Coverage Report**" >> $GITHUB_STEP_SUMMARY + cat reports/coverage_report.md >> $GITHUB_STEP_SUMMARY diff --git a/Makefile b/Makefile index 48c6934..b490bf3 100644 --- a/Makefile +++ b/Makefile @@ -41,14 +41,14 @@ test: # Run unit and feature tests with test (junit) and coverage (cobertura) report .PHONNY: test-ci test-ci: - rm -rf $(REPORTS)/unit_tests $(REPORTS)/feature_tests - $(PYTHON) -m coverage run --data-file $(REPORTS)/unit_tests/coverage.dat --source src \ + rm -fr $(REPORTS) + $(PYTHON) -m coverage run --data-file $(REPORTS)/unit_tests/coverage.dat \ -m pytest -v --junitxml=$(REPORTS)/unit_tests/junit.xml - $(PYTHON) -m coverage run --data-file $(REPORTS)/feature_tests/coverage.dat --source src \ + $(PYTHON) -m coverage run --data-file $(REPORTS)/feature_tests/coverage.dat \ -m behave -v --junit --junit-directory=$(REPORTS)/feature_tests $(PYTHON) -m coverage combine $(REPORTS)/*/*.dat $(PYTHON) -m coverage xml - $(PYTHON) -m coverage report + $(PYTHON) -m coverage report --format=markdown > $(REPORTS)/coverage_report.md # Run isort, ruff, and reformat-gherkin formatter .PHONNY: format @@ -64,14 +64,12 @@ lint: $(VENV)/bin/reformat-gherkin --check tests/features $(PYTHON) -m mypy . -# Run ruff and reformat-gherkin format checker. In addition, run mypy with text report +# Run make lint with more verbose messages .PHONNY: lint-ci lint-ci: - $(PYTHON) -m ruff check . + $(PYTHON) -m ruff check -v . $(VENV)/bin/reformat-gherkin --check tests/features - rm -rf $(REPORTS)/mypy - $(PYTHON) -m mypy --txt-report $(REPORTS)/mypy . - cat $(REPORTS)/mypy/index.txt + $(PYTHON) -m mypy -v . # Clean project .PHONNY: clean diff --git a/pyproject.toml b/pyproject.toml index 32ce920..c5baf46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,9 @@ strip_extras = true [tool.pytest.ini_options] testpaths = ["tests/unit"] +[tool.coverage.run] +source = ["src"] + [tool.mypy] exclude = ["steps.py"] strict = true @@ -41,4 +44,13 @@ profile = "black" [tool.ruff] line-length = 120 -extend-select = ["B", "I", "Q"] +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "I", # isort + "C", # flake8-comprehensions + "B", # flake8-bugbear + "Q", # flake8-quotes + "UP", # pyupgrade +] diff --git a/tests/features/basic.feature b/tests/features/basic.feature index bd987c5..64daa3c 100644 --- a/tests/features/basic.feature +++ b/tests/features/basic.feature @@ -1,4 +1,4 @@ -Feature: showing off behave +Feature: Showing off behave Scenario: run a simple test # This is a basic comment diff --git a/tests/features/person.feature b/tests/features/person.feature index cca5b26..28c0f11 100644 --- a/tests/features/person.feature +++ b/tests/features/person.feature @@ -1,4 +1,4 @@ -Feature: test person +Feature: Test behave table feature Scenario: test find age # This is a basic comment