Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

feat: refactor ci steps and add pre-commit validations #124

Open
wants to merge 12 commits into
base: development
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: 57 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Python CircleCI 2.0 configuration file

version: 2
version: 2.1
jobs:
build:
test:
docker:
- image: circleci/python:3.8-buster-node
- image: circleci/postgres:12
Expand All @@ -18,23 +18,33 @@ jobs:

- restore_cache:
keys:
- cache-v1-{{ checksum "poetry.lock" }}
- cache-
- poetry-v1-{{ checksum "poetry.lock" }}
- poetry-

- run:
name: install python packages
command: poetry install

- save_cache:
key: cache-v1-{{ checksum "poetry.lock" }}
key: poetry-v1-{{ checksum "poetry.lock" }}
paths:
- ~/.local
- ~/.cache

- restore_cache:
keys:
- npm-v1-{{ checksum "package-lock.json" }}
- npm-

- run:
name: install node packages
command: npm ci

- save_cache:
key: npm-v1-{{ checksum "package-lock.json" }}
paths:
- ~/.npm

- run:
name: generate bundles
command: npm run build
Expand Down Expand Up @@ -63,3 +73,45 @@ jobs:
- store_test_results:
path: test-results
destination: test-results

lint:
docker:
- image: circleci/python:3.8-buster-node

working_directory: ~/repo

steps:
- checkout

- restore_cache:
keys:
- poetry-v1-{{ checksum "poetry.lock" }}
- poetry-

- run:
name: install python packages
command: poetry install

- save_cache:
key: poetry-v1-{{ checksum "poetry.lock" }}
paths:
- ~/.local
- ~/.cache

- run:
name: run black
command: poetry run black --check .

- run:
name: run flake8
command: poetry run flake8 --max-line-length=88 --ignore=E203,W503 --exclude=migrations .

- run:
name: run isort
command: poetry run isort --check .

workflows:
test_and_lint:
jobs:
- test
- lint
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
poetry run pre-commit run --hook-stage commit
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

poetry run pre-commit run --hook-stage push
40 changes: 40 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
repos:
- repo: local

hooks:
- id: black
name: black
entry: poetry run black
types:
- python
language: system
stages:
- commit

- id: flake8
name: flake8
entry: poetry run flake8 --max-line-length=88 --ignore=E203,W503
exclude: migrations
language: system
types:
- python
stages:
- commit

- id: health-check
name: health-check
entry: poetry run python manage.py check --fail-level WARNING
language: system
always_run: true
pass_filenames: false
stages:
- commit

- id: migrations
name: check migrations
entry: poetry run python3 manage.py makemigrations --check --dry-run
language: system
always_run: true
stages:
- push

Loading