Skip to content

Commit 4b09a89

Browse files
dguidodependabot[bot]claudeBoyan-MILANOV
authored
Modernize build system with uv and ruff (#144)
* Bump actions/download-artifact from 4 to 5 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 5. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@v4...v5) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Bump picklescan from 0.0.16 to 0.0.27 in /pickle_scanning_benchmark Bumps [picklescan](https://github.com/mmaitre314/picklescan) from 0.0.16 to 0.0.27. - [Release notes](https://github.com/mmaitre314/picklescan/releases) - [Commits](https://github.com/mmaitre314/picklescan/commits/v0.0.27) --- updated-dependencies: - dependency-name: picklescan dependency-version: 0.0.27 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump requests from 2.32.3 to 2.32.4 in /pickle_scanning_benchmark Bumps [requests](https://github.com/psf/requests) from 2.32.3 to 2.32.4. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](psf/requests@v2.32.3...v2.32.4) --- updated-dependencies: - dependency-name: requests dependency-version: 2.32.4 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Modernize build system with uv and ruff - Replace flit with hatchling as build backend - Update pyproject.toml with comprehensive ruff configuration - Replace black with ruff format for code formatting - Modernize Makefile to use uv instead of venv/pip - Update CI/CD workflows to use uv and ruff - Add pre-commit configuration with ruff and mypy - Add comprehensive development documentation - Expand ruff linting rules for better code quality This modernizes the entire build system to use the latest Python tooling standards while maintaining backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Modernize build system with uv and ruff, harden GitHub Actions Build System Modernization: - Replace flit with hatchling as build backend - Update pyproject.toml with comprehensive ruff configuration - Replace black with ruff format for code formatting - Modernize Makefile to use uv instead of venv/pip - Add pre-commit configuration with ruff and mypy - Add comprehensive development documentation - Expand ruff linting rules for better code quality GitHub Actions Security Hardening: - Pin all actions to specific commit SHAs (except Claude action) - Use latest versions: checkout v5.0.0, setup-python v5.6.0, setup-uv v6.5.0 - Add explicit minimal permissions to all workflows and jobs - Set persist-credentials: false on all checkout actions - Update release workflow to use uv for building - Leave Claude action unpinned for active development updates Reduces zizmor security findings from 31 to 1 (intentional). 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: Simplify DEVELOPMENT.md and add uv installation to README - Make DEVELOPMENT.md more concise (196 → 56 lines) - Add uv installation instructions alongside pip in README - Focus on essential developer information 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * style: Apply ruff formatting to all Python files Formatted 16 files to ensure consistent code style across the project * ci: Allow mypy to fail without blocking CI Add continue-on-error to mypy step since there are 295 pre-existing type errors in the codebase that need to be addressed separately * fix: apply ruff linting fixes and configure ignore rules for pre-existing issues - Applied safe automatic fixes from ruff (27 fixes) - Configured ruff to ignore pre-existing issues that require more extensive refactoring - Fixed issues: superfluous else returns/raises, f-string conversions, unused noqa directives - Deferred fixes: pathlib migrations, mutable class defaults, context managers (for future PRs) These changes ensure CI passes while maintaining code functionality. * Lint format --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Boyan MILANOV <boyan.milanov@trailofbits.com>
1 parent 874079c commit 4b09a89

28 files changed

+1762
-232
lines changed

.github/workflows/claude.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
pull_request_review:
1111
types: [submitted]
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
claude:
1518
if: |
@@ -28,6 +31,7 @@ jobs:
2831
uses: actions/checkout@v5
2932
with:
3033
fetch-depth: 1
34+
persist-credentials: false
3135

3236
- name: Run Claude Code
3337
id: claude
@@ -55,5 +59,4 @@ jobs:
5559

5660
# Optional: Custom environment variables for Claude
5761
# claude_env: |
58-
# NODE_ENV: test
59-
62+
# NODE_ENV: test

.github/workflows/lint.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,52 @@ on:
66
- master
77
pull_request:
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
lint-python:
11-
uses: trailofbits/.github/.github/workflows/make-lint.yml@v0.1.3
12-
with:
13-
language: "python"
14-
python-version: "3.9"
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
steps:
18+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19+
with:
20+
persist-credentials: false
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
24+
with:
25+
enable-cache: true
26+
cache-dependency-glob: "uv.lock"
27+
28+
- name: Set up Python
29+
run: uv python install 3.11
30+
31+
- name: Install dependencies
32+
run: uv sync --extra lint
33+
34+
- name: Check formatting with ruff
35+
run: uv run ruff format --check .
36+
37+
- name: Lint with ruff
38+
run: uv run ruff check fickling
39+
40+
- name: Type check with mypy
41+
run: uv run mypy fickling
42+
continue-on-error: true # TODO: Remove once type annotations are fixed
1543

1644
all-lints-pass:
1745
if: always()
18-
46+
permissions:
47+
contents: read
1948
needs:
2049
- lint-python
2150

2251
runs-on: ubuntu-latest
2352

2453
steps:
2554
- name: check test jobs
26-
uses: re-actors/alls-green@v1.2.2
55+
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
2756
with:
28-
jobs: ${{ toJSON(needs) }}
57+
jobs: ${{ toJSON(needs) }}

.github/workflows/pip-audit.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@ on:
88
schedule:
99
- cron: "0 12 * * *"
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
pip-audit:
1316
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
1419

1520
steps:
1621
- name: Checkout repository
17-
uses: actions/checkout@v5
22+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
23+
with:
24+
persist-credentials: false
1825

1926
- name: Install Python
20-
uses: actions/setup-python@v5
27+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2128
with:
2229
python-version: "3.10"
2330

@@ -30,7 +37,6 @@ jobs:
3037
3138
3239
- name: Run pip-audit
33-
uses: pypa/gh-action-pip-audit@v1.1.0
40+
uses: pypa/gh-action-pip-audit@1220774d901786e6f652ae159f7b6bc8fea6d266 # v1.1.0
3441
with:
35-
virtual-environment: /tmp/pip-audit-env
36-
42+
virtual-environment: /tmp/pip-audit-env

.github/workflows/release.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,33 @@ on:
44
release:
55
types: [published]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
build-release:
9-
1012
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
1115

1216
steps:
13-
- uses: actions/checkout@v5
17+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
18+
with:
19+
persist-credentials: false
1420

1521
- name: Set up Python
16-
uses: actions/setup-python@v5
22+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
1723
with:
1824
python-version: '3.10'
1925

26+
- name: Install uv
27+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
28+
2029
- name: Build distributions
21-
run: make dist
30+
run: uv build
2231

2332
- name: Upload distributions
24-
uses: actions/upload-artifact@v4
33+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2534
with:
2635
name: fickling-dists
2736
path: dist/
@@ -36,10 +45,10 @@ jobs:
3645
- build-release
3746
steps:
3847
- name: fetch dists
39-
uses: actions/download-artifact@v5
48+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
4049
with:
4150
name: fickling-dists
4251
path: dist/
4352

4453
- name: publish
45-
uses: pypa/gh-action-pypi-publish@v1.12.4
54+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

.github/workflows/tests.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,45 @@ on:
99
pull_request:
1010
branches: [ master ]
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
test:
1417
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
1520
strategy:
1621
matrix:
1722
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1823

1924
steps:
20-
- uses: actions/checkout@v5
25+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
26+
with:
27+
persist-credentials: false
2128

22-
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v5
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
2431
with:
25-
python-version: ${{ matrix.python-version }}
26-
cache-dependency-path: pyproject.toml
32+
enable-cache: true
33+
cache-dependency-glob: "uv.lock"
34+
35+
- name: Set up Python ${{ matrix.python-version }}
36+
run: uv python install ${{ matrix.python-version }}
37+
38+
- name: Install dependencies
39+
run: uv sync --extra test
2740

28-
- name: Test
29-
run: make test INSTALL_EXTRA=test
41+
- name: Run tests
42+
run: uv run pytest --cov=fickling test/
43+
44+
- name: Generate coverage report
45+
run: uv run coverage report
3046

3147
all-tests-pass:
3248
if: always()
33-
49+
permissions:
50+
contents: read
3451
needs:
3552
- test
3653

@@ -40,4 +57,4 @@ jobs:
4057
- name: check test jobs
4158
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
4259
with:
43-
jobs: ${{ toJSON(needs) }}
60+
jobs: ${{ toJSON(needs) }}

.pre-commit-config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
args: ['--maxkb=1000']
10+
- id: check-toml
11+
- id: check-merge-conflict
12+
- id: debug-statements
13+
language_version: python3
14+
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: v0.8.6
17+
hooks:
18+
- id: ruff
19+
args: [--fix, --exit-non-zero-on-fix]
20+
- id: ruff-format
21+
22+
- repo: https://github.com/pre-commit/mirrors-mypy
23+
rev: v1.14.1
24+
hooks:
25+
- id: mypy
26+
additional_dependencies:
27+
- types-stdlib-list
28+
args: [--config-file=pyproject.toml]
29+
pass_filenames: false
30+
args: [fickling]
31+
32+
ci:
33+
autoupdate_schedule: weekly
34+
skip: [mypy] # mypy requires dependencies to be installed

DEVELOPMENT.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Development Guide
2+
3+
## Setup
4+
5+
Install [uv](https://github.com/astral-sh/uv):
6+
```bash
7+
curl -LsSf https://astral.sh/uv/install.sh | sh # macOS/Linux
8+
# OR
9+
pip install uv
10+
```
11+
12+
Clone and install:
13+
```bash
14+
git clone https://github.com/trailofbits/fickling.git
15+
cd fickling
16+
make dev # or: uv sync --all-extras
17+
```
18+
19+
## Common Tasks
20+
21+
```bash
22+
make test # Run tests with coverage
23+
make test-quick # Run tests without coverage
24+
make lint # Check code style
25+
make format # Auto-format code
26+
make typecheck # Run type checker
27+
make dist # Build package
28+
make clean # Remove build artifacts
29+
```
30+
31+
## Code Style
32+
33+
- Ruff for linting and formatting
34+
- Line length: 100 characters
35+
- Double quotes
36+
- Python 3.9+ syntax
37+
38+
## Project Structure
39+
40+
```
41+
fickling/
42+
├── fickling/ # Source code
43+
├── test/ # Tests
44+
├── example/ # Examples
45+
├── pyproject.toml # Dependencies
46+
└── Makefile # Task automation
47+
```
48+
49+
## Contributing
50+
51+
1. Branch from `master`
52+
2. Make changes
53+
3. Run `make test lint`
54+
4. Create pull request
55+
56+
CI runs tests on Python 3.9-3.13.

0 commit comments

Comments
 (0)