Skip to content

Commit 34a1e93

Browse files
authored
Merge pull request #78 from crytic/use-uv-ruff
Modernize development workflow
2 parents 385ecdf + 1aa27ce commit 34a1e93

File tree

10 files changed

+860
-422
lines changed

10 files changed

+860
-422
lines changed

.github/workflows/main.yml

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,53 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
815

916
jobs:
1017
lint:
11-
runs-on: ubuntu-latest
18+
runs-on: ubuntu-slim
1219
if: github.event_name == 'pull_request'
1320
steps:
14-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
15-
with:
16-
persist-credentials: false
17-
- name: Set up Python 3.10
18-
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
19-
with:
20-
python-version: "3.10"
21-
- name: Lint
22-
run: |
23-
pip install black
24-
pip install mypy
25-
pip install -e .
26-
black --version
27-
black --check pyevmasm
28-
mypy --version
29-
mypy pyevmasm
30-
31-
test310:
32-
runs-on: ubuntu-latest
21+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
22+
with:
23+
persist-credentials: false
24+
- uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1
25+
with:
26+
args: check
27+
- uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1
28+
with:
29+
args: format --check
30+
- uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
31+
with:
32+
activate-environment: true
33+
- name: Install lint dependencies
34+
run: uv sync --group lint
35+
- name: Type check
36+
run: mypy pyevmasm
3337

38+
test:
39+
runs-on: ubuntu-slim
40+
strategy:
41+
matrix:
42+
python-version: ["3.10", "3.14"]
3443
steps:
35-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
36-
with:
37-
persist-credentials: false
38-
39-
- name: Set up Python 3.10
40-
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
41-
with:
42-
python-version: "3.10"
43-
- name: Run Tests 3.10
44-
run: |
45-
pip install -e .
46-
python -m unittest discover "tests/"
44+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
45+
with:
46+
persist-credentials: false
47+
- uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
activate-environment: true
51+
- name: Install dependencies
52+
run: uv sync --group test
53+
- name: Run tests
54+
run: pytest

.github/workflows/pip-audit.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,38 @@ name: Scan dependencies for vulnerabilities with pip-audit
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: ["master"]
66
pull_request:
7-
branches: [ "master" ]
7+
branches: ["master"]
88
schedule:
99
- cron: "0 12 * * *"
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
1118
jobs:
1219
pip-audit:
13-
runs-on: ubuntu-latest
20+
runs-on: ubuntu-slim
1421

1522
steps:
1623
- name: Checkout repository
17-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
24+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
1825
with:
1926
persist-credentials: false
2027

21-
- name: Install Python
22-
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
28+
- name: Install uv and Python
29+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7
2330
with:
24-
python-version: "3.x"
25-
26-
- name: Install project
27-
run: |
28-
python -m venv /tmp/pip-audit-env
29-
source /tmp/pip-audit-env/bin/activate
31+
python-version: "3.10"
3032

31-
python -m pip install --upgrade pip
32-
python -m pip install .
33+
- name: Export dependencies
34+
run: uv export --format requirements-txt --no-emit-project > requirements.txt
3335

3436
- name: Run pip-audit
3537
uses: pypa/gh-action-pip-audit@1220774d901786e6f652ae159f7b6bc8fea6d266 # v1.1.0
3638
with:
37-
virtual-environment: /tmp/pip-audit-env
39+
inputs: requirements.txt

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ pip install pyevmasm
8484
8585
Or, install the library from source:
8686
```sh
87-
git clone https://github.com/trailofbits/pyevmasm
87+
git clone https://github.com/crytic/pyevmasm
8888
cd pyevmasm
89-
python setup.py install --user
89+
pip install .
9090
```
9191
92-
to run the tests
93-
92+
For development (requires [uv](https://docs.astral.sh/uv/)):
9493
```sh
95-
python -m unittest tests\test_EVMAssembler.py -v
94+
uv sync --group dev
95+
uv run pytest
9696
```
9797
9898
## Documentation

docs/conf.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Configuration file for the Sphinx documentation builder.
43
#
@@ -19,14 +18,14 @@
1918

2019
# -- Project information -----------------------------------------------------
2120

22-
project = 'pyevmasm'
23-
copyright = '2018, Trail of Bits'
24-
author = 'Trail of Bits'
21+
project = "pyevmasm"
22+
copyright = "2018, Trail of Bits"
23+
author = "Trail of Bits"
2524

2625
# The short X.Y version
27-
version = ''
26+
version = ""
2827
# The full version, including alpha/beta/rc tags
29-
release = ''
28+
release = ""
3029

3130

3231
# -- General configuration ---------------------------------------------------
@@ -38,21 +37,19 @@
3837
# Add any Sphinx extension module names here, as strings. They can be
3938
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4039
# ones.
41-
extensions = [
42-
'sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc'
43-
]
40+
extensions = ["sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.autodoc"]
4441

4542
# Add any paths that contain templates here, relative to this directory.
46-
templates_path = ['_templates']
43+
templates_path = ["_templates"]
4744

4845
# The suffix(es) of source filenames.
4946
# You can specify multiple suffix as a list of string:
5047
#
5148
# source_suffix = ['.rst', '.md']
52-
source_suffix = '.rst'
49+
source_suffix = ".rst"
5350

5451
# The master toctree document.
55-
master_doc = 'index'
52+
master_doc = "index"
5653

5754
# The language for content autogenerated by Sphinx. Refer to documentation
5855
# for a list of supported languages.
@@ -64,18 +61,18 @@
6461
# List of patterns, relative to source directory, that match files and
6562
# directories to ignore when looking for source files.
6663
# This pattern also affects html_static_path and html_extra_path .
67-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
64+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
6865

6966
# The name of the Pygments (syntax highlighting) style to use.
70-
pygments_style = 'sphinx'
67+
pygments_style = "sphinx"
7168

7269

7370
# -- Options for HTML output -------------------------------------------------
7471

7572
# The theme to use for HTML and HTML Help pages. See the documentation for
7673
# a list of builtin themes.
7774
#
78-
html_theme = 'alabaster'
75+
html_theme = "alabaster"
7976

8077
# Theme options are theme-specific and customize the look and feel of a theme
8178
# further. For a list of options available for each theme, see the
@@ -86,7 +83,7 @@
8683
# Add any paths that contain custom static files (such as style sheets) here,
8784
# relative to this directory. They are copied after the builtin static files,
8885
# so a file named "default.css" will overwrite the builtin "default.css".
89-
html_static_path = ['_static']
86+
html_static_path = ["_static"]
9087

9188
# Custom sidebar templates, must be a dictionary that maps document names
9289
# to template names.
@@ -102,7 +99,7 @@
10299
# -- Options for HTMLHelp output ---------------------------------------------
103100

104101
# Output file base name for HTML help builder.
105-
htmlhelp_basename = 'pyevmasmdoc'
102+
htmlhelp_basename = "pyevmasmdoc"
106103

107104

108105
# -- Options for LaTeX output ------------------------------------------------
@@ -111,15 +108,12 @@
111108
# The paper size ('letterpaper' or 'a4paper').
112109
#
113110
# 'papersize': 'letterpaper',
114-
115111
# The font size ('10pt', '11pt' or '12pt').
116112
#
117113
# 'pointsize': '10pt',
118-
119114
# Additional stuff for the LaTeX preamble.
120115
#
121116
# 'preamble': '',
122-
123117
# Latex figure (float) alignment
124118
#
125119
# 'figure_align': 'htbp',
@@ -129,19 +123,15 @@
129123
# (source start file, target name, title,
130124
# author, documentclass [howto, manual, or own class]).
131125
latex_documents = [
132-
(master_doc, 'pyevmasm.tex', 'pyevmasm Documentation',
133-
'Trail of Bits', 'manual'),
126+
(master_doc, "pyevmasm.tex", "pyevmasm Documentation", "Trail of Bits", "manual"),
134127
]
135128

136129

137130
# -- Options for manual page output ------------------------------------------
138131

139132
# One entry per manual page. List of tuples
140133
# (source start file, name, description, authors, manual section).
141-
man_pages = [
142-
(master_doc, 'pyevmasm', 'pyevmasm Documentation',
143-
[author], 1)
144-
]
134+
man_pages = [(master_doc, "pyevmasm", "pyevmasm Documentation", [author], 1)]
145135

146136

147137
# -- Options for Texinfo output ----------------------------------------------
@@ -150,7 +140,13 @@
150140
# (source start file, target name, title, author,
151141
# dir menu entry, description, category)
152142
texinfo_documents = [
153-
(master_doc, 'pyevmasm', 'pyevmasm Documentation',
154-
author, 'pyevmasm', 'One line description of project.',
155-
'Miscellaneous'),
143+
(
144+
master_doc,
145+
"pyevmasm",
146+
"pyevmasm Documentation",
147+
author,
148+
"pyevmasm",
149+
"One line description of project.",
150+
"Miscellaneous",
151+
),
156152
]

pyevmasm/__init__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
from .evmasm import instruction_tables, Instruction # noqa: F401
2-
from .evmasm import block_to_fork, DEFAULT_FORK
3-
from .evmasm import assemble, assemble_all, assemble_hex, assemble_one
4-
from .evmasm import disassemble, disassemble_all, disassemble_hex, disassemble_one
1+
from .evmasm import ( # noqa: F401
2+
DEFAULT_FORK,
3+
Instruction,
4+
assemble,
5+
assemble_all,
6+
assemble_hex,
7+
assemble_one,
8+
block_to_fork,
9+
disassemble,
10+
disassemble_all,
11+
disassemble_hex,
12+
disassemble_one,
13+
instruction_tables,
14+
)
515

616
__all__ = [
717
"instruction_tables",

pyevmasm/__main__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
#!/usr/bin/env python
22
import argparse
3-
import sys
43
import binascii
4+
import sys
55

66
from .evmasm import (
7+
DEFAULT_FORK,
8+
accepted_forks,
9+
assemble_all,
710
assemble_hex,
11+
block_to_fork,
812
disassemble_all,
913
instruction_tables,
10-
assemble_all,
11-
block_to_fork,
12-
DEFAULT_FORK,
13-
accepted_forks,
1414
)
1515

1616

1717
def main():
18-
parser = argparse.ArgumentParser(
19-
description="pyevmasm the EVM assembler and disassembler"
20-
)
18+
parser = argparse.ArgumentParser(description="pyevmasm the EVM assembler and disassembler")
2119
group_action = parser.add_mutually_exclusive_group(required=True)
2220
group_action.add_argument(
2321
"-a",

0 commit comments

Comments
 (0)