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: add GitHub CI #3

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
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/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install Python dependencies
run: pip install black flake8

- name: Run linters
uses: wearerequired/lint-action@v2
with:
auto_fix: true
black: true
black_args: --config=./configs/pyproject.toml
black_auto_fix: true
flake8: true
flake8_args: --config=./configs/.flake8
flake8_auto_fix: false
commit_message: "style: format code with black and flake8"

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Testing the code with pytest
run: |
pytest --cov=./arquimedia --cov-report xml:coverage.xml --cov-report term-missing tests/

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true

check-conventional-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: webiny/[email protected]
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
hooks:
- id: conventional-pre-commit
stages: [ commit-msg ]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
args: [--config=./configs/.flake8]

- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
args: [--config=./configs/pyproject.toml]
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ make logs

This will show the logs of the docker container.

Might also be useful to enter the container's shell and run commands manually. To do so, run the following command:

```bash
make shell
```

## Testing

To test the project, you need to run the following command:
Expand All @@ -79,6 +85,24 @@ To access the documentation, you need to run the project and access the followin
http://localhost:8001/docs
```

## Pre-commit

This project uses [pre-commit](https://pre-commit.com/) to run some checks before committing.

To install hooks, run the following command:

```bash
pre-commit install
```

This checks will run automatically before every commit and will check for:

- [x] Black
- [x] Flake8
- [x] Conventional Commits

This is a useful tool to keep the code clean and consistent. Changes will still be checked by the CI, but it's better to fix them before pushing.

## Contributing

If not part of the Arquimedia team, you can contribute by following the steps below.
Expand Down
12 changes: 11 additions & 1 deletion configs/.flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
[flake8]
max-line-length = 120

ignore = E203,E266,E501,W503,F403,F401
exclude =
.git
.mypy_cache
.pytest_cache
.tox
build
dist
venv
.github
configs
16 changes: 16 additions & 0 deletions configs/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.black]
line-length = 120
exclude = '''
/(
\.git
| \.mypy_cache
| \.pytest_cache
| \.tox
| build
| dist
| venv
| .github
| configs
)/
'''

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ fastapi
sqlmodel
uvicorn
pytest
pytest-cov