Skip to content

Commit

Permalink
chore: Sync common project files (#183)
Browse files Browse the repository at this point in the history
As well as,

- Use Python 3.10.7 as dev version
- Separate dev & test dependencies via poetry groups
- Do not install test deps on running pre-commit
- Exclude docs & tests from mypy checks

Co-authored-by: badabump-release-bot[bot] <badabump-release-bot[bot]@users.noreply.github.com>
Co-authored-by: Igor Davydenko <iam@igordavydenko.com>
  • Loading branch information
3 people authored Oct 9, 2022
1 parent a99885f commit 067678b
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 163 deletions.
10 changes: 7 additions & 3 deletions .github/actions/install_python_and_poetry/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: "Install Python & poetry"
description: "Composite action to setup Python, install poetry, and setup cache for venv."

inputs:
cache-key-suffix:
description: "Cache key suffix to append to venv cache key"
required: false
default: ""
python-version:
description: "Python version to use"
required: false
Expand All @@ -11,7 +15,7 @@ inputs:
poetry-version:
description: "Poetry version to use"
required: false
default: "1.1.14"
default: "1.2.1"

outputs:
python-path:
Expand Down Expand Up @@ -39,7 +43,7 @@ runs:
run: "pipx install --python='${{ steps.python.outputs.python-path }}' poetry==${{ inputs.poetry-version }}"

- name: "Cache venv"
uses: "actions/cache@v3.0.6"
uses: "actions/cache@v3.0.10"
with:
path: "./.venv/"
key: "venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}"
key: "venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}${{ inputs.cache-key-suffix }}"
4 changes: 2 additions & 2 deletions .github/actions/run_pre_commit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ runs:
using: "composite"
steps:
- name: "Install package"
run: "poetry install"
run: "poetry install --only main,dev"
shell: "bash"

- name: "Cache mypy"
uses: "actions/cache@v3.0.6"
uses: "actions/cache@v3.0.10"
with:
path: "./.mypy_cache/"
key: "mypy-${{ runner.os }}-${{ inputs.python-version }}"
Expand Down
11 changes: 8 additions & 3 deletions .github/actions/run_tox/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ inputs:
tox-version:
description: "Tox version to use"
required: false
default: "3.25.0"
default: "3.26.0"
tox-gh-actions-version:
description: "Tox GitHub Actions plugin version to use"
required: false
default: "2.9.1"
default: "2.10.0"
use-coveralls:
description: "Send coverage to Coveralls"
required: false
Expand All @@ -36,7 +36,7 @@ runs:
shell: "bash"

- name: "Cache tox"
uses: "actions/cache@v3.0.6"
uses: "actions/cache@v3.0.10"
with:
path: "./.tox/"
key: "tox-${{ inputs.python-version }}"
Expand All @@ -45,6 +45,11 @@ runs:
run: "tox"
shell: "bash"

- name: "Install project"
if: "${{ inputs.use-coveralls == 'true' }}"
run: "poetry install --only test"
shell: "bash"

- name: "Send coverage to Coveralls"
if: "${{ inputs.use-coveralls == 'true' }}"
env:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ jobs:

- uses: "./.github/actions/install_python_and_poetry"
with:
cache-key-suffix: "-main"
python-version-file: ".python-version"

- name: "Install package"
run: "poetry install"
run: "poetry install --only main"

- name: "Import package"
run: "poetry run python3 -c 'import badabump'"
Expand All @@ -56,7 +57,10 @@ jobs:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11.0-beta - 3.11"]
include:
- cache-key-suffix: "-main-dev"

- python-version: "3.10"
cache-key-suffix: "-main-dev-test"
dev: "true"

runs-on: "ubuntu-latest"
Expand All @@ -68,6 +72,7 @@ jobs:
- id: "python_and_poetry"
uses: "./.github/actions/install_python_and_poetry"
with:
cache-key-suffix: "${{ matrix.cache-key-suffix }}"
python-version: "${{ matrix.python-version }}"

- if: "${{ matrix.dev == 'true' }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v3.0.2"
- uses: "actions/checkout@v3.1.0"

- id: "python_and_poetry"
uses: "./.github/actions/install_python_and_poetry"
Expand Down
26 changes: 13 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
minimum_pre_commit_version: "1.17.0"
repos:
- repo: "https://github.com/commitizen-tools/commitizen"
rev: "v2.29.3"
rev: "v2.35.0"
hooks:
- id: "commitizen"
# By default commitizen using `python3` instead `python` language, so
Expand All @@ -19,7 +19,7 @@ repos:
exclude: ^docs/.*$

- repo: "https://github.com/psf/black"
rev: "22.6.0"
rev: "22.10.0"
hooks:
- id: "black"
# By default black using `python3` instead `python` language, so
Expand All @@ -35,7 +35,7 @@ repos:
name: "Format docs (blacken-docs)"
args: ["-l", "64"]
additional_dependencies:
- "black==22.3.0"
- "black==22.10.0"

- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v4.3.0"
Expand All @@ -47,25 +47,25 @@ repos:
- id: "check-yaml"

- repo: "https://github.com/PyCQA/flake8"
rev: "4.0.1"
rev: "5.0.4"
hooks:
- id: "flake8"
name: "Lint code (flake8)"
additional_dependencies: &flake8_additional_dependencies
- "flake8==4.0.1"
- "flake8-broken-line==0.4.0"
- "flake8-bugbear==22.7.1"
- "flake8-builtins==1.5.3"
- "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-eradicate==1.2.1"
- "flake8-isort==4.1.2.post0"
- "flake8-eradicate==1.4.0"
- "flake8-isort==5.0.0"
- "flake8-mutable==1.2.0"
- "flake8-pie==0.15.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"
- "pep8-naming==0.13.1"
- "pep8-naming==0.13.2"
exclude: ^docs/.*$

- repo: "https://github.com/asottile/yesqa"
Expand All @@ -84,4 +84,4 @@ repos:
language: "python"
"types": ["python"]
require_serial: true
exclude: ^./docs/.*$
exclude: ^(docs|tests)/.*$
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10.6
3.10.7
Loading

0 comments on commit 067678b

Please sign in to comment.