Skip to content

Commit 2ad5c41

Browse files
ci: add precommit dependabot ruff (python-semantic-release#673)
1 parent d70fe75 commit 2ad5c41

87 files changed

Lines changed: 1466 additions & 1119 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "18:00"
10+
commit-message:
11+
prefix: "fix(deps)"
12+
include: "scope"
13+
labels:
14+
- dependencies
15+
open-pull-requests-limit: 10
16+
rebase-strategy: auto

.github/workflows/main.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ on:
55
push:
66
branches:
77
- master
8-
- "8.0.x"
8+
- main
9+
- "pre/*"
910

1011
jobs:
1112
test:
1213
name: Python ${{ matrix.python-version }} tests
1314
runs-on: ubuntu-latest
1415
strategy:
1516
matrix:
16-
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
17+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
1718

1819
steps:
1920
- uses: actions/checkout@v3
@@ -38,7 +39,7 @@ jobs:
3839
- name: pytest
3940
run: PYTHONHASHSEED=123345 python -m pytest -v tests
4041

41-
mypy:
42+
lint:
4243
runs-on: ubuntu-latest
4344

4445
steps:
@@ -47,16 +48,21 @@ jobs:
4748
uses: actions/setup-python@v4
4849
with:
4950
python-version: 3.8
50-
- name: Install mypy & stubs packages
51-
run: python -m pip install .[mypy]
51+
- name: Install mypy & dev packages
52+
run: |
53+
python -m pip install ".[dev, mypy]"
54+
- name: ruff
55+
run: |
56+
python -m ruff check . --config pyproject.toml --diff --show-source
5257
- name: mypy
53-
run: python -m mypy --ignore-missing-imports semantic_release
58+
run: |
59+
python -m mypy --ignore-missing-imports semantic_release
5460
5561
beautify:
5662
name: Beautify
5763
runs-on: ubuntu-latest
5864
concurrency: push
59-
needs: [ test, mypy ]
65+
needs: [test, lint]
6066
outputs:
6167
new_sha: ${{ steps.sha.outputs.SHA }}
6268
permissions:
@@ -78,13 +84,6 @@ jobs:
7884
- name: Beautify with Black
7985
run: python -m black .
8086

81-
- name: Install isort
82-
run: python -m pip install "isort >=5,<6"
83-
# https://pycqa.github.io/isort/docs/upgrade_guides/5.0.0.html
84-
# removed deprecated "-rc" and "-y" arguments
85-
- name: Sort imports
86-
run: python -m isort .
87-
8887
- name: Commit and push changes
8988
uses: github-actions-x/commit@v2.9
9089
with:
@@ -103,7 +102,7 @@ jobs:
103102
name: Semantic Release
104103
runs-on: ubuntu-latest
105104
concurrency: push
106-
needs: [ test, mypy, beautify ]
105+
needs: [test, lint, beautify]
107106
if: github.repository == 'python-semantic-release/python-semantic-release'
108107
permissions:
109108
# https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#metadata

.github/workflows/pr.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: pytest
3737
run: PYTHONHASHSEED=123345 python -m pytest -v tests
3838

39-
mypy:
39+
lint:
4040
runs-on: ubuntu-latest
4141

4242
steps:
@@ -45,8 +45,12 @@ jobs:
4545
uses: actions/setup-python@v4
4646
with:
4747
python-version: 3.8
48-
- name: Install mypy & stubs packages
49-
run: python -m pip install .[mypy]
48+
- name: Install mypy & dev packages
49+
run: |
50+
python -m pip install ".[dev, mypy]"
51+
- name: ruff
52+
run: |
53+
python -m ruff check . --config pyproject.toml --diff --show-source
5054
- name: mypy
5155
run: python -m mypy --ignore-missing-imports semantic_release
5256

.pre-commit-config.yaml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
default_language_version:
3+
python: python3.8
4+
5+
repos:
6+
# Meta hooks
7+
- repo: meta
8+
hooks:
9+
- id: check-hooks-apply
10+
- id: check-useless-excludes
11+
12+
# Security & credential scanning/alerting
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v4.4.0
15+
hooks:
16+
- id: debug-statements
17+
- id: detect-aws-credentials
18+
args: [ "--allow-missing-credentials" ]
19+
- id: detect-private-key
20+
- id: check-builtin-literals
21+
- id: check-executables-have-shebangs
22+
- id: check-shebang-scripts-are-executable
23+
- id: check-yaml
24+
- id: check-toml
25+
- id: check-case-conflict
26+
- id: end-of-file-fixer
27+
- id: trailing-whitespace
28+
- id: check-merge-conflict
29+
- id: mixed-line-ending
30+
- id: check-ast
31+
32+
# Formatters that may modify source files automatically
33+
- repo: https://github.com/psf/black
34+
rev: 23.7.0
35+
hooks:
36+
- id: black
37+
- repo: https://github.com/adamchainz/blacken-docs
38+
rev: 1.15.0
39+
hooks:
40+
- id: blacken-docs
41+
additional_dependencies: [ "black==23.7.0" ]
42+
43+
- repo: https://github.com/asottile/pyupgrade
44+
rev: v3.9.0
45+
hooks:
46+
- id: pyupgrade
47+
args: [ "--py37-plus", "--keep-runtime-typing" ]
48+
49+
# Linters and validation
50+
- repo: https://github.com/astral-sh/ruff-pre-commit
51+
rev: v0.0.282
52+
hooks:
53+
- id: ruff
54+
args:
55+
- "--fix"
56+
- "--exit-non-zero-on-fix"
57+
- "--statistics"
58+
- "--format=text"
59+
- "."
60+
pass_filenames: false
61+
62+
- repo: https://github.com/pre-commit/mirrors-mypy
63+
rev: "v1.4.1"
64+
hooks:
65+
- id: mypy
66+
args: [ "--config-file", "pyproject.toml" ]
67+
additional_dependencies:
68+
- "pydantic>1.10.11,<2"
69+
- "types-requests"
70+
log_file: "mypy.log"
71+
files: "^semantic_release/.*"
72+
pass_filenames: false
73+
74+
- repo: https://github.com/pre-commit/pygrep-hooks
75+
rev: v1.10.0
76+
hooks:
77+
# - id: python-use-type-annotations
78+
- id: python-check-blanket-noqa
79+
- id: python-check-blanket-type-ignore
80+
- id: python-check-mock-methods
81+
- id: python-no-eval
82+
- id: python-no-log-warn
83+
- id: rst-backticks
84+
- id: rst-directive-colons
85+
- id: rst-inline-touching-normal
86+
87+
- repo: https://github.com/jendrikseipp/vulture
88+
rev: "v2.7"
89+
hooks:
90+
- id: vulture
91+
args:
92+
- --min-confidence
93+
- "100"
94+
- --sort-by-size
95+
- "semantic_release"
96+
- "tests"
97+
98+
- repo: https://github.com/pycqa/bandit
99+
rev: 1.7.5
100+
hooks:
101+
- id: bandit
102+
args:
103+
- "-c"
104+
- "pyproject.toml"
105+
- "--quiet"
106+
- "semantic_release/"
107+
# Needed if using pyproject.toml for config
108+
additional_dependencies: [ "bandit[toml]" ]
109+
pass_filenames: false
110+
111+
# GHA linting
112+
- repo: https://github.com/python-jsonschema/check-jsonschema
113+
rev: "0.23.3"
114+
hooks:
115+
- id: check-github-workflows
116+
- id: check-readthedocs
117+
- id: check-dependabot

0 commit comments

Comments
 (0)