Skip to content

Commit 78ba80b

Browse files
dguidoclaude
andauthored
Add comprehensive test suite and modernize CI (#26)
* 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]> * Restrict GitHub Actions workflow permissions Add explicit minimal permissions to all workflows to follow security best practices (fixes zizmor excessive-permissions audit). Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 9bc9d75 commit 78ba80b

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

+1666
-414
lines changed

.github/workflows/black.yaml

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

.github/workflows/lint.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
lint:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
with:
24+
persist-credentials: false
25+
26+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
27+
with:
28+
enable-cache: true
29+
30+
- run: uv sync --group lint
31+
32+
- run: uv run ruff format --check .
33+
34+
- run: uv run ruff check --output-format=github .
35+
36+
- 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: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,28 @@
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+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
audit:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
persist-credentials: false
23+
24+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
25+
26+
- run: uv sync --group audit
27+
28+
- run: uv run pip-audit

.github/workflows/publish.yaml

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

7+
permissions: {}
8+
79
jobs:
810
build-release:
9-
11+
permissions:
12+
contents: read
1013
runs-on: ubuntu-latest
11-
1214
steps:
13-
- uses: actions/checkout@v4
14-
15-
- name: Set up Python
16-
uses: actions/setup-python@v5
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1716
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
17+
persist-credentials: false
18+
19+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
20+
21+
- run: uv build
22+
23+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2724
with:
2825
name: slither-lsp-dists
2926
path: dist/
@@ -32,22 +29,19 @@ jobs:
3229
runs-on: ubuntu-latest
3330
environment: release
3431
permissions:
35-
id-token: write # For trusted publishing + codesigning.
36-
contents: write # For attaching signing artifacts to the release.
32+
id-token: write
33+
contents: write
3734
needs:
3835
- build-release
3936
steps:
40-
- name: fetch dists
41-
uses: actions/download-artifact@v4
37+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
4238
with:
4339
name: slither-lsp-dists
4440
path: dist/
4541

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

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

.github/workflows/pylint.yaml

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

.github/workflows/test.yaml

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

0 commit comments

Comments
 (0)