Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kelkawi-a committed Jun 13, 2024
1 parent 08fb6ba commit 348292e
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ __pycache__/
*.py[cod]
.idea
.vscode/
*.whl
*.tar.gz
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The sample wheel file can be built by running `poetry build -f wheel` in the
Once ready, the resource can be attached as follows:

```bash
make -C resource_sample/ build
juju attach-resource temporal-worker-k8s workflows-file=./resource_sample/dist/python_samples-1.1.0-py3-none-any.whl
```

Expand Down Expand Up @@ -153,7 +154,7 @@ storing workflow-related credentials in production environments. To enable this,
run the following commands:

```bash
juju deploy vault-k8s --channel edge
juju deploy vault-k8s --channel 1.15/edge

# After following Vault doc instructions to unseal Vault
juju relate temporal-worker-k8s vault-k8s
Expand Down
94 changes: 94 additions & 0 deletions resource_sample/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Makefile to help automate tasks

# build and dist folders
BUILD := build
DIST := dist

# The name of the python package/project
PY_PACKAGE := resource_sample

# Paths to venv executables
POETRY := poetry
PY := python3
PYTEST := pytest
BANDIT := bandit
BLACK := black
FLAKE8 := flake8
ISORT := isort
MYPY := mypy
PYLINT := pylint
PYDOCSTYLE := pydocstyle

.PHONY: help
help: ## Print help about available targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: run
run: ## Run the application
$(POETRY) run $(PY) -m $(PY_PACKAGE)

.PHONY: install
install:
$(POETRY) install --only main --no-root

# Development tools.
.PHONY: install-dev
install-dev:
$(POETRY) install --with dev --no-root

.PHONY: lint
lint: ## Run linter
$(POETRY) run $(FLAKE8) $(PY_PACKAGE) tests
$(POETRY) run $(PYLINT) $(PY_PACKAGE) tests --disable=E0401,W1203,W0613,W0718,R0903,W1514,C0301,C0103,C0104,R0914,R0913,W0719,R0902
$(POETRY) run $(ISORT) --check $(PY_PACKAGE) tests
$(POETRY) run $(BLACK) --check $(PY_PACKAGE) tests
$(POETRY) run $(BANDIT) --configfile pyproject.toml --quiet --recursive $(PY_PACKAGE) tests
$(POETRY) run $(PYDOCSTYLE) $(PY_PACKAGE)

.PHONY: fmt
fmt: ## Reformat code for linter
$(POETRY) run $(ISORT) $(PY_PACKAGE) tests
$(POETRY) run $(BLACK) $(PY_PACKAGE) tests

.PHONY: test
test: ## Run tests
$(POETRY) run $(PYTEST) --cov=$(PY_PACKAGE) tests

.PHONY: check
check: clean install-dev lint test ## Runs linter and tests from a clean directory


# Release management.

.PHONY: changelog
changelog: ## Add a new entry to the Changelog and bump the package version
./scripts/update_changelog.sh

.PHONY: build
build: ## Create a Python source distribution and a wheel in dist
$(POETRY) build

.PHONY: publish
publish: ## Publish the package to PYPI
$(POETRY) publish

# Cleaning up.

.PHONY: clean-dist
clean-dist:
rm -rf $(BUILD) $(DIST)

.PHONY: clean-pyc
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
rm -rf .pytest_cache .coverage .mypy_cache

.PHONY: clean-venv
clean-venv:
$(POETRY) env remove --all

.PHONY: clean
clean: clean-dist clean-pyc clean-venv ## Clean up the virtualenv, Python bytecode and docs
rm -rf *.egg-info
Binary file not shown.
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ all_path = {[vars]src_path} {[vars]tst_path}

[testenv]
basepython = python3
allowlist_externals = make
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
PYTHONBREAKPOINT=ipdb.set_trace
Expand Down Expand Up @@ -102,6 +103,7 @@ deps =
pytest-asyncio==0.21
-r{toxinidir}/requirements.txt
commands =
make -C resource_sample/ build
pytest {[vars]tst_path}integration/test_charm.py -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --destructive-mode

[testenv:integration-scaling]
Expand All @@ -115,6 +117,7 @@ deps =
pytest-asyncio==0.21
-r{toxinidir}/requirements.txt
commands =
make -C resource_sample/ build
pytest {[vars]tst_path}integration/test_scaling.py -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --destructive-mode

[testenv:integration-upgrades]
Expand All @@ -128,6 +131,7 @@ deps =
pytest-asyncio==0.21
-r{toxinidir}/requirements.txt
commands =
make -C resource_sample/ build
pytest {[vars]tst_path}integration/test_upgrades.py -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --destructive-mode

[testenv:integration-vault]
Expand All @@ -142,4 +146,5 @@ deps =
hvac==2.2.0
-r{toxinidir}/requirements.txt
commands =
make -C resource_sample/ build
pytest {[vars]tst_path}integration/test_vault.py -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --destructive-mode

0 comments on commit 348292e

Please sign in to comment.