Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
pip install poetry
poetry config installer.max-workers 10
poetry install --no-interaction --no-ansi
- name: Run pre-commit
run: poetry run pre-commit run --all-files
- name: Run Lint
run: make lint
19 changes: 13 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.6
- repo: local
hooks:
# Run the linter.
- id: ruff
entry: ruff check . --fix
- id: lint
name: Lint
entry: make lint
types: [python]
language: system
pass_filenames: false
# Run the formatter.
- id: ruff-format
args: [ . ]
- id: format
name: Format
entry: make format
types: [python]
language: system
pass_filenames: false
8 changes: 3 additions & 5 deletions CONTRIBUTING.md

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much more simple for potential contributors, nice!

Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ Once you find an interesting issue let us know that you want to work on it by co

## Development
### Install our development environment
1. Please set up your development environment by referring to the `Setup` section in the `README.md`.
Please set up your development environment by referring to the `Setup` section in the `README.md`.

2. Install the `pre-commit`:
```
pre-commit install
```
> [!WARNING]
> Make sure to run `make install` to ensure that lint and format are executed reliably when using the `git commit` command.

### Code Style and Quality
- The [PEP 8](https://realpython.com/python-pep8/) styling convention is used.
Expand Down
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,12 @@ To use cli-surf, clone the project locally and install the necessary dependencie
cd cli-surf
```

3. Install dependencies using Poetry.
3. Install dependencies and Activate the virtual environment.
```bash
poetry install
make install
```

4. Activate the virtual environment.
```bash
poetry shell
```

5. Run the project. For example, if the entry point is `server.py`, use the following command.
4. Run the project. For example, if the entry point is `server.py`, use the following command.
```bash
python src/server.py

Expand Down
53 changes: 48 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,68 @@
.PHONY: run run_docker test test_docker post_test docker_post_test send_email send_email_docker
.DEFAULT_GOAL := all
sources = src tests

.PHONY: install

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This install target is great

install:
poetry install
poetry shell
pre-commit install

.PHONY: run
run:
poetry run python src/server.py

.PHONY: format
format:
poetry run ruff check --fix $(sources)
poetry run ruff format $(sources)

.PHONY: lint
lint:
poetry run ruff check $(sources)
poetry run ruff format --check $(sources)

.PHONY: run_docker
run_docker:
docker compose up -d

.PHONY: test
test:
poetry run pytest -s -x --cov=src -vv
poetry run pytest

.PHONY: test_docker
test_docker:
docker compose exec flask poetry run pytest -s -x --cov=src -vv
docker compose exec flask poetry run pytest

.PHONY: output_coverage
output_coverage:
poetry run coverage html
@rm -rf htmlcov
@mkdir -p htmlcov
poetry run coverage run -m pytest
poetry run coverage report
poetry run coverage html -d htmlcov

.PHONY: output_coverage_docker
output_coverage_docker:
docker compose exec flask poetry run coverage html
@docker compose exec flask rm -rf htmlcov
@docker compose exec flask mkdir -p htmlcov
docker compose exec flask poetry run coverage run -m pytest
docker compose exec flask poetry run coverage report
docker compose exec flask poetry run coverage html -d htmlcov

.PHONY: send_email
send_email:
poetry run python src/send_email.py

.PHONY: send_email_docker
send_email_docker:
docker compose exec flask poetry run python src/send_email.py

.PHONY: clean

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good addition

clean:
rm -rf htmlcov
rm -rf .pytest_cache
rm -f .coverage
rm -f .coverage.*

.PHONY: all
all: format lint test
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ build-backend = "poetry.core.masonry.api"

# pytest settings
[tool.pytest.ini_options]
testpaths = 'tests'
pythonpath = "."
addopts = '-p no:warnings' # disable pytest warnings
log_format = '%(name)s %(levelname)s: %(message)s'

# ruff global settings
[tool.ruff]
Expand Down