Skip to content
Merged
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
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: CI
on: push
permissions: read-all
on:
pull_request:
paths-ignore:
- '.github/**'
jobs:
test:
uses: mitlibraries/.github/.github/workflows/python-shared-test.yml@main
uses: mitlibraries/.github/.github/workflows/python-uv-shared-test.yml@main
lint:
uses: mitlibraries/.github/.github/workflows/python-shared-lint.yml@main
uses: mitlibraries/.github/.github/workflows/python-uv-shared-lint.yml@main
31 changes: 15 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
default_language_version:
python: python3.12
default_stages:
- pre-push
repos:
- repo: local
hooks:
- id: black-apply
name: black-apply
entry: pipenv run black
- id: ruff-format
name: ruff-format
entry: uv run ruff format --diff
language: system
pass_filenames: true
types: ["python"]
types: [ "python" ]

- id: mypy
name: mypy
entry: pipenv run mypy
entry: uv run mypy
language: system
pass_filenames: true
types: ["python"]
exclude: "tests/"
- id: ruff-apply
name: ruff-apply
entry: pipenv run ruff check --fix
types: [ "python" ]
exclude: "(tests/|output/|migrations/)"

- id: ruff-check
name: ruff-check
entry: uv run ruff check
language: system
pass_filenames: true
types: ["python"]
- id: pip-audit
name: pip-audit
entry: pipenv run pip-audit
language: system
pass_filenames: false
types: [ "python" ]
74 changes: 39 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,60 @@ help: # Preview Makefile commands
@awk 'BEGIN { FS = ":.*#"; print "Usage: make <target>\n\nTargets:" } \
/^[-_[:alpha:]]+:.?*#/ { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST)

#######################
# Dependency commands
#######################
# ensure OS binaries aren't called if naming conflict with Make recipes
.PHONY: help install venv update test coveralls lint lint-fix security minio-start

install: # Install Python dependencies
pipenv install --dev
pipenv run pre-commit install
##############################################
# Python Environment and Dependency commands
##############################################

update: install # Update Python dependencies
pipenv clean
pipenv update --dev
install: .venv .git/hooks/pre-commit .git/hooks/pre-push # Install Python dependencies and create virtual environment if not exists
uv sync --dev

.venv: # Creates virtual environment if not found
@echo "Creating virtual environment at .venv..."
uv venv .venv

.git/hooks/pre-commit: # Sets up pre-commit commit hooks if not setup
@echo "Installing pre-commit commit hooks..."
uv run pre-commit install --hook-type pre-commit

.git/hooks/pre-push: # Sets up pre-commit push hooks if not setup
@echo "Installing pre-commit push hooks..."
uv run pre-commit install --hook-type pre-push

venv: .venv # Create the Python virtual environment

update: # Update Python dependencies
uv lock --upgrade
uv sync --dev

######################
# Unit test commands
######################

test: # Run tests and print a coverage report
pipenv run coverage run --source=timdex_dataset_api -m pytest -vv
pipenv run coverage report -m
uv run coverage run --source=timdex_dataset_api -m pytest -vv
uv run coverage report -m

coveralls: test # Write coverage data to an LCOV report
pipenv run coverage lcov -o ./coverage/lcov.info
uv run coverage lcov -o ./coverage/lcov.info

####################################
# Code quality and safety commands
# Code linting and formatting
####################################

lint: black mypy ruff safety # Run linters

black: # Run 'black' linter and print a preview of suggested changes
pipenv run black --check --diff .

mypy: # Run 'mypy' linter
pipenv run mypy .

ruff: # Run 'ruff' linter and print a preview of errors
pipenv run ruff check .

safety: # Check for security vulnerabilities and verify Pipfile.lock is up-to-date
pipenv run pip-audit
pipenv verify

lint-apply: black-apply ruff-apply # Apply changes with 'black' and resolve 'fixable errors' with 'ruff'

black-apply: # Apply changes with 'black'
pipenv run black .
lint: # Run linting, alerts only, no code changes
uv run ruff format --diff
uv run mypy .
uv run ruff check .

ruff-apply: # Resolve 'fixable errors' with 'ruff'
pipenv run ruff check --fix .
lint-fix: # Run linting, auto fix behaviors where supported
uv run ruff format .
uv run ruff check --fix .

security: # Run security / vulnerability checks
uv run pip-audit

######################
# Minio S3 Instance
Expand All @@ -69,4 +73,4 @@ minio-start:
-v $(MINIO_DATA):/data \
-e "MINIO_ROOT_USER=$(MINIO_USERNAME)" \
-e "MINIO_ROOT_PASSWORD=$(MINIO_PASSWORD)" \
quay.io/minio/minio server /data --console-address ":9001"
quay.io/minio/minio server /data --console-address ":9001"
32 changes: 0 additions & 32 deletions Pipfile

This file was deleted.

Loading