From 6a082332fd2589c22cc4cdc21ae62c789b46a723 Mon Sep 17 00:00:00 2001 From: "badabump-release-bot[bot]" Date: Sun, 11 Dec 2022 11:48:16 +0000 Subject: [PATCH] chore: Sync common project files --- .editorconfig | 2 +- .flake8 | 2 + .github/actions/install_badabump/action.yml | 2 +- .../install_python_and_poetry/action.yml | 12 ++++-- .github/actions/run_pre_commit/action.yml | 2 +- .github/actions/run_tox/action.yml | 2 +- .github/workflows/ci_package.yml | 5 ++- .github/workflows/release_pr.yml | 4 +- .github/workflows/release_tag.yml | 2 +- .gitignore | 7 +++- .pre-commit-config.yaml | 16 +++---- .python-version | 2 +- python.mk | 42 ++++++++++--------- 13 files changed, 59 insertions(+), 41 deletions(-) diff --git a/.editorconfig b/.editorconfig index 153257b..30e6922 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,7 @@ trim_trailing_whitespace = true [{.babelrc,.compressrc,.eslintrc,.linguirc}] indent_size = 2 -[*.{css,cfg,html,html.j2,ini,js,json,md,service,service.j2,toml,yaml,yml,xml}] +[*.{css,cfg,html,ini,j2,js,json,md,service,toml,yaml,yml,xml}] indent_size = 2 [*.{nginx,nginx.j2,py,rst,sh}] diff --git a/.flake8 b/.flake8 index 8f1f2c1..4df58d4 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,8 @@ [flake8] ban-relative-imports = true extend-ignore = E501, PIE786 +extend-select = TC, TC1 inline-quotes = double max-complexity = 15 multiline-quotes = double +type-checking-strict = true diff --git a/.github/actions/install_badabump/action.yml b/.github/actions/install_badabump/action.yml index c48ee59..0c671b7 100644 --- a/.github/actions/install_badabump/action.yml +++ b/.github/actions/install_badabump/action.yml @@ -12,7 +12,7 @@ runs: steps: - id: "python" name: "Install Python" - uses: "actions/setup-python@v4.3.0" + uses: "actions/setup-python@v4.3.1" with: python-version-file: ".python-version" diff --git a/.github/actions/install_python_and_poetry/action.yml b/.github/actions/install_python_and_poetry/action.yml index 3fa8b91..5b4f181 100644 --- a/.github/actions/install_python_and_poetry/action.yml +++ b/.github/actions/install_python_and_poetry/action.yml @@ -6,34 +6,40 @@ inputs: description: "Cache key suffix to append to venv cache key" required: false default: "" + python-version: description: "Python version to use" required: false + python-version-file: description: "Read Python version from given file" required: false + poetry-version: description: "Poetry version to use" required: false - default: "1.2.2" + default: "1.3.0" outputs: python-path: description: "Absolute path to Python executable" value: "${{ steps.python.outputs.python-path }}" + python-version: description: "Installed Python version" value: "${{ steps.python.outputs.python-version }}" + poetry-version: description: "Installed poetry version" value: "${{ inputs.poetry-version }}" runs: using: "composite" + steps: - id: "python" name: "Install Python" - uses: "actions/setup-python@v4.3.0" + uses: "actions/setup-python@v4.3.1" with: python-version: "${{ inputs.python-version }}" python-version-file: "${{ inputs.python-version-file }}" @@ -43,7 +49,7 @@ runs: run: "pipx install --python='${{ steps.python.outputs.python-path }}' poetry==${{ inputs.poetry-version }}" - name: "Cache venv" - uses: "actions/cache@v3.0.10" + uses: "actions/cache@v3.0.11" with: path: "./.venv/" key: "venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}${{ inputs.cache-key-suffix }}" diff --git a/.github/actions/run_pre_commit/action.yml b/.github/actions/run_pre_commit/action.yml index bb66960..61d8cd3 100644 --- a/.github/actions/run_pre_commit/action.yml +++ b/.github/actions/run_pre_commit/action.yml @@ -14,7 +14,7 @@ runs: shell: "bash" - name: "Cache mypy" - uses: "actions/cache@v3.0.10" + uses: "actions/cache@v3.0.11" with: path: "./.mypy_cache/" key: "mypy-${{ runner.os }}-${{ inputs.python-version }}" diff --git a/.github/actions/run_tox/action.yml b/.github/actions/run_tox/action.yml index 7c4f65a..35bb830 100644 --- a/.github/actions/run_tox/action.yml +++ b/.github/actions/run_tox/action.yml @@ -36,7 +36,7 @@ runs: shell: "bash" - name: "Cache tox" - uses: "actions/cache@v3.0.10" + uses: "actions/cache@v3.0.11" with: path: "./.tox/" key: "tox-${{ inputs.python-version }}" diff --git a/.github/workflows/ci_package.yml b/.github/workflows/ci_package.yml index 634cb24..e5aaa5f 100644 --- a/.github/workflows/ci_package.yml +++ b/.github/workflows/ci_package.yml @@ -7,12 +7,13 @@ on: description: "Twine version to use." type: "string" required: false - default: "4.0.1" + default: "4.0.2" secrets: pypi-user: description: "PyPI username to use." required: true + pypi-password: description: "PyPI password (token) to use." required: true @@ -42,7 +43,7 @@ jobs: - name: "Publish package" if: "${{ startsWith(github.ref, 'refs/tags/') }}" - uses: "pypa/gh-action-pypi-publish@v1.5.1" + uses: "pypa/gh-action-pypi-publish@v1.6.4" with: user: "${{ secrets.pypi-user }}" password: "${{ secrets.pypi-password }}" diff --git a/.github/workflows/release_pr.yml b/.github/workflows/release_pr.yml index 9a60c97..5d058ed 100644 --- a/.github/workflows/release_pr.yml +++ b/.github/workflows/release_pr.yml @@ -40,13 +40,13 @@ jobs: run: "badabump --ci ${{ github.event.inputs.args }}" - id: "token" - uses: "tibdex/github-app-token@v1.7" + uses: "tibdex/github-app-token@v1.7.0" with: app_id: "${{ secrets.BADABUMP_APP_ID }}" private_key: "${{ secrets.BADABUMP_APP_PRIVATE_KEY }}" - name: "Create pull request with changed files" - uses: "peter-evans/create-pull-request@v4.2.0" + uses: "peter-evans/create-pull-request@v4.2.3" with: token: "${{ steps.token.outputs.token }}" commit-message: | diff --git a/.github/workflows/release_tag.yml b/.github/workflows/release_tag.yml index 4ee09dd..441a9c6 100644 --- a/.github/workflows/release_tag.yml +++ b/.github/workflows/release_tag.yml @@ -20,7 +20,7 @@ jobs: steps: - id: "token" - uses: "tibdex/github-app-token@v1.7" + uses: "tibdex/github-app-token@v1.7.0" with: app_id: "${{ secrets.BADABUMP_APP_ID }}" private_key: "${{ secrets.BADABUMP_APP_PRIVATE_KEY }}" diff --git a/.gitignore b/.gitignore index 7af5dda..1aad984 100644 --- a/.gitignore +++ b/.gitignore @@ -141,7 +141,6 @@ dmypy.json # AWS CDK files /cdk.out -/cdk.context.json # DotENV files .env.* @@ -153,3 +152,9 @@ dmypy.json # Sublime Text 3 workspace *.sublime-workspace + +# Auto-generated .gz static files +static/**/*.gz + +# Do not ignore dist files in vendored static files +!static/vendor/**/dist/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5180944..a2980a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ exclude: ^(archive|assets|migrations)/.*|.*/(migrations|test-data|vendor)/.*|.*\ minimum_pre_commit_version: "1.17.0" repos: - repo: "https://github.com/commitizen-tools/commitizen" - rev: "v2.35.0" + rev: "v2.37.1" hooks: - id: "commitizen" # By default commitizen using `python3` instead `python` language, so @@ -29,7 +29,7 @@ repos: exclude: ^docs/.*$ - repo: "https://github.com/psf/black" - rev: "22.10.0" + rev: "22.12.0" hooks: - id: "black" # By default black using `python3` instead `python` language, so @@ -48,7 +48,7 @@ repos: - "black==22.10.0" - repo: "https://github.com/pre-commit/pre-commit-hooks" - rev: "v4.3.0" + rev: "v4.4.0" hooks: - id: "end-of-file-fixer" - id: "trailing-whitespace" @@ -71,19 +71,19 @@ repos: - id: "flake8" name: "Lint code (flake8)" additional_dependencies: &flake8_additional_dependencies - - "flake8==5.0.4" - "flake8-broken-line==0.6.0" - - "flake8-bugbear==22.9.23" - - "flake8-builtins==2.0.0" - - "flake8-comprehensions==3.10.0" + - "flake8-bugbear==22.12.6" + - "flake8-builtins==2.0.1" + - "flake8-comprehensions==3.10.1" - "flake8-eradicate==1.4.0" - - "flake8-isort==5.0.0" + - "flake8-isort==5.0.3" - "flake8-mutable==1.2.0" - "flake8-pie==0.16.0" - "flake8-quotes==3.3.1" - "flake8-string-format==0.3.0" - "flake8-tidy-imports==4.8.0" - "flake8-variables-names==0.0.5" + - "flake8==5.0.4" - "pep8-naming==0.13.2" exclude: ^docs/.*$ diff --git a/.python-version b/.python-version index afad818..371cfe3 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.11.0 +3.11.1 diff --git a/python.mk b/python.mk index a56eca2..45d9509 100644 --- a/python.mk +++ b/python.mk @@ -1,22 +1,3 @@ -.PHONY: \ - build-python \ - build-python-only \ - clean-egg-info \ - clean-python \ - distclean-python \ - ensure-venv \ - install-python \ - install-python-only \ - lint-python \ - lint-python-only \ - list-outdated-python \ - poetry \ - python-version \ - test-python \ - test-python-only \ - test-python-setup \ - test-python-teardown - GIT_DIR = .git PYTHON_VERISON = $(shell cat .python-version) @@ -32,19 +13,26 @@ PYENV ?= $(shell if [ -z "${CI}" ]; then echo "pyenv"; fi) PYTHON ?= $(DOTENV) $(PYTHON_BIN) PYTHON_DIST_DIR ?= dist +.PHONY: build-python build-python: install-python build-python-only + +.PHONY: build-python-only build-python-only: $(POETRY) build -vv -f wheel +.PHONY: clean-egg-info clean-egg-info: find . \( -name *.egg-info -a -type d -not -path '$(VENV_DIR)/*' \) -exec rm -rf {} + 2> /dev/null +.PHONY: clean-python clean-python: find . \( -name __pycache__ -o -type d -empty -not -path '$(GIT_DIR)/*' \) -exec rm -rf {} + 2> /dev/null +.PHONY: distclean-python distclean-python: clean-egg-info -rm -rf .coverage .install-python $(VENV_DIR)/ $(PYTHON_DIST_DIR)/ +.PHONY: ensure-venv ensure-venv: .python-version if [ -f "$(PYTHON_BIN)" ]; then \ if [ "$$("$(PYTHON_BIN)" -V)" != "Python $(PYTHON_VERISON)" ]; then \ @@ -56,20 +44,30 @@ ensure-venv: .python-version $(POETRY) env use $$($(PYENV) which python3); \ fi +.PHONY: install-python install-python: .install-python .install-python: poetry.toml $(PYTHON_BIN) poetry.lock touch $@ +.PHONY: install-python-only install-python-only: if [ "$(STAGE)" = "prod" ]; then $(POETRY) install $(POETRY_INSTALL_ARGS) --no-dev; else $(POETRY) install $(POETRY_INSTALL_ARGS); fi +.PHONY: lint-and-test-python +lint-and-test-python: lint-python test-python + +.PHONY: lint-python lint-python: install-python lint-python-only + +.PHONY: lint-python-only lint-python-only: SKIP=$(SKIP) $(PRE_COMMIT) run --all $(HOOK) +.PHONY: list-outdated-python list-outdated-python: install-python $(POETRY) show -o +.PHONY: poetry poetry: $(POETRY) $(ARGS) @@ -80,21 +78,27 @@ poetry.lock: pyproject.toml poetry.toml: $(POETRY) config --local virtualenvs.create true $(POETRY) config --local virtualenvs.in-project true + $(POETRY) config --local virtualenvs.prefer-active-python true +.PHONY: python-version python-version: @echo "Expected: Python $(PYTHON_VERISON)" @if [ -f "$(PYTHON_BIN)" ]; then echo "Virtual env: $$("$(PYTHON_BIN)" -V)"; else echo "Virtual env: -"; fi +.PHONY: test-python test-python: install-python clean-python test-python-only +.PHONY: test-python-only test-python-only: STAGE = test test-python-only: test-python-setup STAGE=$(STAGE) $(PYTHON) -m pytest $(TEST_ARGS) @$(MAKE) -s test-python-teardown +.PHONY: test-python-setup test-python-setup: STAGE = test test-python-setup: +.PHONY: test-python-teardown test-python-teardown: STAGE = test test-python-teardown: