Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Linter and formatter #14

Merged
merged 7 commits into from
Oct 3, 2023
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
62 changes: 62 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Integration

on:
pull_request:
branches: ["dev"]

jobs:
check-format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Check format
run: black --check .

check-linter:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Check linter
run: ruff check .

test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set up docker environment
run: docker-compose up -d

- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Run tests
run: pytest
env:
PYTHONPATH: "."

- name: Clean docker environment
run: docker compose down --rmi all -v --remove-orphans
30 changes: 0 additions & 30 deletions .github/workflows/testing.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Python files
venv
__pycache__

# Vscode files
.vscode/*
!.vscode/extensions.json

# Pipelines files
.coverage
node_modules
coverage.xml
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"ms-python.python",
"ms-python.black-formatter",
"charliermarsh.ruff",
"usernamehw.errorlens"
]
}
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,34 @@ docker compose up -d
coverage run -m pytest
```

### Formatting and linting

If you installed the recommended extensions for VSCode, you may have the formatting and linting configured out of the box.

Additionally, you may need to configure `black` to format `python` files with the following steps:

- Open the command palette (Ctrl + Shift + P)
- Search Format Document With...
- Search Configure Default Formatter...
- Select "Black Formatter"

You can also run the following commands to format and lint the code from the console:

```bash
# Check format
black --check .

# Format all python files
black .

# Check lint
ruff check .

# Fix lint (if possible)
ruff check --fix .
```

## Coverage

| [![circle](https://codecov.io/gh/hawks-atlanta/proxy-python/graphs/sunburst.svg?token=JODBEVCYCF)](https://app.codecov.io/gh/hawks-atlanta/proxy-python) | [![square](https://codecov.io/gh/hawks-atlanta/proxy-python/graphs/tree.svg?token=JODBEVCYCF)](https://app.codecov.io/gh/hawks-atlanta/proxy-python) |
| ------------------------------------------------------------ | ------------------------------------------------------------ |

| -------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
5 changes: 3 additions & 2 deletions pages/home/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import flask
from ._view import *
from ._view import view


home = flask.Blueprint("home", __name__)
home.register_blueprint(view)
home.register_blueprint(view)
3 changes: 2 additions & 1 deletion pages/home/_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

view = flask.Blueprint("home", __name__)


@view.route("/", methods=["GET"])
def index():
return flask.render_template("index.html")
return flask.render_template("index.html")
3 changes: 2 additions & 1 deletion pages/home/_view_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from main import app


def test_view() -> None:
response = app.test_client().get("/")
assert response.status_code == 200
assert response.status_code == 200
Binary file modified requirements.txt
Binary file not shown.
4 changes: 2 additions & 2 deletions version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json

with open("package.json", "rb") as pkg_file:
pkg = json.load(pkg_file)
print(f"version={pkg['version']}")
pkg = json.load(pkg_file)
print(f"version={pkg['version']}")