Skip to content

Commit d332669

Browse files
dguidoclaude
andcommitted
Add comprehensive test suite and modernize CI
- Add pytest with 74 tests covering unit, integration, and E2E scenarios - Test file_paths, ranges, and analysis_structures utilities - Test SlitherDiagnostics with mocked server - Test LSP protocol types and server capabilities - Add test fixtures (Solidity contracts, detector JSON) - Configure pytest-asyncio for async test support - Add test.yaml CI workflow with pinned action SHAs - Replace black/pylint workflows with ruff-based lint.yaml - Update pip-audit.yaml and publish.yaml for uv - Add pre-commit configuration - Add py.typed marker for type checking - Add __init__.py files for proper package structure - Fix TYPE_CHECKING annotation in slither_diagnostics.py - Format codebase with ruff Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 9bc9d75 commit d332669

Some content is hidden

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

47 files changed

+1653
-414
lines changed

.github/workflows/black.yaml

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

.github/workflows/lint.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
branches: [main, dev]
6+
paths: ["**/*.py"]
7+
push:
8+
branches: [main, dev]
9+
paths: ["**/*.py"]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
with:
21+
persist-credentials: false
22+
23+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
24+
with:
25+
enable-cache: true
26+
27+
- run: uv sync --group lint
28+
29+
- run: uv run ruff format --check .
30+
31+
- run: uv run ruff check --output-format=github .
32+
33+
- run: uv run ty check slither_lsp/

.github/workflows/matchers/pylint.json

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

.github/workflows/pip-audit.yaml

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,25 @@
1-
---
2-
name: pip-audit
3-
4-
on:
5-
push:
6-
branches: [ dev, main ]
7-
pull_request:
8-
branches: [ dev, main ]
9-
schedule: [ cron: "0 7 * * 2" ]
10-
11-
concurrency:
12-
group: ${{ github.workflow }}-${{ github.ref }}
13-
cancel-in-progress: true
14-
15-
jobs:
16-
audit:
17-
runs-on: ubuntu-latest
18-
19-
steps:
20-
- name: Checkout repository
21-
uses: actions/checkout@v4
22-
23-
- name: Install Python
24-
uses: actions/setup-python@v5
25-
with:
26-
python-version: "3.10"
27-
28-
- name: Install Slither
29-
run: |
30-
python -m venv /tmp/pip-audit-env
31-
source /tmp/pip-audit-env/bin/activate
32-
33-
python -m pip install --upgrade pip setuptools wheel
34-
python -m pip install .
35-
36-
- name: Run pip-audit
37-
uses: pypa/[email protected]
38-
with:
39-
virtual-environment: /tmp/pip-audit-env
1+
name: pip-audit
2+
3+
on:
4+
push:
5+
branches: [dev, main]
6+
pull_request:
7+
branches: [dev, main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
audit:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
with:
19+
persist-credentials: false
20+
21+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
22+
23+
- run: uv sync --group audit
24+
25+
- run: uv run pip-audit

.github/workflows/publish.yaml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,17 @@ on:
66

77
jobs:
88
build-release:
9-
109
runs-on: ubuntu-latest
11-
1210
steps:
13-
- uses: actions/checkout@v4
14-
15-
- name: Set up Python
16-
uses: actions/setup-python@v5
11+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1712
with:
18-
python-version: '3.x'
19-
20-
- name: Build distributions
21-
run: |
22-
python -m pip install --upgrade pip
23-
python -m pip install build
24-
python -m build
25-
- name: Upload distributions
26-
uses: actions/upload-artifact@v4
13+
persist-credentials: false
14+
15+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
16+
17+
- run: uv build
18+
19+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2720
with:
2821
name: slither-lsp-dists
2922
path: dist/
@@ -32,22 +25,19 @@ jobs:
3225
runs-on: ubuntu-latest
3326
environment: release
3427
permissions:
35-
id-token: write # For trusted publishing + codesigning.
36-
contents: write # For attaching signing artifacts to the release.
28+
id-token: write
29+
contents: write
3730
needs:
3831
- build-release
3932
steps:
40-
- name: fetch dists
41-
uses: actions/download-artifact@v4
33+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
4234
with:
4335
name: slither-lsp-dists
4436
path: dist/
4537

46-
- name: publish
47-
uses: pypa/[email protected]
38+
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
4839

49-
- name: sign
50-
uses: sigstore/[email protected]
40+
- uses: sigstore/gh-action-sigstore-python@f514d46b907ebcd5bedc05145c03b69c1edd8b46 # v3.0.0
5141
with:
5242
inputs: ./dist/*.tar.gz ./dist/*.whl
53-
release-signing-artifacts: true
43+
release-signing-artifacts: true

.github/workflows/pylint.yaml

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

.github/workflows/test.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
13+
with:
14+
persist-credentials: false
15+
16+
- uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
17+
18+
- name: Install dependencies
19+
run: uv sync --group dev
20+
21+
- name: Run tests
22+
run: uv run pytest -q

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ ENV/
100100
# mypy
101101
.mypy_cache
102102

103+
# ruff
104+
.ruff_cache
105+
106+
# uv (lockfile not committed for library packages)
107+
uv.lock
108+
103109
*.sw*
104110

105111
# PyCharm project dir

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.14.14
4+
hooks:
5+
- id: ruff-check
6+
args: [--fix]
7+
- id: ruff-format
8+
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v5.0.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: check-yaml
15+
- id: check-toml

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.PHONY: dev lint format check audit test test-cov
2+
3+
dev:
4+
uv sync --group dev
5+
6+
lint:
7+
uv run ruff check .
8+
uv run ty check slither_lsp/
9+
10+
format:
11+
uv run ruff format .
12+
uv run ruff check --fix .
13+
14+
check:
15+
uv run ruff format --check .
16+
uv run ruff check .
17+
18+
audit:
19+
uv run pip-audit
20+
21+
test:
22+
uv run pytest -q
23+
24+
test-cov:
25+
uv run pytest --cov=slither_lsp --cov-report=term-missing

0 commit comments

Comments
 (0)