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

Feature/test refactoring #21

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
d09e534
First go at implementing poetry
mcqueary Nov 18, 2023
49945f1
First go at implementing poetry
mcqueary Nov 18, 2023
68f4448
First go at implementing poetry
mcqueary Nov 18, 2023
bf06fe7
First go at implementing poetry
mcqueary Nov 18, 2023
015adaf
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
a2db356
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
d70dd0a
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
6e8b7c4
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
377c3ff
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
c82ee93
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
9112e6b
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
a81d2b5
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
eac9af3
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
86f2bbe
Get poetry working with CI
mcqueary Nov 18, 2023
3970cc6
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
34e7b69
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
57609b1
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
f1614c3
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
5d56259
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
5d5ba0d
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
6156c02
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
a80ad80
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 18, 2023
45d8fc1
build: finalizing poetry build
mcqueary Nov 18, 2023
4aa2db8
Merge remote-tracking branch 'origin/chore/2-poetry' into chore/2-poetry
mcqueary Nov 19, 2023
b52dec5
Merge pull request #3 from mcqueary/chore/2-poetry
mcqueary Nov 19, 2023
a4c199c
feat(cli): Add support for configuring db file name
mcqueary Nov 19, 2023
413f0c0
Merge pull request #5 from mcqueary/feature/config-db-name
mcqueary Nov 19, 2023
1efc784
test: Refactor tests and class models for better testability and cove…
mcqueary Nov 20, 2023
d51b135
Merge pull request #7 from mcqueary/feature/improve-test-coverage
mcqueary Nov 20, 2023
f4bd2fb
feat(cli): CLI now detects nonexistent input-file and exits with erro…
mcqueary Nov 21, 2023
d94cbe9
Merge pull request #8 from mcqueary/feature/handle-input-filename-error
mcqueary Nov 21, 2023
1b1d88e
feat: Refactor "id" to "_id" to avoid shadowing a Python builtin func…
mcqueary Nov 21, 2023
f32ea74
Merge pull request #9 from mcqueary/feature/refactor-id
mcqueary Nov 21, 2023
9be4fa7
Merge pull request #9 from mcqueary/feature/refactor-id
mcqueary Nov 21, 2023
7d2a6e9
Merge pull request #10 from mcqueary/feature/refactor-db-integration
mcqueary Nov 21, 2023
aa319ae
feat(api): Memorial now correctly parses all burial and cemetery info
mcqueary Nov 23, 2023
d8a2962
Merge pull request #11 from mcqueary/feature/improve-burial-info
mcqueary Nov 23, 2023
f155110
feat(api): improve memorial parsing
mcqueary Nov 24, 2023
e27b2ef
Merge pull request #13 from mcqueary/feature/complete-memorial-parsing
mcqueary Nov 24, 2023
1989d40
massive refactor
mcqueary Dec 14, 2023
fd2d70d
oops
mcqueary Dec 14, 2023
e0a6a83
oops
mcqueary Dec 14, 2023
0aa478c
Backwards compatibility
mcqueary Dec 14, 2023
453386f
Fixing typing issues
mcqueary Dec 14, 2023
05eb7bf
Fixing tests
mcqueary Dec 14, 2023
b335ec3
Fixing precommit issues
mcqueary Dec 14, 2023
a527232
Fixing poetry install issue
mcqueary Dec 14, 2023
8f08713
fixing issues (obviously)
mcqueary Dec 14, 2023
a1c6bd5
Fixing typing issues
mcqueary Dec 14, 2023
ccfbe10
Adding Python 3.7 support (I hope)
mcqueary Dec 14, 2023
f181402
Adding Windows CI testing
mcqueary Dec 14, 2023
18437bb
Resolving dependency issues
mcqueary Dec 14, 2023
7548db2
Fixing text fixtures
mcqueary Dec 15, 2023
22f337b
Fixing Windows CI issues
mcqueary Dec 15, 2023
15ecc48
Fixing Windows temp file issues
mcqueary Dec 15, 2023
e5ca8c7
Fixing Windows temp file issues
mcqueary Dec 15, 2023
f7ce1a9
Fixing Windows temp file issues
mcqueary Dec 15, 2023
60b8067
Fixing Windows tmp file issues
mcqueary Dec 15, 2023
020cd77
Still fixing temp file issues
mcqueary Dec 15, 2023
6d70f26
Still fixing windows temp file issues
mcqueary Dec 15, 2023
bfb0df6
Temp file drama still
mcqueary Dec 15, 2023
3dd8104
Merge pull request #14 from mcqueary/feature/massive-refactor
mcqueary Dec 15, 2023
7411658
Merge branch 'feature/massive-refactor' into develop
mcqueary Dec 15, 2023
78cabe7
Merge branch 'develop' of github.com:mcqueary/graver into develop
mcqueary Dec 15, 2023
43d4898
fixing dependencies
mcqueary Dec 15, 2023
96c1d06
Merge pull request #15 from mcqueary/feature/dependency-changes
mcqueary Dec 15, 2023
2c44462
Fixing tests
mcqueary Dec 15, 2023
422e7e1
Merge pull request #17 from mcqueary/feature/fix-search-test-error
mcqueary Dec 15, 2023
eec8441
adding http retry test
mcqueary Dec 16, 2023
4369482
Updating dependencies
mcqueary Dec 16, 2023
ee0c660
Merge pull request #18 from mcqueary/feature/test-http-retry
mcqueary Dec 16, 2023
5d7cc05
small refactor of CLI
mcqueary Dec 16, 2023
1b7e7e1
Updating __all__
mcqueary Dec 16, 2023
edb09a2
Fixing some OS assumptions about newlines
mcqueary Dec 17, 2023
a6fde3f
Fixed quoting issue
mcqueary Dec 17, 2023
c0c04e3
Merge pull request #19 from mcqueary/feature/coverage
mcqueary Dec 17, 2023
0125a50
Updating build files
mcqueary Dec 17, 2023
6c31993
Merge pull request #20 from mcqueary/feature/build
mcqueary Dec 18, 2023
e4b2359
Refactoring tests
mcqueary Dec 20, 2023
0d304d8
Fix typos
mcqueary Dec 20, 2023
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
37 changes: 22 additions & 15 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,48 @@ name: CI

on:
push:
branches: [ "master" ]
branches: [ "master", "develop" ]
pull_request:
branches: [ "master" ]
branches: [ "master", "develop" ]

jobs:
build:

ci:
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ubuntu-latest,]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install -r requirements.txt
python -m pip install -e .
poetry install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run flake8 src/graver tests --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
poetry run flake8 src/graver tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest and report coverage
run: |
pytest --cov
poetry run pytest --cov=graver --cov-report term-missing
- name: Publish to coveralls.io
uses: coverallsapp/[email protected]
with:
github-token: ${{ github.token }}
github-token: ${{ github.token }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ __pycache__/
*.db
*.csv
*.egg-info
data.json
*.log
graver.log.*
.bandit
.env
.idea/
Expand All @@ -16,3 +19,4 @@ __pycache__/
bandit.yaml
*.txt
!require*.txt
dist/
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8

- repo: local
hooks:
- id: commitizen
name: My commitizen check
entry: make
args: ['commitizen']
pass_filenames: false
language: system
stages: [commit-msg]
57 changes: 38 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,70 @@
.PHONY: test test-unit test-integration run help fmt install-editable lint git-setup clean all
.PHONY: test run build help fmt install install-editable lint git-setup clean realclean all commitizen cov coveralls

# same as `export PYTHONPATH="$PWD:$PYTHONPATH"`
# see also https://stackoverflow.com/a/18137056
mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
PYTHONPATH:=$(PYTHONPATH):$(mkfile_path)
PYTHONPATH:=$(PYTHONPATH)
PACKAGES:=src/graver

VENV?=.venv
PIP=$(VENV)/bin/pip
PY=$(VENV)/bin/python
POETRY=$(VENV)/bin/poetry
VCR_CASSETTES=$(mkfile_path)tests/fixtures/vcr_cassettes/

all: ; $(info $$PYTHONPATH is [${PYTHONPATH}])

help: ## list targets with short description
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9._-]+:.*?## / {printf "\033[1m\033[36m%-38s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

cov: ## run pytest coverage report
. $(VENV)/bin/activate && pytest --cov tests/ && coveralls
$(POETRY) run pytest --cov=graver --cov-report term-missing

run: ## sample run
. $(VENV)/bin/activate && $(PY) graver/app.py -i input.txt
coveralls: ## report coverage data to coveralls.io
$(POETRY) run coveralls

test-unit: $(info $$PYTHONPATH is [${PYTHONPATH}])
. $(VENV)/bin/activate && pytest -rA -vvs --log-level INFO tests/unit

test-integration: $(info $$PYTHONPATH is [${PYTHONPATH}])
. $(VENV)/bin/activate && pytest -rA -vvs --log-level INFO tests/integration

test: test-unit test-integration
test: ## run pytest
$(POETRY) run pytest -rA -vvs --log-level INFO

lint: ## run flake8 to check the code
. $(VENV)/bin/activate && flake8 --max-line-length 88 src tests
$(POETRY) run flake8 $(PACKAGES) tests --count --select=E9,F63,F7,F82 --show-source --statistics
$(POETRY) run flake8 $(PACKAGES) tests --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics
$(POETRY) run deadcode $(PACKAGES)

install-editable:
. $(VENV)/bin/activate && pip install -e .
install: ## install project using `which poetry` from pyproject.toml
poetry install --with dev,test

fmt: ## run black to format the code
. $(VENV)/bin/activate && isort src tests
. $(VENV)/bin/activate && black -q --line-length 88 src tests
$(POETRY) run isort $(PACKAGES) tests
$(POETRY) run black -q --line-length 88 $(PACKAGES) tests

$(VENV)/init: ## init the virtual environment
python3 -m venv $(VENV)
$(VENV)/init: ## init the virtual environment via standard pip
python3.12 -m venv $(VENV)
touch $@
. $(VENV)/bin/activate && pip install -U pip
. $(VENV)/bin/activate && pip install -r requirements.txt

$(VENV)/requirements: requirements.txt $(VENV)/init ## install requirements
$(PIP) install -r $<
touch $@

build: ## export requirements.txt (for standard pip install) and build dist
$(POETRY) export -f requirements.txt --output requirements.txt
$(POETRY) build

commitizen:
@cz check --commit-msg-file .git/COMMIT_EDITMSG

clean: ## clean up test outputs and other temporary files
rm -f *.csv
rm -f *.db
rm -f tests/*.log
rm -f tests/*.db
rm -f *.log*

realclean: clean ## clean up everything produced by the install and build
rm -rf dist/
rm -rf $(VENV)

vcrclean:
rm -f $(VCR_CASSETTES)/*
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions bin/export-json.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
sqlite3 $1 <<EOF
.headers on
.mode json
.output data.json
select * from graves;
.quit
EOF
2 changes: 0 additions & 2 deletions definitions.py

This file was deleted.

Loading