Skip to content

Commit e2a0619

Browse files
authored
Merge pull request #16 from giancarlosisasi/tooling-improvement
Modernize dev tooling (uv, Ruff, Pyrefly, pydantic v2, click 8, GH Actions)
2 parents 39f28a9 + 9589eb4 commit e2a0619

37 files changed

Lines changed: 6807 additions & 9869 deletions

‎.dockerignore‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.git
2+
.github
3+
.venv
4+
__pycache__
5+
*.pyc
6+
node_modules
7+
dist
8+
build
9+
*.egg-info
10+
.pytest_cache
11+
.ruff_cache
12+
.mypy_cache
13+
.coverage
14+
cov.xml

‎.github/workflows/ci.yml‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ci-${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
quality:
17+
name: Format, lint & type check
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up uv
22+
uses: astral-sh/setup-uv@v6
23+
with:
24+
enable-cache: true
25+
python-version: "3.14"
26+
- name: Install dependencies
27+
run: uv sync --frozen
28+
- name: Check formatting
29+
run: uv run ruff format --check
30+
- name: Lint
31+
run: uv run ruff check
32+
- name: Type check
33+
run: uv run pyrefly check
34+
35+
test:
36+
name: Test (Python ${{ matrix.python-version }})
37+
needs: quality
38+
runs-on: ubuntu-latest
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
python-version: ["3.13", "3.14"]
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Set up uv
46+
uses: astral-sh/setup-uv@v6
47+
with:
48+
enable-cache: true
49+
python-version: ${{ matrix.python-version }}
50+
- name: Install dependencies
51+
run: uv sync --frozen
52+
- name: Run tests with coverage
53+
run: uv run pytest

‎.github/workflows/danger.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v4
1111
- name: Run Danger
1212
uses: ./
1313
env:

‎.gitignore‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ target/
7272
# Jupyter Notebook
7373
.ipynb_checkpoints
7474

75-
# pyenv
76-
.python-version
75+
# pyenv / uv — .python-version IS tracked: it pins the uv-managed interpreter (3.14)
7776

7877
# celery beat schedule file
7978
celerybeat-schedule
@@ -106,3 +105,5 @@ venv.bak/
106105
# Coverage report
107106
cov.xml
108107

108+
109+
.ruff_cache

‎.python-version‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.14

‎.travis.yml‎

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

‎CHANGELOG.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
* No changes.
44

5+
### 0.2.0
6+
7+
**BREAKING** — Toolchain modernization and runtime baseline bump. The Danger DSL, the
8+
danger-js invocation contract, and the model JSON shapes are unchanged; the 100%
9+
test-coverage gate is preserved.
10+
11+
* **BREAKING:** Dropped support for Python 3.7–3.12. `danger-python` now requires **Python 3.13+** (developed and tested on 3.14).
12+
* **BREAKING:** Migrated the runtime from **pydantic v1 to pydantic v2** (implementation only — model JSON input/output is byte-compatible).
13+
* **BREAKING:** Migrated the CLI from **click 7 to click 8**.
14+
* Replaced **Poetry** with **uv** for environment, dependency, and lockfile management: PEP 621 `[project]` metadata, committed `uv.lock`, and the `uv_build` backend.
15+
* Replaced **black + isort + flake8 + pylint** with **Ruff** for linting and formatting.
16+
* Replaced **mypy** with **Pyrefly** for type checking.
17+
* Consolidated all tool configuration into `pyproject.toml`; removed `setup.cfg`.
18+
* Replaced **Travis CI** with **GitHub Actions** (`ci.yml`, Python 3.13/3.14 matrix); updated the `Dockerfile` to `python:3.14-slim` + Node 20 + uv.
19+
520
### 0.1.0
621

722
* Initial release of the plugin. - [@turekj]

‎Dockerfile‎

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1-
FROM python:3.7
1+
FROM python:3.14-slim
22

33
LABEL maintainer="Jakub Turek <jkbturek@gmail.com>"
4-
LABEL "com.github.actions.name"="danger-python"
5-
LABEL "com.github.actions.description"="Runs Python Dangerfiles"
6-
LABEL "com.github.actions.icon"="zap"
7-
LABEL "com.github.actions.color"="blue"
84

9-
# Install dependencies
10-
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
11-
RUN apt-get install -y nodejs
5+
# danger-python shells out to danger-js, so the image needs Node. Install
6+
# Node 20 via NodeSource. python:*-slim ships without curl / gnupg /
7+
# ca-certificates, which the NodeSource setup script requires.
8+
RUN apt-get update \
9+
&& apt-get install -y --no-install-recommends \
10+
ca-certificates \
11+
curl \
12+
gnupg \
13+
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
14+
&& apt-get install -y --no-install-recommends nodejs \
15+
&& rm -rf /var/lib/apt/lists/*
1216

13-
RUN python -m pip install --upgrade pip
14-
RUN pip install poetry
17+
# Install uv (dependency / environment manager) from its official image.
18+
COPY --from=ghcr.io/astral-sh/uv:0.11 /uv /uvx /bin/
1519

16-
RUN mkdir -p /usr/src/danger-python
17-
COPY . /usr/src/danger-python
18-
RUN cd /usr/src/danger-python && \
19-
poetry config virtualenvs.create false && \
20-
poetry install --no-dev
20+
WORKDIR /usr/src/danger-python
21+
COPY . .
22+
23+
# Install the package and its runtime dependencies from the committed lockfile
24+
# into an in-project virtualenv (no dev tools), then put that venv on PATH so
25+
# the `danger-python` console script the entrypoint calls is resolvable. Use
26+
# the base image's Python 3.14 rather than downloading a second interpreter.
27+
ENV UV_LINK_MODE=copy \
28+
UV_PYTHON_DOWNLOADS=never \
29+
UV_PYTHON_PREFERENCE=only-system
30+
RUN uv sync --frozen --no-dev --no-editable
31+
ENV PATH="/usr/src/danger-python/.venv/bin:${PATH}"
2132

2233
ENTRYPOINT ["npx", "--package", "danger", "danger-python", "ci"]

‎README.md‎

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![PyPI](https://img.shields.io/pypi/v/danger-python)](https://pypi.org/project/danger-python/)
2-
![Python versions](https://img.shields.io/pypi/pyversions/danger-python)
3-
[![Build Status](https://travis-ci.org/danger/python.svg?branch=master)](https://travis-ci.org/danger/python)
2+
![Python versions](https://img.shields.io/badge/python-3.13%20%7C%203.14-blue)
3+
[![CI](https://github.com/giancarlosisasi/danger-python/actions/workflows/ci.yml/badge.svg)](https://github.com/giancarlosisasi/danger-python/actions/workflows/ci.yml)
44

55
# python
66

@@ -12,7 +12,7 @@ Write your Dangerfiles in Python.
1212

1313
Running `danger-python` requires:
1414

15-
* Python 3.7 (tested under Python 3.7.5)
15+
* Python 3.13+ (developed and tested under Python 3.14)
1616
* danger-js 9.2 (tested under danger-js 9.2.10)
1717

1818
### Installation
@@ -61,63 +61,63 @@ jobs:
6161
runs-on: ubuntu-latest
6262

6363
steps:
64-
- uses: actions/checkout@v2
64+
- uses: actions/checkout@v4
6565
- uses: danger/python@master
6666
env:
6767
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6868
```
6969
70-
### Using as a CI step (Travis)
70+
### Using as a CI step
7171
72-
1. Create a `dangerfile.py` in the root directory of your repository.
73-
2. Set up the CI to execute the `danger-python` script after the test suite.
74-
75-
Example `.travis.yml` configuration:
72+
If you already run your own pipeline, add `danger-python` as a step after your test suite
73+
instead of using the prebuilt action above. This works on any CI provider — the example
74+
below uses GitHub Actions:
7675

7776
```yaml
78-
language: python
79-
python:
80-
- "3.7"
81-
cache:
82-
yarn: true
83-
pip: true
84-
directories:
85-
- node_modules
86-
install:
87-
- pip install poetry
88-
- poetry install
89-
script:
90-
- poetry run pytest
91-
after_script:
92-
- nvm install 10.16.0
93-
- nvm use 10.16.0
94-
- yarn global add danger
95-
- pip install danger-python
96-
- danger-python ci -v
77+
name: CI
78+
on: [pull_request]
79+
80+
jobs:
81+
build:
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: actions/checkout@v4
85+
- uses: actions/setup-python@v5
86+
with:
87+
python-version: "3.14"
88+
- uses: actions/setup-node@v4
89+
with:
90+
node-version: "20"
91+
# ... install dependencies and run your test suite here ...
92+
- run: npm install -g danger
93+
- run: pip install danger-python
94+
- run: danger-python ci -v
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9797
```
9898

9999
### Development
100100

101101
To develop the `danger-python`, clone the repository and run the following commands:
102102

103103
```sh
104-
# install danger
104+
# install danger-js
105105
npm install -g danger
106-
# install poetry
107-
pip install poetry
108-
# install project dependencies
109-
poetry install
110-
# activate virtual environment
111-
poetry shell
112-
# run tests
113-
pytest
106+
# install uv (https://docs.astral.sh/uv/getting-started/installation/)
107+
# create the virtual environment and install all dependencies from uv.lock
108+
uv sync
109+
# run the full local gate: format, lint, type-check, tests (enforces 100% coverage)
110+
uv run ruff format --check
111+
uv run ruff check
112+
uv run pyrefly check
113+
uv run pytest
114114
```
115115

116116
To regenerate the input JSONSchema, put the latest version in `scripts/input_schema.json` and run the following commands:
117117

118118
```sh
119119
cd scripts
120-
python generate_scheme.py
120+
uv run python generate_scheme.py
121121
```
122122

123123
This should update the `danger_python/models.py` file.

‎action.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: "danger-python"
2+
description: "Runs Python Dangerfiles"
3+
branding:
4+
icon: "zap"
5+
color: "blue"
6+
runs:
7+
using: "docker"
8+
image: "Dockerfile"

0 commit comments

Comments
 (0)