diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 24450d1..0357514 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -39,11 +39,11 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} cache: 'poetry' - - run: poetry install - - name: Run ruff - run: poetry run ruff format --check - - name: Run ruff lint - run: poetry run ruff check + - run: make resolve_deps + - name: Check code formatting + run: make format_check + - name: Run linter + run: make lint_check pytest: runs-on: ubuntu-latest @@ -55,9 +55,9 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} cache: 'poetry' - - run: poetry install + - run: make resolve_deps - name: Run pytest - run: poetry run pytest . -v + run: make test publish: needs: [ check-version, format, pytest ] @@ -71,7 +71,7 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} cache: "poetry" - - run: poetry install + - run: make resolve_deps - name: Build and Publish run: | poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0b95566 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +#!/usr/bin/make -f + +# Makefile for harambe + +.DEFAULT_GOAL := help + +help: ## Show this helpful message + @for ML in $(MAKEFILE_LIST); do \ + grep -E '^[a-zA-Z_-]+:.*?## .*$$' $$ML | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'; \ + done +.PHONY: help + +format: ## Format code + @echo "Formatting code 🧹" + @poetry run ruff format +.PHONY: format + +format_check: ## Check code formatting + @echo "Checking code 🧹" + @poetry run ruff format --diff +.PHONY: format_check + +lint: ## Lint code + @poetry run ruff check --fix +.PHONY: lint + +lint_check: ## Check code quality + @poetry run ruff check +.PHONY: lint_check + +resolve_deps: ## Install required dependencies + @poetry install +.PHONY: resolve_deps + +test: ## Run tests + @poetry run pytest . -v +.PHONY: test diff --git a/README.md b/README.md index 2b5d560..5e914b6 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ Before submitting a PR, please run the following commands to ensure that your code is formatted correctly. ```shell -./format.sh +make format lint ``` Happy extraction! 🦍 diff --git a/format.sh b/format.sh deleted file mode 100755 index 5bb3530..0000000 --- a/format.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -cd "$(dirname "$0")" || exit 1 - -echo "Formatting code 🧹" -poetry run ruff format - -echo "Checking code 🧹" -poetry run ruff check diff --git a/harambe/core.py b/harambe/core.py index fa1158f..431f670 100644 --- a/harambe/core.py +++ b/harambe/core.py @@ -35,7 +35,8 @@ class AsyncScraper(Protocol): Note that scrapers in harambe should be functions, not classes. """ - async def scrape(self, sdk: "SDK", url: URL, context: Context) -> None: ... + async def scrape(self, sdk: "SDK", url: URL, context: Context) -> None: + ... class SDK: