Skip to content

Commit c12f486

Browse files
authored
build: add ruff linter (#332)
* fix: lowercase whats changed label * fix: update commit message for release * build: add ruff linter * fix python linting errors * fix: github workflow script
1 parent 5ccf66a commit c12f486

File tree

7 files changed

+42
-18
lines changed

7 files changed

+42
-18
lines changed
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
name: Lint and Format Check (Ubuntu Latest)
22

3-
on:
4-
push:
5-
branches:
6-
- "*"
7-
pull_request:
8-
branches:
9-
- "*"
3+
on: [push, pull_request]
104

115
permissions:
126
contents: read
@@ -15,7 +9,7 @@ jobs:
159
lint-and-format:
1610
runs-on: ubuntu-latest
1711
steps:
18-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
1913

2014
- name: Install clang-format
2115
run: |
@@ -28,3 +22,8 @@ jobs:
2822
env:
2923
CXX: clang++-14
3024
LINT_AND_FORMAT_CHECK: true
25+
26+
- uses: @chartboost/ruff-action@v1
27+
name: Lint with Ruff
28+
with:
29+
version: 0.0.261

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
7676
git add doxygen include/ada/ada_version.h CMakeLists.txt
7777
78-
git commit -m "New Release: ${{ env.NEXT_RELEASE_TAG }}"
78+
git commit -m "chore: release ${{ env.NEXT_RELEASE_TAG }}"
7979
git push
8080
8181
- name: "Create Release"

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[tool.ruff]
2+
select = [
3+
"C90", # McCabe cyclomatic complexity
4+
"E", # pycodestyle
5+
"F", # Pyflakes
6+
"ICN", # flake8-import-conventions
7+
"INT", # flake8-gettext
8+
"PLC", # Pylint conventions
9+
"PLE", # Pylint errors
10+
"PLR09", # Pylint refactoring: max-args, max-branches, max returns, max-statements
11+
"PYI", # flake8-pyi
12+
"RSE", # flake8-raise
13+
"RUF", # Ruff-specific rules
14+
"T10", # flake8-debugger
15+
"TCH", # flake8-type-checking
16+
"TID", # flake8-tidy-imports
17+
"W", # pycodestyle
18+
"YTT", # flake8-2020
19+
]
20+
exclude = [
21+
"docs",
22+
"tests",
23+
]
24+
ignore = [
25+
"E722" # Do not use bare `except`
26+
]
27+
line-length = 120
28+
target-version = "py37"

singleheader/amalgamate.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Creates the amalgamated source files.
44
#
55

6+
import zipfile
67
import sys
78
import os.path
89
import subprocess
@@ -18,9 +19,6 @@
1819
PROJECTPATH = os.path.dirname(SCRIPTPATH)
1920
print(f"SCRIPTPATH={SCRIPTPATH} PROJECTPATH={PROJECTPATH}")
2021

21-
22-
print("We are about to amalgamate all ada files into one source file.")
23-
print("See https://www.sqlite.org/amalgamation.html and https://en.wikipedia.org/wiki/Single_Compilation_Unit for rationale.")
2422
if "AMALGAMATE_SOURCE_PATH" not in os.environ:
2523
AMALGAMATE_SOURCE_PATH = os.path.join(PROJECTPATH, "src")
2624
else:
@@ -71,7 +69,7 @@ def dofile(fid, prepath, filename):
7169
RELFILE = os.path.relpath(file, PROJECTPATH)
7270
# Last lines are always ignored. Files should end by an empty lines.
7371
print(f"/* begin file {RELFILE} */", file=fid)
74-
includepattern = re.compile('\s*#\s*include "(.*)"')
72+
includepattern = re.compile('\\s*#\\s*include "(.*)"')
7573
with open(file, 'r') as fid2:
7674
for line in fid2:
7775
line = line.rstrip('\n')
@@ -84,7 +82,7 @@ def dofile(fid, prepath, filename):
8482

8583
if includedfile.startswith('../'):
8684
includedfile = includedfile[2:]
87-
# we explicitly include ada headers, one time each
85+
# we explicitly include ada headers, one time each
8886
doinclude(fid, includedfile, line, filename)
8987
else:
9088
print(line, file=fid)
@@ -132,7 +130,6 @@ def dofile(fid, prepath, filename):
132130
shutil.copy2(os.path.join(SCRIPTPATH,"demo.cpp"),AMALGAMATE_OUTPUT_PATH)
133131
shutil.copy2(os.path.join(SCRIPTPATH,"README.md"),AMALGAMATE_OUTPUT_PATH)
134132

135-
import zipfile
136133
zf = zipfile.ZipFile(os.path.join(AMALGAMATE_OUTPUT_PATH,'singleheader.zip'), 'w', zipfile.ZIP_DEFLATED)
137134
zf.write(os.path.join(AMALGAMATE_OUTPUT_PATH,"ada.cpp"), "ada.cpp")
138135
zf.write(os.path.join(AMALGAMATE_OUTPUT_PATH,"ada.h"), "ada.h")

tools/release/create_release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
TOKEN = os.environ["GITHUB_TOKEN"]
1212
if not NEXT_TAG or not REPO_NAME or not TOKEN:
1313
raise Exception(
14-
f"Bad environment variables. Invalid GITHUB_REPOSITORY, GITHUB_TOKEN or NEXT_RELEASE_TAG"
14+
"Bad environment variables. Invalid GITHUB_REPOSITORY, GITHUB_TOKEN or NEXT_RELEASE_TAG"
1515
)
1616

1717
g = Github(TOKEN)

tools/release/lib/release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def contruct_release_notes(repository, next_tag_name):
110110
repository.full_name, last_tag.title, next_tag_name
111111
)
112112

113-
notes = "## What's Changed\n"
113+
notes = "## What's changed\n"
114114
for changes in whats_changed:
115115
notes += changes + "\n"
116116

tools/release/lib/tests/test_release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_contruct_release_notes():
211211
notes = release.contruct_release_notes(repo_stub, "v3.0.0")
212212
assert (
213213
notes
214-
== "## What's Changed\n"
214+
== "## What's changed\n"
215215
+ "* Feature 2 by @new_contr_1 in https://github.com/ada-url/ada/pull/12\n"
216216
+ "* Refactoring by @new_contr_2 in https://github.com/ada-url/ada/pull/15\n"
217217
+ "* Feature 10 by @contr_2 in https://github.com/ada-url/ada/pull/22\n"

0 commit comments

Comments
 (0)