From ba4e54ee70c19b918debc77a01d8877d0cbe809d Mon Sep 17 00:00:00 2001 From: Jared Lewis Date: Mon, 28 Oct 2024 11:43:14 +1100 Subject: [PATCH] chore: Move to use make targets in CI --- .github/workflows/ci.yaml | 18 +++++++++++++----- Makefile | 21 +++++++++------------ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 53adc4e..7dba43b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,10 +13,19 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 - - name: Install uv - uses: astral-sh/setup-uv@v3 + - uses: ./.github/actions/setup - name: mypy - run: MYPYPATH=stubs uv run mypy src + run: make mypy + + pre-commit: + if: ${{ !github.event.pull_request.draft }} + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - name: pre-commit + run: make pre-commit docs: if: ${{ !github.event.pull_request.draft }} @@ -24,8 +33,7 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 - - name: Install uv - uses: astral-sh/setup-uv@v3 + - uses: ./.github/actions/setup - name: docs run: uv run mkdocs build diff --git a/Makefile b/Makefile index 6f447b0..87d3610 100644 --- a/Makefile +++ b/Makefile @@ -22,17 +22,18 @@ export PRINT_HELP_PYSCRIPT help: ## print short description of each target @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) -.PHONY: checks -checks: ## run all the linting checks of the codebase - @echo "=== pre-commit ==="; uv run pre-commit run --all-files || echo "--- pre-commit failed ---" >&2; \ - echo "=== mypy ==="; MYPYPATH=stubs uv run mypy packages || echo "--- mypy failed ---" >&2; \ - echo "======" +.PHONY: pre-commit +pre-commit: ## run all the linting checks of the codebase + uv run pre-commit run --all-files + + +.PHONY: mypy +mypy: ## run mypy on the codebase + MYPYPATH=stubs uv run --package ref-core mypy packages/ref-core + MYPYPATH=stubs uv run --package ref-metrics-example mypy packages/ref-metrics-example .PHONY: ruff-fixes ruff-fixes: ## fix the code using ruff - # format before and after checking so that the formatted stuff is checked and - # the fixed stuff is formatted - uv run ruff format uv run ruff check --fix uv run ruff format @@ -52,14 +53,10 @@ test-metrics-example: ## run the tests test: test-core test-metrics-example ## run the tests # Note on code coverage and testing: -# You must specify cov=src as otherwise funny things happen when doctests are -# involved. # If you want to debug what is going on with coverage, we have found # that adding COVERAGE_DEBUG=trace to the front of the below command # can be very helpful as it shows you if coverage is tracking the coverage # of all of the expected files or not. -# We are sure that the coverage maintainers would appreciate a PR that improves -# the coverage handling when there are doctests and a `src` layout like ours. .PHONY: docs docs: ## build the docs