Skip to content

Commit

Permalink
Merge pull request #33 from MartinBernstorff/mbern_update_cruft
Browse files Browse the repository at this point in the history
ci: update cruft
  • Loading branch information
MartinBernstorff authored Nov 22, 2023
2 parents 83704ae + 8d91050 commit c6211ac
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/MartinBernstorff/nimble-python-cookiecutter",
"commit": "7b0df632c9b44d28eb60bbfc6fd376c5ba667564",
"commit": "33bc232101ce0384e315ae3b5cc49b45d31cf36e",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
push: filter
refFilterForPush: refs/heads/main
runCmd:
make validate
make validate_ci
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ __pycache__/
_build/
.tox

#
# Coverage
**/.coverage*

# VSCode
.vscode/
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ WORKDIR /app

# Dev experience
COPY Makefile ./

COPY dev-requirements.txt ./
RUN make install-dev
RUN --mount=type=cache,target=/root/.cache/pip make install-dev
RUN pyright .

COPY requirements.txt ./
RUN make install-deps
RUN --mount=type=cache,target=/root/.cache/pip make install-deps

COPY pyproject.toml ./
COPY . /app
RUN pip install .
RUN pip install .
RUN git init
91 changes: 68 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,88 @@
SRC_PATH = functionalpy
MAKEFLAGS = --no-print-directory

install-dev:
pip install --upgrade -r dev-requirements.txt
@pip install --upgrade -r dev-requirements.txt

install-deps:
pip install --upgrade -r requirements.txt
@pip install --upgrade -r requirements.txt

install:
make install-deps
make install-dev
pip install -e .
@make install-deps
@make install-dev
@pip install -e .

# Tasks
generate_coverage:
@pytest --cov=$(SRC_PATH) $(SRC_PATH) --cov-report xml:.coverage.xml --cov-report lcov:.coverage.lcov

test: ## Run tests
pytest $(SRC_PATH)
@echo "––– Testing –––"
@make generate_coverage
@diff-cover .coverage.xml --fail-under=80
@echo "✅✅✅ Tests passed ✅✅✅"

lint: ## Format code
ruff check . --fix
ruff format .
@echo "––– Linting –––"
@ruff format .
@ruff . --fix \
--extend-select F401 \
--extend-select F841
@echo "✅✅✅ Lint ✅✅✅"

type-check: ## Type-check code
pyright $(SRC_PATH)
types: ## Type-check code
@echo "––– Type-checking –––"
@pyright $(SRC_PATH)
@echo "✅✅✅ Types ✅✅✅"

validate: ## Run all checks
make lint
make type-check
make test
@echo "––– Running all checks –––"
@make lint
@make types
@make test

validate_ci: ## Run all checks
@echo "––– Running all checks –––"
@make lint
@make types
## CI doesn't support local coverage report, so skipping full tests
@make generate_coverage

sync-pr:
git push --set-upstream origin HEAD
git push
# PR management
merge-main:
@echo "––– Merging main –––"
@git fetch
@git merge --no-edit origin/main

push:
@echo "––– Pushing to origin/main –––"
@git push --set-upstream origin HEAD
@git push
create-pr:
gh pr create -w || true
@echo "––– Creating PR –––"
@gh pr create --title "$$(git rev-parse --abbrev-ref HEAD | tr -d '[:digit:]' | tr '-' ' ')" --body "Auto-created" || true

enable-automerge:
@gh pr merge --auto --merge --delete-branch

merge-pr:
gh pr merge --auto --merge --delete-branch
pr-status:
@gh pr view | cat | grep "title"
@gh pr view | cat | grep "url"
@echo "✅✅✅ PR created ✅✅✅"

################
# Compositions #
################
setup-pr: ## Update everything and setup the PR
@make merge-main
@make push
@make create-pr

finalise-pr:
@make enable-automerge
@make pr-status

pr: ## Run relevant tests before PR
make sync-pr
make create-pr
make validate
make merge-pr
@make setup-pr
@make validate
@make finalise-pr
10 changes: 7 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
pytest==7.4.3
ruff==0.1.6
cruft==2.15.0
pyright==1.1.336
cruft==2.15.0
pytest==7.4.3
pytest-cov==4.1.0
pytest-xdist==3.5.0
pytest-sugar==0.9.7
diff-cover==8.0.1
ruff==0.1.6
2 changes: 1 addition & 1 deletion functionalpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from ._sequence import Seq, Group # noqa: F401
from ._sequence import Seq, Group # noqa: F401 # type: ignore
1 change: 0 additions & 1 deletion functionalpy/benchmark/query_1/iterators_q1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime as dt
import itertools
import statistics as stats
from collections.abc import Mapping, Sequence
from dataclasses import dataclass
Expand Down
2 changes: 1 addition & 1 deletion functionalpy/benchmark/query_1/polars_q1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def main(data: pl.LazyFrame) -> pl.DataFrame:
result = (
data.filter(pl.col("ship_date") <= dt.datetime(2000, 1, 1))
data.filter(pl.col("ship_date") <= dt.datetime(2000, 1, 1)) # type: ignore
.group_by(["returned", "line_status"])
.agg(
[
Expand Down
5 changes: 3 additions & 2 deletions functionalpy/benchmark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ def benchmark_method(
)
parsed_data = data_ingest_result.output

result = run_query(
result = run_query( # type: ignore
lambda: query(data=parsed_data), # type: ignore
query_title=f"{method_title}: Computation",
)

return CombinedBenchmark(
ingest=data_ingest_result, query_result=result
ingest=data_ingest_result,
query_result=result, # type: ignore
)
2 changes: 0 additions & 2 deletions functionalpy/test_sequence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from cgi import test

from functionalpy._sequence import Seq


Expand Down

0 comments on commit c6211ac

Please sign in to comment.