Skip to content

Commit fc76737

Browse files
committed
Overhaul tooling
1 parent 5a56adb commit fc76737

21 files changed

+1095
-1282
lines changed

.pylintrc

Lines changed: 0 additions & 554 deletions
This file was deleted.

Containerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
FROM registry.access.redhat.com/ubi9/python-311
1+
FROM registry.access.redhat.com/ubi9/python-312
22

33
USER root
44

5-
ENV GO_VERSION=1.22.8
6-
RUN curl -Ls https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz | \
7-
tar -C /usr/local -zxvf - go/
5+
ENV GO_VERSION=1.24.3
86
ENV PATH="/usr/local/go/bin:$PATH"
97

8+
RUN dnf install -y tar gzip git make && \
9+
curl -Ls https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz | \
10+
tar -C /usr/local -zxvf - go/
11+
1012
WORKDIR /src
1113
COPY . .
1214
RUN python -m pip install .
1315

1416
WORKDIR /working
1517
RUN rm -rf /src
16-
RUN chown default .
18+
RUN chown 1001:0 .
1719
RUN chmod 0777 .
1820

19-
USER default
21+
USER 1001
2022
ENTRYPOINT [ "/opt/app-root/bin/rebasebot" ]

Makefile

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
1-
PYTHON=python3
2-
3-
.PHONY: deps
4-
deps:
5-
$(PYTHON) -m pip install --upgrade pip
6-
$(PYTHON) -m pip install --upgrade -r requirements-hacking.txt
1+
SRC_DIRS = rebasebot tests
72

83
.PHONY: unittests
9-
unittests:
4+
unittests: ## Run unit & integration tests
105
hack/tests.sh
116

127
.PHONY: lint
13-
lint:
14-
$(PYTHON) -m flake8 --max-line-length=120 rebasebot tests
15-
$(PYTHON) -m pylint rebasebot tests
16-
$(PYTHON) -m mypy rebasebot tests --no-strict-optional --ignore-missing-imports
8+
lint: ## Run lint and format in check mode
9+
uv tool run ruff check $(SRC_DIRS)
10+
uv tool run ruff format --check $(SRC_DIRS)
11+
12+
.PHONY: lint-fix
13+
lint-fix: ## Fix fixable lint issues and format code
14+
uv tool run ruff format $(SRC_DIRS)
15+
uv tool run ruff check --fix $(SRC_DIRS)
1716

1817
.PHONY: venv
19-
venv:
20-
$(PYTHON) -m venv env
18+
venv: ## Create venv
19+
uv venv
20+
21+
.PHONY: install
22+
install: ## Install into your user python environment.
23+
python -m pip install --user .
24+
25+
.PHONY: build
26+
build: ## Create build tarball
27+
uv build
28+
29+
.PHONY: help
30+
help: ## Display this help screen
31+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
32+
33+
.PHONY: clean
34+
clean:
35+
rm -r dist/ build/ .pytest_cache/ .mypy_cache rebasebot.egg-info .coverage
2136

22-
install:
23-
$(PYTHON) -m pip install --user .
37+
# old target still referenced in ci
38+
.PHONY: deps

hack/configure-hooks.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

hack/lint

Lines changed: 0 additions & 39 deletions
This file was deleted.

hack/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ if [ "$OPENSHIFT_CI" == "true" ] && [ -n "$ARTIFACT_DIR" ] && [ -d "$ARTIFACT_DI
3737
fi
3838

3939
set -x
40-
pytest $PYTEST_ARGS "$REPO_ROOT"
40+
uv run pytest $PYTEST_ARGS "$REPO_ROOT"

main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def main():
2+
print("Hello from rebasebot!")
3+
4+
5+
if __name__ == "__main__":
6+
main()

pyproject.toml

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,72 @@
11
[build-system]
2-
requires = [
3-
"setuptools>=42",
4-
"wheel"
5-
]
2+
requires = ["setuptools>=42", "wheel"]
63
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "rebasebot"
7+
version = "0.0.1"
8+
description = "A tool to sync downstream repositories with their upstream"
9+
readme = "README.md"
10+
requires-python = ">=3.11"
11+
12+
dependencies = [
13+
"github3-py>=4.0.1",
14+
"gitpython>=3.1.44",
15+
]
16+
17+
[dependency-groups]
18+
dev = [
19+
"pytest>=8.3.5",
20+
"pytest-cov>=6.1.1",
21+
]
22+
23+
[project.scripts]
24+
rebasebot = "rebasebot.cli:main"
25+
26+
[tool.setuptools.packages.find]
27+
where = ["."]
28+
29+
[tool.setuptools.package-data]
30+
rebasebot = ["builtin-hooks/**"]
31+
32+
[tool.ruff]
33+
line-length = 120
34+
35+
[tool.ruff.lint]
36+
ignore = [
37+
"PLR0912", # too many branches
38+
"PLR0913", # too many arguments
39+
"PLR0915", # too many statements
40+
"PLR0911", # too many return statements
41+
# Enabling these rules would require significant refactoring
42+
]
43+
44+
select = [
45+
"E", # pycodestyle errors
46+
"W", # pycodestyle warnings
47+
"F", # pyflakes - undefined names, unused imports
48+
"I", # isort - import sorting
49+
"B", # flake8-bugbear - common bugs and design problems
50+
"C4", # flake8-comprehensions - better list/set/dict comprehensions
51+
"UP", # pyupgrade - upgrade syntax for newer Python versions
52+
"PL", # pylint - static analysis rules
53+
#"D", # pydocstyle - docstring conventions
54+
#"N", # pep8-naming - naming conventions
55+
#"RET", # flake8-return - return statement patterns
56+
#"SIM", # flake8-simplify - code simplification
57+
#"PTH", # flake8-use-pathlib - prefer pathlib over os.path
58+
# TODO Enable the currently disabled rules
59+
]
60+
61+
[tool.ruff.lint.per-file-ignores]
62+
"tests/**/*.py" = ["PLR2004", "D"] # allow magic values, disable docstring checks in tests
63+
64+
[tool.ruff.lint.pep8-naming]
65+
ignore-names = ["i", "j", "k", "ex", "Run", "_"] # allow common single-letter variable names
66+
67+
[tool.ruff.format]
68+
quote-style = "double"
69+
indent-style = "space"
70+
71+
[tool.ruff.lint.isort]
72+
known-first-party = ["rebasebot"] # treat rebasebot as first-party for import sorting

0 commit comments

Comments
 (0)