switch from pipenv to poetry

This commit is contained in:
Kenneth Kehl
2023-09-01 07:56:02 -07:00
parent b5d795e09e
commit e8d7d91402
12 changed files with 3522 additions and 2307 deletions

View File

@@ -13,9 +13,9 @@ runs:
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install pipenv
- name: Install poetry
shell: bash
run: pip install pipenv==2023.7.23
run: pip install poetry
- name: Install application dependencies
shell: bash
run: make bootstrap

View File

@@ -33,9 +33,9 @@ jobs:
annotations: failed-tests
prnumber: ${{ steps.findPr.outputs.number }}
- name: Run style checks
run: pipenv run flake8 .
run: poetry run flake8 .
- name: Check imports alphabetized
run: pipenv run isort --check-only ./app ./tests
run: poetry run isort --check-only ./app ./tests
- name: Check dead code
run: make dead-code
- name: Run js lint
@@ -43,9 +43,9 @@ jobs:
- name: Run js tests
run: npm test
- name: Run py tests with coverage
run: pipenv run coverage run --omit=*/notifications_utils/* -m pytest --maxfail=10 --ignore=tests/end_to_end tests/
run: poetry run coverage run --omit=*/notifications_utils/* -m pytest --maxfail=10 --ignore=tests/end_to_end tests/
- name: Run E2E tests
run: pipenv run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end
run: poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end
env:
NOTIFY_E2E_AUTH_STATE_PATH: ${{ secrets.NOTIFY_E2E_AUTH_STATE_PATH }}
NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }}
@@ -54,7 +54,7 @@ jobs:
NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }}
NOTIFY_E2E_TEST_URI: ${{ secrets.NOTIFY_E2E_TEST_URI }}
- name: Check coverage threshold
run: pipenv run coverage report --fail-under=90
run: poetry run coverage report --fail-under=90
validate-new-relic-config:
runs-on: ubuntu-latest
@@ -67,7 +67,7 @@ jobs:
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
# Need to set a NEW_RELIC_ENVIRONMENT with monitor_mode: true
NEW_RELIC_ENVIRONMENT: staging
run: pipenv run newrelic-admin validate-config $NEW_RELIC_CONFIG_FILE
run: poetry run newrelic-admin validate-config $NEW_RELIC_CONFIG_FILE
dependency-audits:
runs-on: ubuntu-latest
@@ -75,7 +75,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- name: Create requirements.txt
run: pipenv requirements > requirements.txt
run: poetry export --without-hashes --format=requirements.txt > requirements.txt
- uses: pypa/gh-action-pip-audit@v1.0.6
with:
inputs: requirements.txt
@@ -88,7 +88,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- name: Run scan
run: pipenv run bandit -r app/ --confidence-level medium
run: poetry run bandit -r app/ --confidence-level medium
dynamic-scan:
runs-on: ubuntu-latest

View File

@@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- name: Create requirements.txt
run: pipenv requirements > requirements.txt
run: poetry export --without-hashes --format=requirements.txt > requirements.txt
- uses: pypa/gh-action-pip-audit@v1.0.6
with:
inputs: requirements.txt
@@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
- name: Run scan
run: pipenv run bandit -r app/ --confidence-level medium
run: poetry run bandit -r app/ --confidence-level medium
dynamic-scan:
runs-on: ubuntu-latest

View File

@@ -43,8 +43,8 @@ jobs:
- uses: ./.github/actions/setup-project
- name: Create requirements.txt because Cloud Foundry does a weird pipenv thing
run: pipenv requirements > requirements.txt
- name: Create requirements.txt
run: poetry export --without-hashes --format=requirements.txt > requirements.txt
- name: Deploy to cloud.gov
uses: 18f/cg-deploy-action@main

View File

@@ -43,8 +43,8 @@ jobs:
- uses: ./.github/actions/setup-project
- name: Create requirements.txt because Cloud Foundry does a weird pipenv thing
run: pipenv requirements > requirements.txt
- name: Create requirements.txt
run: poetry export --without-hashes --format=requirements.txt > requirements.txt
- name: Deploy to cloud.gov
uses: 18f/cg-deploy-action@main

View File

@@ -48,8 +48,8 @@ jobs:
- uses: ./.github/actions/setup-project
- name: Create requirements.txt because Cloud Foundry does a weird pipenv thing
run: pipenv requirements > requirements.txt
- name: Create requirements.txt
run: poetry export --without-hashes --format=requirements.txt > requirements.txt
- name: Deploy to cloud.gov
uses: 18f/cg-deploy-action@main

View File

@@ -15,8 +15,8 @@ NVMSH := $(shell [ -f "$(HOME)/.nvm/nvm.sh" ] && echo "$(HOME)/.nvm/nvm.sh" || e
.PHONY: bootstrap
bootstrap: generate-version-file ## Set up everything to run the app
pipenv install --dev
pipenv run playwright install --with-deps
poetry install
poetry run playwright install --with-deps
source $(NVMSH) --no-use && nvm install && npm ci --no-audit
source $(NVMSH) && npm run build
@@ -26,10 +26,10 @@ watch-frontend: ## Build frontend and watch for changes
.PHONY: run-flask
run-flask: ## Run flask
pipenv run newrelic-admin run-program flask run -p 6012 --host=0.0.0.0
poetry run newrelic-admin run-program flask run -p 6012 --host=0.0.0.0
.PHONY: run-flask-bare
run-flask-bare: ## Run flask without invoking pipenv so we can override ENV variables in .env
run-flask-bare: ## Run flask without invoking poetry so we can override ENV variables in .env
flask run -p 6012 --host=0.0.0.0
.PHONY: npm-audit
@@ -49,35 +49,36 @@ test: py-lint py-test js-lint js-test ## Run tests
.PHONY: py-lint
py-lint: ## Run python linting scanners and black
pipenv run black .
pipenv run flake8 .
pipenv run isort --check-only ./app ./tests
poetry self add poetry-dotenv-plugin
poetry run black .
poetry run flake8 .
poetry run isort --check-only ./app ./tests
.PHONY: avg-complexity
avg-complexity:
echo "*** Shows average complexity in radon of all code ***"
pipenv run radon cc ./app -a -na
poetry run radon cc ./app -a -na
.PHONY: too-complex
too-complex:
echo "*** Shows code that got a rating of C, D or F in radon ***"
pipenv run radon cc ./app -a -nc
poetry run radon cc ./app -a -nc
.PHONY: py-test
py-test: export NEW_RELIC_ENVIRONMENT=test
py-test: ## Run python unit tests
pipenv run coverage run --omit=*/notifications_utils/* -m pytest --maxfail=10 --ignore=tests/end_to_end tests/
pipenv run coverage report --fail-under=96
pipenv run coverage html -d .coverage_cache
poetry run coverage run --omit=*/notifications_utils/* -m pytest --maxfail=10 --ignore=tests/end_to_end tests/
poetry run coverage report --fail-under=96
poetry run coverage html -d .coverage_cache
.PHONY: dead-code
dead-code:
pipenv run vulture ./app --min-confidence=100
poetry run vulture ./app --min-confidence=100
.PHONY: e2e-test
e2e-test: export NEW_RELIC_ENVIRONMENT=test
e2e-test: ## Run end-to-end integration tests
pipenv run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end
poetry run pytest -v --browser chromium --browser firefox --browser webkit tests/end_to_end
.PHONY: js-lint
js-lint: ## Run javascript linting scanners
@@ -89,25 +90,25 @@ js-test: ## Run javascript unit tests
.PHONY: fix-imports
fix-imports: ## Fix imports using isort
pipenv run isort ./app ./tests
poetry run isort ./app ./tests
.PHONY: freeze-requirements
freeze-requirements: ## create static requirements.txt
pipenv requirements > requirements.txt
poetry export --without-hashes --format=requirements.txt > requirements.txt
.PHONY: pip-audit
pip-audit:
pipenv requirements > requirements.txt
pipenv requirements --dev > requirements_for_test.txt
pipenv run pip-audit -r requirements.txt
-pipenv run pip-audit -r requirements_for_test.txt
poetry requirements > requirements.txt
poetry requirements --dev > requirements_for_test.txt
poetry run pip-audit -r requirements.txt
-poetry run pip-audit -r requirements_for_test.txt
.PHONY: audit
audit: npm-audit pip-audit
.PHONY: static-scan
static-scan:
pipenv run bandit -r app/
poetry run bandit -r app/
.PHONY: a11y-scan
a11y-scan:

2254
Pipfile.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -38,7 +38,7 @@ The [Notify API](https://github.com/GSA/notifications-api) provides the UI's bac
1. Get the API running
1. Install [pipenv](https://pipenv.pypa.io/en/latest/)
1. Install [poetry](https://poetry.pypa.io/en/latest/)
1. Install [nvm (Node Version Manager)](https://github.com/nvm-sh/nvm#installing-and-updating)

View File

@@ -57,8 +57,8 @@ your environment is set up and configured as outlined in the README.
At your shell in the project root folder, run the following commands:
```sh
pipenv install pytest-playwright --dev
pipenv run playwright install --with-deps
poetry install pytest-playwright --dev
poetry run playwright install --with-deps
```
This will install Playwright and its `pytest` plugin, then the

3463
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,12 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[tool.poetry]
name = "notifications-admin"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
[packages]
[tool.poetry.dependencies]
python = "^3.9"
ago = "~=0.0.95"
black = "==23.7.0"
blinker = "~=1.4"
@@ -12,8 +15,9 @@ flask = "~=2.3"
flask-basicauth = "~=0.2"
flask-login = "~=0.6"
flask-wtf = "~=1.1"
poetry = "==1.6.1"
govuk-bank-holidays = "==0.13"
govuk-frontend-jinja = {version = "==0.5.8-alpha", git = "https://github.com/alphagov/govuk-frontend-jinja.git"}
govuk-frontend-jinja = "==0.5.8-alpha"
gunicorn = {version = "==21.2.0", extras = ["eventlet"]}
humanize = "~=4.8"
itsdangerous = "~=2.1"
@@ -33,12 +37,13 @@ werkzeug = "~=2.3"
wtforms = "~=3.0"
newrelic = "*"
flask-talisman = "*"
notifications-utils = {editable = true, ref = "main", git = "https://github.com/GSA/notifications-utils.git"}
notifications-utils = {git = "https://github.com/GSA/notifications-utils.git", develop = true, tag = "main"}
coverage = "*"
vulture = "==2.9.1"
radon = "==6.0.1"
[dev-packages]
[tool.poetry.group.dev.dependencies]
isort = "==5.12.0"
pytest = "==7.4.0"
pytest-env = "==1.0.1"
@@ -52,10 +57,10 @@ flake8-bugbear = "==23.7.10"
flake8-print = "==5.0.0"
moto = "~=4.1"
requests-mock = "==1.11.0"
# used for creating manifest file locally
jinja2-cli = {version = "==0.8.2", extras = ["yaml"]}
pip-audit = "*"
bandit = "*"
[requires]
python_version = "3.9"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"