diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index c573dd416..9bb373a19 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -72,11 +72,8 @@ jobs: - name: Install dev dependencies run: pip install -r requirements-dev.txt - - name: Run Ruff check - run: ruff check - - - name: Run Ruff format check - run: ruff format --diff + - name: Run lint + run: make lint check-requirements: runs-on: ubuntu-latest @@ -98,10 +95,4 @@ jobs: run: pip install pip-tools - name: Check requirements files - run: | - mkdir .tmp - pip-compile --quiet --output-file .tmp/requirements.txt - pip-compile --quiet --extra=dev --output-file .tmp/requirements-dev.txt - diff -u requirements.txt .tmp/requirements.txt || (echo "requirements.txt doesn't match pyproject.toml" && exit 1) - diff -u requirements-dev.txt .tmp/requirements-dev.txt || (echo "requirements-dev.txt doesn't match pyproject.toml" && exit 1) - echo "Requirements files match pyproject.toml" + run: make check-requirements diff --git a/bindings/python/Makefile b/bindings/python/Makefile new file mode 100644 index 000000000..f685fa651 --- /dev/null +++ b/bindings/python/Makefile @@ -0,0 +1,37 @@ +REQUIREMENTS := requirements.txt +REQUIREMENTS_DEV := requirements-dev.txt + +all: check-requirements install lint test +.PHONY: all + +install: + @echo "Installing requirements..." + pip install -r requirements.txt -r requirements-dev.txt +.PHONY: install + +test: + @echo "Running tests..." + pytest +.PHONY: test + +lint: + @echo "Running linters..." + ruff check + ruff format --diff +.PHONY: lint + +check-requirements: + @echo "Checking requirements files..." + mkdir -p .tmp + pip-compile pyproject.toml --quiet --output-file=.tmp/$(REQUIREMENTS) + pip-compile pyproject.toml --quiet --extra=dev --output-file=.tmp/$(REQUIREMENTS_DEV) + diff -u $(REQUIREMENTS) .tmp/$(REQUIREMENTS) || (echo "$(REQUIREMENTS) doesn't match pyproject.toml" && exit 1) + diff -u $(REQUIREMENTS_DEV) .tmp/$(REQUIREMENTS_DEV) || (echo "$(REQUIREMENTS_DEV) doesn't match pyproject.toml" && exit 1) + @echo "Requirements files match pyproject.toml" +.PHONY: check-requirements + +compile-requirements: + @echo "Compiling requirements files..." + pip-compile pyproject.toml --output-file=$(REQUIREMENTS) + pip-compile pyproject.toml --extra=dev --output-file=$(REQUIREMENTS_DEV) +.PHONY: compile-requirements