Skip to content

Commit

Permalink
Split linting & formating
Browse files Browse the repository at this point in the history
  • Loading branch information
epwr committed Mar 1, 2024
1 parent 0736a58 commit 3891037
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Integration
name: Linting

on:
push:
Expand All @@ -22,8 +22,8 @@ jobs:
- name: Install dependencies
run: make venv

- name: Run Static Analysis & Tests
run: make
- name: Run Static Analysis
run: make lint

- name: Ensure 100% Test Coverage
run: make coverage
- name: Run Formatting
run: black --check app tests
26 changes: 26 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set Up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install dependencies
run: make venv

- name: Run Tests w/ Coverage Report
run: make test
22 changes: 5 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,20 @@ VENV := venv
APP_DIR := app

# default target, when make executed without arguments
all: test
all: lint test

#
$(VENV)/bin/activate:
python3 -m venv $(VENV)
./$(VENV)/bin/pip install -r ./requirements/requirements.txt -r ./requirements/requirements-dev.txt

venv: $(VENV)/bin/activate

test: venv
lint: venv
./$(VENV)/bin/mypy app --strict
./$(VENV)/bin/flake8 app tests

# Use `yq` to parse config/testing.toml and set the env variables. Then run pytest.
$(shell yq -o='shell' '.env_variables' config/testing.toml \
| tr '\n' ' ' \
| sed 's|$$|./$(VENV)/bin/python3 -m pytest|')


coverage: venv
touch .gitignore # used to force make to run test every time

# Use `yq` to parse config/testing.toml and set the env variables. Then run coverage.
# Use `yq` to parse config/testing.toml and set the env variables. Then run tests & coverage.
test: venv
$(shell yq -o='shell' '.env_variables' config/testing.toml \
| tr '\n' ' ' | \
sed 's|$$|./$(VENV)/bin/coverage run --omit=tests/* -m pytest|')
Expand All @@ -41,7 +32,6 @@ clean:
rm -rf $(VENV)
find . -type f -name '*.pyc' -delete


setup-db:
$(shell yq -o='shell' '.env_variables.SQLITE_FILE' config/local.toml \
| tr '\n' ' ' \
Expand All @@ -52,6 +42,4 @@ populate-db:
| tr '\n' ' ' \
| sed "s|value='\(.*\)'|sqlite3 '\1' < data/initial_data.sql|")

.PHONY: all test venv run clean coverage


.PHONY: all test venv run clean

0 comments on commit 3891037

Please sign in to comment.