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

Switch to poetry #223

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9c6af82
Switch to poetry
nrobinaubertin Feb 26, 2024
d80a093
Merge origin/main
nrobinaubertin Feb 26, 2024
3d4ac3f
Add poetry.lock to licenserc exceptions
nrobinaubertin Feb 26, 2024
88f642a
Rerun CI
nrobinaubertin Feb 26, 2024
f5f722c
Merge remote-tracking branch 'origin/main' into poetry
nrobinaubertin Feb 26, 2024
ecfe5ba
Use verbose mode for poetry install
nrobinaubertin Feb 26, 2024
8da3090
Try to debug
nrobinaubertin Feb 26, 2024
13e838f
Debug
nrobinaubertin Feb 26, 2024
7a36d3c
Remove debug, change wf branch
nrobinaubertin Feb 26, 2024
86cff1c
Merge remote-tracking branch 'origin/main' into poetry
nrobinaubertin Feb 26, 2024
724447e
Add poetry lock operations
nrobinaubertin Feb 26, 2024
8bee835
Update poetry.lock
nrobinaubertin Feb 26, 2024
a0431c4
Rerun CI
nrobinaubertin Feb 26, 2024
0939de7
Rerun CI
nrobinaubertin Feb 26, 2024
083daa6
Rerun CI
nrobinaubertin Feb 26, 2024
2594525
Debug
nrobinaubertin Feb 26, 2024
2fa8dcf
Remove debug
nrobinaubertin Feb 26, 2024
64afc1d
Debug
nrobinaubertin Feb 26, 2024
bbcea06
More debug
nrobinaubertin Feb 26, 2024
82ed9b0
Change wf branch
nrobinaubertin Feb 26, 2024
c15d71e
Install poetry as a tox dep
nrobinaubertin Feb 27, 2024
7a1de36
Merge origin/main
nrobinaubertin Feb 27, 2024
48d3c73
Fix
nrobinaubertin Feb 27, 2024
641538a
Fix
nrobinaubertin Feb 27, 2024
72ff6e0
Fix
nrobinaubertin Feb 27, 2024
eceb3d3
Merge origin/main
nrobinaubertin Feb 28, 2024
6d77e08
Merge origin/main
nrobinaubertin Mar 4, 2024
91acaf9
Merge origin/main
nrobinaubertin May 6, 2024
7b915c1
Update dependencies
nrobinaubertin May 6, 2024
13932ad
Remove selfhosted runnvers for now
nrobinaubertin May 6, 2024
1e9858f
Remove all selfhosted runners for now
nrobinaubertin May 6, 2024
c567d98
Merge branch 'main' into poetry
nrobinaubertin May 6, 2024
8d3d41f
Rerun CI
nrobinaubertin May 6, 2024
e8f3e93
Fix dependencies
nrobinaubertin May 6, 2024
5d2d051
Update poetry.lock
nrobinaubertin May 7, 2024
fff175e
Rerun CI
nrobinaubertin May 7, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
integration-tests:
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@charmcraft-tox-wrapper
secrets: inherit
with:
extra-arguments: -x --localstack-address 172.17.0.1
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,7 @@ cython_debug/
.vscode/

*/*.snap

# Poetry
requirements.txt
requirements-last-build.txt
2,437 changes: 2,437 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

95 changes: 94 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ branch = true
fail_under = 92
show_missing = true


[tool.pytest.ini_options]
minversion = "6.0"
log_cli_level = "INFO"
Expand Down Expand Up @@ -64,3 +63,97 @@ disallow_untyped_defs = true
[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false

[tool.poetry]
# Charm is not packed as a standard Python package; this information is not used
name = "charm"
version = "0.0.0"
description = ""
authors = ["IS DevOps <https://launchpad.net/~canonical-is-devops>"]

[tool.poetry.dependencies]
python = "^3.10"
ops = "^2.10.0"
pydantic = "^1.10"
psycopg2-binary = "^2.9.9"
requests = "^2.31.0"
boto3 = "^1.34.47"

[tool.poetry.group.charm-libs.dependencies]
ops = "*"
pydantic = "*"
# lib/charms/prometheus_k8s/v0/prometheus_scrape.py
# lib/charms/grafana_k8s/v0/grafana_dashboard.py
pyyaml = "^6.0.1"
# lib/charms/traefik_k8s/v1/ingress.py
jsonschema = "^4.21.1"
# lib/charms/prometheus_k8s/v0/prometheus_scrape.py
cosl = "^0.0.8"

[tool.poetry.group.fmt]
optional = true

[tool.poetry.group.fmt.dependencies]
black = "^24.2.0"
isort = "^5.13.2"

[tool.poetry.group.lint]
optional = true

[tool.poetry.group.lint.dependencies]
black = "^24.2.0"
codespell = "^2.2.6"
flake8 = "<6.0.0"
flake8-builtins = "^2.2.0"
flake8-copyright = "<6.0.0"
flake8-docstrings = ">=1.6.0"
flake8-docstrings-complete = ">=1.0.3"
flake8-test-docs = ">=1.0"
isort = "^5.13.2"
mypy = "^1.8.0"
pep8-naming = "^0.13.3"
pydocstyle = ">=2.10"
pylint = "^3.0.3"
pyproject-flake8 = "<6.0.0"
pytest = "^8.0.1"
pytest-operator = "^0.32.0"
python-magic = "^0.4.27"
types-pyyaml = "^6.0.12.12"
types-requests = "^2.31.0.20240218"
saml-test-helper = {git = "https://github.com/canonical/saml-test-idp.git"}

[tool.poetry.group.src-docs]
optional = true

[tool.poetry.group.src-docs.dependencies]
lazydocs = "^0.4.8"

[tool.poetry.group.unit]
optional = true

[tool.poetry.group.unit.dependencies]
coverage = {extras = ["toml"], version = "^7.4.2"}
pytest = "^8.0.1"

[tool.poetry.group.coverage-report]
optional = true

[tool.poetry.group.coverage-report.dependencies]
coverage = {extras = ["toml"], version = "^7.4.2"}
pytest = "^8.0.1"

[tool.poetry.group.static]
optional = true

[tool.poetry.group.static.dependencies]
bandit = {extras = ["toml"], version = "^1.7.7"}

[tool.poetry.group.integration]
optional = true

[tool.poetry.group.integration.dependencies]
juju = ">=3.0"
pytest = "^8.0.1"
pytest-operator = "^0.32.0"
python-magic = "^0.4.27"
saml-test-helper = {git = "https://github.com/canonical/saml-test-idp.git"}
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

92 changes: 34 additions & 58 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,66 +17,45 @@ setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
PYTHONBREAKPOINT=ipdb.set_trace
PY_COLORS=1
PYTHON_KEYRING_BACKEND = keyring.backends.fail.Keyring
passenv =
PYTHONPATH
CHARM_BUILD_DIR
MODEL_SETTINGS
allowlist_externals =
poetry
sh

[testenv:fmt]
description = Apply coding style standards to code
deps =
black
isort
commands_pre =
poetry install --only fmt
commands =
isort {[vars]all_path}
black {[vars]all_path} --target-version=py310
poetry run isort {[vars]all_path}
poetry run black {[vars]all_path} --target-version=py310

[testenv:src-docs]
allowlist_externals=sh
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
description = Generate documentation for src
deps =
lazydocs
-r{toxinidir}/requirements.txt
commands_pre =
poetry install --with src-docs
commands =
; cannot run lazydocs directly due to needing to run it on src/* which produces an invocation error in tox
sh generate-src-docs.sh

[testenv:lint]
description = Check code against coding style standards
deps =
black
codespell
flake8<6.0.0
flake8-builtins
flake8-copyright<6.0.0
flake8-docstrings>=1.6.0
flake8-docstrings-complete>=1.0.3
flake8-test-docs>=1.0
isort
mypy
pep8-naming
pydocstyle>=2.10
pylint
pyproject-flake8<6.0.0
pytest
pytest-asyncio
pytest-operator
python-magic
requests
types-PyYAML
types-requests
git+https://github.com/canonical/saml-test-idp.git
-r{toxinidir}/requirements.txt
commands_pre =
poetry install --with lint
commands =
pydocstyle {[vars]src_path}
# uncomment the following line if this charm owns a lib
# codespell {[vars]lib_path}
codespell {toxinidir} --skip {toxinidir}/.git --skip {toxinidir}/.tox \
--skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \
--skip {toxinidir}/.mypy_cache --skip {toxinidir}/icon.svg \
--skip {toxinidir}/synapse_rock
--skip {toxinidir}/synapse_rock --skip {toxinidir}/poetry.lock
# pflake8 wrapper supports config from pyproject.toml
pflake8 {[vars]all_path} --ignore=W503
isort --check-only --diff {[vars]all_path}
Expand All @@ -86,46 +65,43 @@ commands =

[testenv:unit]
description = Run unit tests
deps =
cosl
coverage[toml]
pytest
-r{toxinidir}/requirements.txt
commands_pre =
poetry install --with unit
commands =
coverage run --source={[vars]src_path} \
-m pytest --ignore={[vars]tst_path}integration -v --tb native -s {posargs}
coverage report

[testenv:coverage-report]
description = Create test coverage report
deps =
coverage[toml]
pytest
-r{toxinidir}/requirements.txt
commands_pre =
poetry install --with coverage-report
commands =
coverage report

[testenv:static]
description = Run static analysis tests
deps =
bandit[toml]
-r{toxinidir}/requirements.txt
commands_pre =
poetry install --with static
commands =
bandit -c {toxinidir}/pyproject.toml -r {[vars]src_path} {[vars]tst_path}

[testenv:integration]
description = Run integration tests
deps =
macaroonbakery==1.3.2 # fixes "TypeError: Descriptors cannot be created directly." protobuf error
juju >=3.0
pytest
pytest-asyncio
pytest-operator
python-magic
boto3
# Type error problem with newer version of macaroonbakery
macaroonbakery==1.3.2
git+https://github.com/canonical/saml-test-idp.git
-r{toxinidir}/requirements.txt
commands_pre =
poetry install --with integration
commands =
pytest -v -x --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs}

[testenv:pack]
# Wrap `charmcraft pack`
allowlist_externals =
{[testenv]allowlist_externals}
charmcraft
mv
commands_pre =
poetry export --only main,charm-libs --output requirements.txt
commands =
charmcraft pack {posargs}
commands_post =
mv requirements.txt requirements-last-build.txt
Loading