Skip to content

Commit 30c5bc6

Browse files
authored
ci: update GitHub Actions with uv setup (#57)
* chore: update build instructions * ci: fix static check actions * add pylint * allow line 100 char * pylint fail under 9 * ci: unittest * ci: split mypy and pylint * fix: filter for dependencies is not None
1 parent b1182ba commit 30c5bc6

11 files changed

Lines changed: 102 additions & 147 deletions

File tree

.github/workflows/mypy.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ jobs:
1111
with:
1212
fetch-depth: 1
1313

14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v5
16+
1417
- name: Set up Python
15-
uses: actions/setup-python@v2
16-
with:
17-
python-version: "3.10.12" # Replace with the version you need
18+
run: uv sync
1819

19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install -r requirements.txt
23-
pip install mypy>=1.7.1
2420
- name: Type Check Source Code
25-
run: mypy src
21+
run: uv run mypy src
22+

.github/workflows/pylint.yml

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
1-
name: Pylint
1+
name: Pylint Linting
22

33
on: [pull_request]
44

55
jobs:
6-
build:
6+
linting:
77
runs-on: ubuntu-latest
8-
strategy:
9-
matrix:
10-
python-version: ["3.10.12"]
8+
119
steps:
12-
- uses: actions/checkout@v3
13-
- name: Set up Python ${{ matrix.python-version }}
14-
uses: actions/setup-python@v3
10+
- uses: actions/checkout@v2
1511
with:
16-
python-version: ${{ matrix.python-version }}
17-
- name: Install dependencies
18-
run: |
19-
python -m pip install --upgrade pip
20-
pip install pylint
21-
pip install -r requirements.txt
22-
# - name: Analysing the code with pylint
23-
# run: |
24-
# pylint $(git ls-files '*.py')
25-
- name: Run Pylint
26-
run: |
27-
PYLINT_OUTPUT=$(pylint $(git ls-files '*.py') || true)
28-
PYLINT_SCORE=$(echo "$PYLINT_OUTPUT" | grep 'rated at' | sed 's/.*rated at \([0-9.]*\)\/10.*/\1/')
29-
echo "PYLINT_SCORE=$PYLINT_SCORE" >> $GITHUB_ENV
30-
echo "$PYLINT_OUTPUT"
12+
fetch-depth: 1
13+
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v5
16+
17+
- name: Set up Python
18+
run: uv sync
3119

32-
- name: Fail if below threshold (8)
33-
run: |
34-
if (( $(echo "$PYLINT_SCORE < 8.0" |bc -l) )); then
35-
exit 1
36-
fi
20+
- name: Lint Source Code
21+
run: uv run pylint src

.github/workflows/unitttest.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,11 @@ jobs:
1111
with:
1212
fetch-depth: 1
1313

14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v5
16+
1417
- name: Set up Python
15-
uses: actions/setup-python@v2
16-
with:
17-
python-version: "3.10.12" # Replace with the version you need
18+
run: uv sync
1819

19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install -r requirements.txt
2320
- name: Run Unit Tests
24-
run: |
25-
source ./env.sh
26-
python3 tests/test_ast.py
27-
python3 tests/test_polymorphism.py
28-
python3 tests/test_dependency.py
29-
python3 tests/test_rewrite.py
30-
python3 tests/test_alpha_equiv.py
21+
run: uv run pytest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ result/
173173
evaluation_log.txt
174174
banned.txt
175175

176+
alpharewrite/
177+
176178
*.pdf
177179
*.png
178180
*.csv

.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension-pkg-whitelist=
3939
fail-on=
4040

4141
# Specify a score threshold under which the program will exit with error.
42-
fail-under=10
42+
fail-under=9
4343

4444
# Interpret the stdin as a python script, whose filename needs to be passed as
4545
# the module_or_package argument.
@@ -340,7 +340,7 @@ indent-after-paren=4
340340
indent-string=' '
341341

342342
# Maximum number of characters on a single line.
343-
max-line-length=80
343+
max-line-length=100
344344

345345
# Maximum number of lines in a module.
346346
max-module-lines=1000

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,12 @@ uv sync # create a virtual environment, and install dependencies
1616

1717
## Building TF-Bench From Scratch (Optional)
1818

19-
### Getting Required Data
20-
21-
```sh
22-
./scripts/init.sh
23-
```
24-
25-
This script will download raw data from [Hackage](https://hackage.haskell.org/).
26-
2719
### TF-Bench
2820

2921
This script will build the benchmark (Prelude with NL) from the raw data.
3022

3123
```sh
32-
uv run reprocess_benchmark.py -i benchmark/ -o TF-Bench.json
24+
uv run --project . scripts/preprocess_benchmark.py
3325
```
3426

3527
### TF-Bench_pure
@@ -40,6 +32,8 @@ cd alpharewrite
4032

4133
stack build
4234
stack exec alpharewrite-exe 1 TF-Bench.json > TF-Bench.pure.json
35+
36+
cd ..
4337
```
4438

4539
For details, please refer to the README of [alpharewrite](https://github.com/SecurityLab-UCD/alpharewrite).

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies = [
1919
"ollama==0.2.1",
2020
"openai==1.30.5",
2121
"pathos>=0.3.3",
22+
"pylint>=3.3.6",
2223
"pytest>=8.0.0",
2324
"python-dotenv==1.0.1",
2425
"requests==2.32.3",
@@ -31,3 +32,6 @@ dependencies = [
3132
"tree-sitter-haskell==0.21.0",
3233
"types-requests>=2.31.0",
3334
]
35+
[tool.pytest.ini_options]
36+
pythonpath = ["."]
37+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from funcy import lmap
99

1010

11-
def main(input_raw_benchmark_path: str = "benchmark", output_path: str = "Benchmark-F.json"):
11+
def main(input_raw_benchmark_path: str = "benchmark", output_path: str = "tfb.json"):
1212

1313
# read in all files ending with .md in the input_raw_benchmark_path
1414
tasks: list[BenchmarkTask] = []

src/hoogle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def main(
244244
# Also transform them back into dictionaries for json format
245245
filtered = (
246246
(tasks_w_dep)
247-
.filter(lambda d: d.dependencies != None)
247+
.filter(lambda d: d.dependencies is not None)
248248
.map(lambda x: x.__dict__)
249249
.value
250250
)

tests/test_rewrite.py

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

0 commit comments

Comments
 (0)