Skip to content

Commit

Permalink
refactor(no-release): make ruff standalone (serious-scaffold#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored Jul 4, 2024
1 parent 728b70e commit 175f7cd
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ RUN if [ "${PYTHON_VERSION}" = "3.8" ]; then \
pipx install pre-commit==3.7.1; \
fi

# Install prerequisites
RUN --mount=source=Makefile,target=Makefile \
make prerequisites

# Create a non-root user with sudo permission
ARG USERNAME=ss-python
ARG USER_UID=1000
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*
.*
!/Makefile
!/README.md
!/pdm.lock
!/pyproject.toml
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
python-version: ${{ matrix.python-version }}
version: 2.16.1
- run: env | sort
- run: make prerequisites
- run: make dev
- run: make lint test doc build
strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitlab/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ci:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- make prerequisites
- make dev
- make lint test doc build
stage: ci
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ repos:
require_serial: true
- id: ruff
name: ruff
entry: pdm run python -m ruff check --force-exclude
entry: ruff check --force-exclude
language: system
types_or:
- python
- pyi
require_serial: true
- id: ruff-format
name: ruff-format
entry: pdm run python -m ruff format --force-exclude
entry: ruff format --force-exclude
language: system
types_or:
- python
Expand Down
2 changes: 2 additions & 0 deletions .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"datasourceTemplate": "pypi",
"description": "Match Python packages installed with pip/pipx",
"fileMatch": [
"^Makefile$",
"^README\\.md$",
"^\\.devcontainer/Dockerfile$",
"^\\.github/workflows/.+\\.yml$",
Expand All @@ -20,6 +21,7 @@
"^includes/sample\\.jinja$",
"^template/.*\\.github.*/workflows/.+\\.yml(\\.jinja)?$",
"^template/.*\\.gitlab.*/workflows/.+\\.yml(\\.jinja)?$",
"^template/Makefile\\.jinja$",
"^template/\\.devcontainer/Dockerfile\\.jinja$",
"^template/\\.readthedocs\\.yaml$",
"^template/\\.renovaterc\\.json\\.jinja$",
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean deepclean install dev mypy ruff ruff-format toml-sort lint pre-commit test-run test build publish doc-autobuild doc-gen doc-mypy doc-coverage doc consistency
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format toml-sort lint pre-commit test-run test build publish doc-autobuild doc-gen doc-mypy doc-coverage doc consistency

########################################################################################
# Variables
Expand Down Expand Up @@ -51,6 +51,10 @@ dev:
pdm install
if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi

# Install standalone tools
prerequisites:
pipx install --force ruff==0.5.0

########################################################################################
# Lint and pre-commit
########################################################################################
Expand All @@ -61,11 +65,11 @@ mypy:

# Lint with ruff.
ruff:
pdm run python -m ruff check .
ruff check .

# Format with ruff.
ruff-format:
pdm run python -m ruff format --check .
ruff format --check .

# Check lint with toml-sort.
toml-sort:
Expand Down
29 changes: 1 addition & 28 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ doc = [
]
lint = [
"mypy",
"ruff",
"toml-sort",
]
test = [
Expand Down
1 change: 1 addition & 0 deletions template/.devcontainer/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*
.*
!/Makefile
!/README.md
!/pdm.lock
!/pyproject.toml
Expand Down
4 changes: 4 additions & 0 deletions template/.devcontainer/Dockerfile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ RUN if [ "${PYTHON_VERSION}" = "3.8" ]; then \
pipx install pre-commit==3.7.1; \
fi

# Install prerequisites
RUN --mount=source=Makefile,target=Makefile \
make prerequisites

# Create a non-root user with sudo permission
ARG USERNAME={{ repo_name }}
ARG USER_UID=1000
Expand Down
4 changes: 2 additions & 2 deletions template/.pre-commit-config.yaml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ repos:
require_serial: true
- id: ruff
name: ruff
entry: pdm run python -m ruff check --force-exclude
entry: ruff check --force-exclude
language: system
types_or:
- python
- pyi
require_serial: true
- id: ruff-format
name: ruff-format
entry: pdm run python -m ruff format --force-exclude
entry: ruff format --force-exclude
language: system
types_or:
- python
Expand Down
2 changes: 2 additions & 0 deletions template/.renovaterc.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"datasourceTemplate": "pypi",
"description": "Match Python packages installed with pip/pipx",
"fileMatch": [
"^Makefile$",
"^README\\.md$",
"^\\.devcontainer/Dockerfile$",
"^\\.github/workflows/.+\\.yml$",
Expand All @@ -22,6 +23,7 @@
"^includes/sample\\.jinja$",
"^template/.*\\.github.*/workflows/.+\\.yml(\\.jinja)?$",
"^template/.*\\.gitlab.*/workflows/.+\\.yml(\\.jinja)?$",
"^template/Makefile\\.jinja$",
"^template/\\.devcontainer/Dockerfile\\.jinja$",
"^template/\\.readthedocs\\.yaml$",
"^template/\\.renovaterc\\.json\\.jinja$",
Expand Down
10 changes: 7 additions & 3 deletions template/Makefile.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[% from pathjoin("includes", "variable.jinja") import page_url with context -%]
.PHONY: clean deepclean install dev mypy ruff ruff-format toml-sort lint pre-commit test-run test build publish doc-autobuild doc-gen doc-mypy doc-coverage doc
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format toml-sort lint pre-commit test-run test build publish doc-autobuild doc-gen doc-mypy doc-coverage doc
[%- if project_name == "Serious Scaffold Python" %] consistency[% endif %]

########################################################################################
Expand Down Expand Up @@ -53,6 +53,10 @@ dev:
pdm install
if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi

# Install standalone tools
prerequisites:
pipx install --force ruff==0.5.0

########################################################################################
# Lint and pre-commit
########################################################################################
Expand All @@ -63,11 +67,11 @@ mypy:

# Lint with ruff.
ruff:
pdm run python -m ruff check .
ruff check .

# Format with ruff.
ruff-format:
pdm run python -m ruff format --check .
ruff format --check .

# Check lint with toml-sort.
toml-sort:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
python-version: {{ '${{ matrix.python-version }}' }}
version: 2.16.1
- run: env | sort
- run: make prerequisites
- run: make dev
- run: make lint test doc build
strategy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ci:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- make prerequisites
- make dev
- make lint test doc build
stage: ci
Expand Down
1 change: 0 additions & 1 deletion template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ doc = [
]
lint = [
"mypy",
"ruff",
"toml-sort",
]
test = [
Expand Down

0 comments on commit 175f7cd

Please sign in to comment.