Skip to content

Commit 2a6c1ae

Browse files
authored
Merge pull request #231 from crytic/feature/code-quality-phase1
feat: implement code quality improvements
2 parents 77a788c + 6a61de6 commit 2a6c1ae

Some content is hidden

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

41 files changed

+1873
-436
lines changed
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
---
2-
body:
3-
-
4-
attributes:
1+
---
2+
body:
3+
-
4+
attributes:
55
value: |
66
Please check the issues tab to avoid duplicates.
77
Thanks for taking the time to fill out this bug report!
88
type: markdown
9-
-
10-
attributes:
9+
-
10+
attributes:
1111
label: "Describe the issue:"
1212
id: what-happened
1313
type: textarea
14-
validations:
14+
validations:
1515
required: true
16-
-
17-
attributes:
16+
-
17+
attributes:
1818
description: "It can be a github repo, etherscan link, or code snippet."
1919
label: "Code example to reproduce the issue:"
2020
placeholder: "`contract A {}`\n"
2121
id: reproduce
2222
type: textarea
23-
validations:
23+
validations:
2424
required: true
25-
-
26-
attributes:
25+
-
26+
attributes:
2727
description: |
28-
What version of solc-select are you running?
28+
What version of solc-select are you running?
2929
Run `solc-select--version`
3030
label: "Version:"
3131
id: version
3232
type: textarea
33-
validations:
33+
validations:
3434
required: true
35-
-
36-
attributes:
35+
-
36+
attributes:
3737
description: |
38-
Please copy and paste any relevant log output. This
38+
Please copy and paste any relevant log output. This
3939
will be automatically formatted into code, so no need for backticks.
4040
render: shell
4141
label: "Relevant log output:"
4242
id: logs
4343
type: textarea
4444
description: "File a bug report"
45-
labels:
45+
labels:
4646
- bug-candidate
4747
name: "Bug Report"
4848
title: "[Bug-Candidate]: "

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ updates:
55
directory: /
66
schedule:
77
interval: daily
8+
9+
- package-ecosystem: pip
10+
directory: /
11+
schedule:
12+
interval: weekly
13+
open-pull-requests-limit: 5
14+
reviewers:
15+
- "elopez"
16+
- "montyly"

.github/workflows/ci.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,25 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
tests:
19-
name: CI (Python ${{ matrix.python }} on ${{ matrix.os }}, ${{ matrix.type }} test)
22+
name: CI (Python ${{ matrix.python }} on ${{ matrix.os }})
2023
runs-on: ${{ matrix.os }}
2124
strategy:
2225
matrix:
2326
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2427
os: ["ubuntu-latest", "macos-latest", "windows-2022"]
25-
type: ["solc", "solc_upgrade", "os_specific"]
2628
steps:
2729
- uses: actions/checkout@v5
28-
- uses: actions/setup-python@v6
29-
id: python
30+
- uses: astral-sh/setup-uv@v4
3031
with:
3132
python-version: ${{ matrix.python }}
32-
- name: Create Python virtual environment
33-
run: |
34-
${{ steps.python.outputs.python-path }} -m venv test-venv
35-
- name: Install solc-select
36-
shell: bash
33+
- name: Install solc-select and test dependencies
3734
run: |
38-
source test-venv/${{ (runner.os == 'Windows' && 'Scripts') || 'bin' }}/activate
39-
python -m pip install --upgrade pip
40-
pip3 install .
35+
uv sync --extra dev
4136
- name: Run Tests
42-
shell: bash
43-
env:
44-
TEST_TYPE: ${{ (matrix.type != 'os_specific' && matrix.type) || runner.os }}
4537
run: |
46-
source test-venv/${{ (runner.os == 'Windows' && 'Scripts') || 'bin' }}/activate
47-
TEST_TYPE="$(echo "$TEST_TYPE" | tr '[:upper:]' '[:lower:]')"
48-
bash scripts/test_${TEST_TYPE}.sh
38+
uv run python -m pytest tests/ -v --tb=short -n auto

.github/workflows/lint.yml

Lines changed: 10 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
---
22
name: Lint Code Base
33

4-
defaults:
5-
run:
6-
# To load bashrc
7-
shell: bash -ieo pipefail {0}
8-
94
on:
105
pull_request:
116
branches: [master, dev]
@@ -19,78 +14,22 @@ concurrency:
1914

2015
permissions:
2116
contents: read
22-
packages: read
23-
# To report GitHub Actions status checks
24-
statuses: write
2517

2618
jobs:
27-
pylint:
28-
name: Lint Code Base (pylint)
19+
lint:
20+
name: Lint Code Base
2921
runs-on: ubuntu-latest
3022

3123
steps:
32-
- name: Checkout Code
33-
uses: actions/checkout@v5
34-
with:
35-
# super-linter needs the full git history to get the
36-
# list of files that changed across commits
37-
fetch-depth: 0
38-
39-
- name: Set up Python 3.8
40-
uses: actions/setup-python@v6
41-
with:
42-
python-version: 3.8
43-
44-
- name: Install dependencies
45-
run: |
46-
mkdir -p .github/linters
47-
cp pyproject.toml .github/linters
48-
49-
- name: Pylint
50-
uses: super-linter/super-linter/[email protected]
51-
if: always()
52-
env:
53-
# run linter on everything to catch preexisting problems
54-
VALIDATE_ALL_CODEBASE: true
55-
DEFAULT_BRANCH: master
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57-
# Run only pylint
58-
VALIDATE_PYTHON: true
59-
VALIDATE_PYTHON_PYLINT: true
60-
PYTHON_PYLINT_CONFIG_FILE: pyproject.toml
61-
FILTER_REGEX_EXCLUDE: .*tests/.*.(json|zip|sol)
24+
- uses: actions/checkout@v5
6225

63-
black:
64-
name: Lint Code Base (black)
65-
runs-on: ubuntu-latest
66-
67-
steps:
68-
- name: Checkout Code
69-
uses: actions/checkout@v5
70-
with:
71-
# super-linter needs the full git history to get the
72-
# list of files that changed across commits
73-
fetch-depth: 0
26+
- uses: astral-sh/setup-uv@v4
7427

75-
- name: Set up Python 3.8
76-
uses: actions/setup-python@v6
77-
with:
78-
python-version: 3.8
28+
- name: Install solc-select and test dependencies
29+
run: uv sync --extra dev
7930

80-
- name: Install dependencies
81-
run: |
82-
mkdir -p .github/linters
83-
cp pyproject.toml .github/linters
31+
- name: Run ruff check
32+
run: uv run ruff check .
8433

85-
- name: Black
86-
uses: super-linter/super-linter/[email protected]
87-
if: always()
88-
env:
89-
# run linter on everything to catch preexisting problems
90-
VALIDATE_ALL_CODEBASE: true
91-
DEFAULT_BRANCH: master
92-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93-
# Run only black
94-
VALIDATE_PYTHON_BLACK: true
95-
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
96-
FILTER_REGEX_EXCLUDE: .*tests/.*.(json|zip|sol)
34+
- name: Run ruff format check
35+
run: uv run ruff format --check .

.github/workflows/pip-audit.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ jobs:
3333
python -m pip install --upgrade pip setuptools wheel
3434
python -m pip install .
3535
36-
3736
- name: Run pip-audit
3837
uses: pypa/[email protected]
3938
with:
4039
virtual-environment: /tmp/pip-audit-env
41-

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Build distributions
2121
run: |
2222
python -m pip install --upgrade pip
23-
python -m pip install build
23+
python -m pip install --upgrade build
2424
python -m build
2525
2626
- name: Upload distributions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ global-version
88
build/
99
dist/
1010
*.egg
11-
*.egg-info/
11+
*.egg-info/

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Pre-commit hooks for code quality
2+
# See https://pre-commit.com for more information
3+
repos:
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
# Ruff version - using latest stable
6+
rev: v0.12.10
7+
hooks:
8+
# Run the linter
9+
- id: ruff
10+
args: ["--fix"]
11+
# Run the formatter
12+
- id: ruff-format
13+
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v5.0.0
16+
hooks:
17+
- id: trailing-whitespace
18+
- id: end-of-file-fixer
19+
- id: check-yaml
20+
- id: check-added-large-files
21+
args: ["--maxkb=1000"]
22+
- id: check-merge-conflict
23+
- id: check-toml
24+
- id: debug-statements

CONTRIBUTING.md

Lines changed: 75 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Contribuing to solc-select
1+
# Contributing to solc-select
22

3-
Hi! Welcome to solc-select.
3+
Hi! Welcome to solc-select.
44

5-
## Bug Reports and Feature Suggestions
5+
## Bug Reports and Feature Suggestions
66

77
Bug reports and feature suggestions can be submitted to our issue tracker. For bug reports, attaching the contract that caused the bug will help us in debugging and resolving the issue quickly. If you find a security vulnerability, do not open an issue; email [email protected] instead.
88

99
## Questions
1010
Questions can be submitted to the issue tracker, but you may get a faster response if you ask in our [chat room](https://slack.empirehacking.nyc/) (in the #ethereum channel).
1111

12-
## Code
12+
## Code
1313
solc-select uses the pull request contribution model. Please make an account on Github, fork this repo, and submit code contributions via pull request. For more documentation, look [here](https://guides.github.com/activities/forking/).
1414

1515
Some pull request guidelines:
@@ -20,31 +20,87 @@ Some pull request guidelines:
2020
- Fill out the pull request description with a summary of what your patch does, key changes that have been made, and any further points of discussion, if applicable.
2121
- Title your pull request with a brief description of what it's changing. "Fixes #123" is a good comment to add to the description, but makes for an unclear title on its own.
2222

23-
## Linters
23+
## Development Setup
2424

25-
Several linters and security checkers are run on the PRs.
25+
### Setting up the Development Environment
2626

27-
To run them locally in the root dir of the repository:
27+
#### Using uv (recommended - fastest)
2828

29-
- `pylint solc_select --rcfile pyproject.toml`
30-
- `black . --config pyproject.toml`
31-
32-
We use pylint `2.8.2` black `20.8b1`.
33-
34-
## Running Tests
35-
36-
These tests can be run locally by using the `bash test_{linux | macos | windows}.sh` respective scripts.
29+
```bash
30+
git clone https://github.com/crytic/solc-select.git
31+
cd solc-select
32+
uv venv
33+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
34+
uv pip install -e ".[dev]"
35+
pre-commit install # Set up automatic linting on commit
36+
```
3737

38-
These will also run in a github workflow on each platform.
38+
#### Using pip
3939

40-
## Developer Environment
40+
```bash
41+
git clone https://github.com/crytic/solc-select.git
42+
cd solc-select
43+
python3 -m venv venv
44+
source venv/bin/activate # On Windows: venv\Scripts\activate
45+
pip install -e ".[dev]"
46+
pre-commit install # Set up automatic linting on commit
47+
```
4148

42-
Run `make dev` to create your own development environment.
49+
#### Using make
4350

4451
```bash
4552
git clone https://github.com/crytic/solc-select.git
4653
cd solc-select
4754
make dev
4855
```
4956

50-
Update `solc-select` by running `git pull` from the `solc-select/` directory.
57+
### Code Quality
58+
59+
We use automated tools to maintain code quality. Several linters and security checkers are run on all PRs.
60+
61+
To run them locally:
62+
63+
```bash
64+
# Code formatting and linting
65+
ruff check . # Check for linting issues
66+
ruff format --check . # Check formatting
67+
ruff format . # Auto-format code
68+
69+
# Type checking (optional but recommended)
70+
pip install pylint
71+
pylint solc_select --rcfile pyproject.toml
72+
```
73+
74+
## Running Tests
75+
76+
Tests use pytest and can be run locally:
77+
78+
```bash
79+
# Install development dependencies (includes pytest)
80+
pip install -e ".[dev]"
81+
82+
# Run all tests
83+
pytest tests/
84+
85+
# Run specific test file
86+
pytest tests/test_compiler_versions.py
87+
88+
# Run tests with verbose output
89+
pytest tests/ -v
90+
91+
# Skip slow tests (upgrade test) and platform boundary tests
92+
pytest tests/ -k "not version_boundaries" -m "not slow"
93+
94+
# Tests also run automatically in GitHub Actions on all platforms
95+
```
96+
97+
## Updating Your Fork
98+
99+
To keep your fork up to date with the latest changes:
100+
101+
```bash
102+
git remote add upstream https://github.com/crytic/solc-select.git
103+
git fetch upstream
104+
git checkout dev
105+
git merge upstream/dev
106+
```

0 commit comments

Comments
 (0)