-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Why these changes are being introduced: * How this addresses that need: * Add .pre-commit-config.yaml * Clean up Makefile * Add command to install pre-commit hook * Clean up comments and 'help' description * Update Pipfile dev-packages * Remove coverage, flake8, and isort * Add coveralls, pre-commit, ruff * Add pyproject.toml Side effects of this change: * None Relevant ticket(s): * X
- Loading branch information
1 parent
0b5c2ab
commit ed147fd
Showing
5 changed files
with
670 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
default_language_version: | ||
python: python3.11 # set for project python version | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: black-apply | ||
name: black-apply | ||
entry: pipenv run black | ||
language: system | ||
pass_filenames: true | ||
types: ["python"] | ||
- id: mypy | ||
name: mypy | ||
entry: pipenv run mypy | ||
language: system | ||
pass_filenames: true | ||
types: ["python"] | ||
exclude: "tests/" | ||
- id: ruff-apply | ||
name: ruff-apply | ||
entry: pipenv run ruff check --fix | ||
language: system | ||
pass_filenames: true | ||
types: ["python"] | ||
- id: safety | ||
name: safety | ||
entry: pipenv check | ||
language: system | ||
pass_filenames: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,86 @@ | ||
.PHONY: install test coveralls lint bandit black flake8 isort mypy dist-dev update publish-dev | ||
SHELL=/bin/bash | ||
DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ) | ||
|
||
### This is the Terraform-generated header for oai-pmh-harvester-dev ### | ||
ECR_NAME_DEV:=oai-pmh-harvester-dev | ||
ECR_URL_DEV:=222053980223.dkr.ecr.us-east-1.amazonaws.com/oai-pmh-harvester-dev | ||
### End of Terraform-generated header ### | ||
|
||
help: ## Print this message | ||
@awk 'BEGIN { FS = ":.*##"; print "Usage: make <target>\n\nTargets:" } \ | ||
/^[-_[:alpha:]]+:.?*##/ { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST) | ||
help: # preview Makefile commands | ||
@awk 'BEGIN { FS = ":.*#"; print "Usage: make <target>\n\nTargets:" } \ | ||
/^[-_[:alpha:]]+:.?*#/ { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST) | ||
|
||
install: ## Install script and dependencies | ||
## Dependency commands | ||
install: # install Python dependencies and pre-commit hook | ||
pipenv install --dev | ||
pipenv run pre-commit install | ||
|
||
update: install # update Python dependencies | ||
pipenv clean | ||
pipenv update --dev | ||
|
||
test: ## Run tests and print a coverage report | ||
## Unit test commands | ||
test: # run tests and print a coverage report | ||
pipenv run coverage run --source=harvester -m pytest -vv | ||
pipenv run coverage report -m | ||
|
||
coveralls: test | ||
coveralls: test # write coverage data to an LCOV report | ||
pipenv run coverage lcov -o ./coverage/lcov.info | ||
|
||
### Linting commands ### | ||
lint: bandit black flake8 isort mypy ## Lint the repo | ||
## Code quality and safety commands | ||
|
||
bandit: | ||
pipenv run bandit -r harvester | ||
lint: black mypy ruff safety # run linters | ||
|
||
black: | ||
black: # run 'black' linter and print a preview of suggested changes | ||
pipenv run black --check --diff . | ||
|
||
flake8: | ||
pipenv run flake8 . | ||
mypy: # run 'mypy' linter | ||
pipenv run mypy . | ||
|
||
isort: | ||
pipenv run isort . --diff | ||
ruff: # run 'ruff' linter and print a preview of errors | ||
pipenv run ruff check . | ||
|
||
mypy: | ||
pipenv run mypy harvester | ||
safety: # check for security vulnerabilities and verify Pipfile.lock is up-to-date | ||
pipenv check | ||
pipenv verify | ||
|
||
update: install ## Update all Python dependencies | ||
pipenv clean | ||
pipenv update --dev | ||
lint-apply: # apply changes with 'black' and resolve fixable errors with 'ruff' | ||
black-apply ruff-apply | ||
|
||
black-apply: # apply changes with 'black' | ||
pipenv run black . | ||
|
||
ruff-apply: # resolve fixable errors with 'ruff' | ||
pipenv run ruff check --fix . | ||
|
||
### Terraform-generated Developer Deploy Commands for Dev environment ### | ||
dist-dev: ## Build docker container (intended for developer-based manual build) | ||
## Terraform-generated commands for container build and deployment in dev | ||
dist-dev: # build docker container (intended for developer-based manual build) | ||
docker build --platform linux/amd64 \ | ||
-t $(ECR_URL_DEV):latest \ | ||
-t $(ECR_URL_DEV):`git describe --always` \ | ||
-t $(ECR_NAME_DEV):latest . | ||
|
||
publish-dev: dist-dev ## Build, tag and push (intended for developer-based manual publish) | ||
publish-dev: dist-dev # build, tag and push (intended for developer-based manual publish) | ||
docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1) $(ECR_URL_DEV) | ||
docker push $(ECR_URL_DEV):latest | ||
docker push $(ECR_URL_DEV):`git describe --always` | ||
|
||
### Terraform-generated manual shortcuts for deploying to Stage ### | ||
### This requires that ECR_NAME_STAGE & ECR_URL_STAGE environment variables are set locally | ||
### by the developer and that the developer has authenticated to the correct AWS Account. | ||
### The values for the environment variables can be found in the stage_build.yml caller workflow. | ||
dist-stage: ## Only use in an emergency | ||
## Terraform-generated commands for container build and deployment in stage \ | ||
This requires that ECR_NAME_STAGE and ECR_URL_STAGE environment variables \ | ||
are set locally by the developer and that the developer has \ | ||
authenticated to the correct AWS Account. The values for the environment \ | ||
variables can be found in the stage_build.yml caller workflow. \ | ||
While Stage should generally only be used in an emergency for most repos, \ | ||
it is necessary for any testing requiring access to the Data Warehouse \ | ||
because Cloud Connector is not enabled on Dev1. | ||
dist-stage: | ||
docker build --platform linux/amd64 \ | ||
-t $(ECR_URL_STAGE):latest \ | ||
-t $(ECR_URL_STAGE):`git describe --always` \ | ||
-t $(ECR_NAME_STAGE):latest . | ||
|
||
publish-stage: ## Only use in an emergency | ||
publish-stage: | ||
docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1) $(ECR_URL_STAGE) | ||
docker push $(ECR_URL_STAGE):latest | ||
docker push $(ECR_URL_STAGE):`git describe --always` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.