diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 3fdc9d8..153f91a 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -15,7 +15,5 @@ jobs: run: | python -m pip install --upgrade pip pip install -r dev-requirements.txt - - name: Lint with ruff - run: | - make lint - make format + - name: Run pre-commit + run: pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0e90f7a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +repos: + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.4.6 + hooks: + # Run the linter. + - id: ruff + args: [ ., --fix, --diff ] + # Run the formatter. + - id: ruff-format + args: [ . ] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 20dcbc9..adedbe9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,26 +15,37 @@ To find issues you can help with, go though the list of [good first issues](http Once you find an interesting issue let us know that you want to work on it by commenting on the issue. ## Development +### Install our development environment +Install the development dependencies: +``` +pip install -r requirements.txt -r dev-requirements.txt +``` + +Install the `pre-commit`: +``` +pre-commit install +``` + +### Code Style and Quality +- The [PEP 8](https://realpython.com/python-pep8/) styling convention is used. +- This is achieved using the `ruff` Linter and Formatter. +- The Linter and Formatter are automatically executed before committing via pre-commit. + - If you want to run the Linter and Formatter at any time, execute `pre-commit run --all-files`. + +### Testing +> [!NOTE] +> This project uses `Makefile` as a task runner. You need to set up your environment to be able to run the `make` command. + +Run the following command in the project's root directory: +``` +make test +``` +You can generate a coverage report with the following command: +``` +make post_test +``` +Additionally, when a PR is raised, pytest will be executed by the GitHub Actions CI. -**Code Style and Quality** - -The [PEP 8](https://realpython.com/python-pep8/) styling convention is used. - -To make sure you are following it, you can install [black](https://pypi.org/project/black/) - -`pip install black` - -To run black: - -`black .` - -**Testing** - -To run tests, install pytest, `pip install pytest` and navigate to `/test`. - -Run `pytest` - -On commit, git will run `pytest` for you to catch any errors. ## Questions, suggestions or new ideas @@ -46,4 +57,4 @@ Feel free to [create a new issue](https://github.com/ryansurf/cli-surf/issues/ne Be sure to explain in details the context and the outcome that you are lookign for. If reporting bugs, provide basic information like your OS version, whether using Docker, etc. -Thanks! :ocean: :surfer: \ No newline at end of file +Thanks! :ocean: :surfer: diff --git a/README.md b/README.md index bb01a6c..ffa3f31 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ Change `.env.example` to `.env` | `PORT` | The port you want to open to run the application. Default = `8000` | | `IP_ADDRESS` | The ip your server is running on. Default = `localhost` | | `SMTP_SERVER` | The email server you are using. Default = smtp.gmail.com | +| `SMTP_PORT` | The email server port you are using. Default = `587` | | `EMAIL` | The email you will send the report from. | | `EMAIL_PW` | The sending email's password | | `EMAIL_RECEIVER` | The email that will receive the report (your personal email) | diff --git a/dev-requirements.txt b/dev-requirements.txt index d98c126..e425c17 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,3 +1,4 @@ ruff==0.4.6 pytest==8.2.1 pytest-cov==5.0.0 +pre-commit==3.7.1 diff --git a/docs/styling.md b/docs/styling.md index 424e76b..72b39fd 100644 --- a/docs/styling.md +++ b/docs/styling.md @@ -1,15 +1,10 @@ # Styling ## Code Style and Quality - The [PEP 8](https://realpython.com/python-pep8/) styling convention is used. -To make sure you are following it, you can install [black](https://pypi.org/project/black/) - -`pip install black` - -To run black: +This is achieved using the ruff Linter and Formatter. -`black .` +The Linter and Formatter are automatically executed before committing via pre-commit. -On a push/pull request, git will run `black .` for you! \ No newline at end of file +If you want to run the Linter and Formatter at any time, execute `pre-commit run --all-files`. diff --git a/makefile b/makefile index c49405c..b6343c6 100644 --- a/makefile +++ b/makefile @@ -1,10 +1,7 @@ -.PHONY: lint format +.PHONY: run test post_test -lint: - ruff check . && ruff check . --diff - -format: - ruff check . --fix && ruff format . +run: + cd src && python3 server.py test: pytest -s -x --cov=src -vv