Skip to content

Commit 37ccad8

Browse files
committed
Ci pipeline enhancements (#4)
1 parent 580b67e commit 37ccad8

File tree

56 files changed

+1402
-545
lines changed

Some content is hidden

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

56 files changed

+1402
-545
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,77 @@ permissions:
1919
contents: read
2020

2121
jobs:
22+
test:
23+
name: Test Python ${{ matrix.python-version }}
24+
runs-on: ubuntu-latest
25+
strategy:
26+
matrix:
27+
python-version: ["3.11", "3.12"]
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v4
33+
with:
34+
version: "latest"
35+
36+
- name: Set up Python ${{ matrix.python-version }}
37+
run: uv python install ${{ matrix.python-version }}
38+
39+
- name: Install Rust
40+
uses: dtolnay/rust-toolchain@stable
41+
with:
42+
components: rustfmt, clippy
43+
44+
- name: Install dependencies
45+
run: |
46+
uv sync --dev
47+
uv run maturin develop
48+
49+
- name: Run Rust tests
50+
run: cargo test --verbose
51+
52+
- name: Run Python tests
53+
run: uv run pytest --verbose --tb=short
54+
55+
lint:
56+
name: Code Quality
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Install uv
62+
uses: astral-sh/setup-uv@v4
63+
with:
64+
version: "latest"
65+
66+
- name: Set up Python
67+
run: uv python install 3.12
68+
69+
- name: Install Rust
70+
uses: dtolnay/rust-toolchain@stable
71+
with:
72+
components: rustfmt, clippy
73+
74+
- name: Install dependencies
75+
run: |
76+
uv sync --dev
77+
uv run maturin develop
78+
79+
- name: Check Rust formatting
80+
run: cargo fmt --all -- --check
81+
82+
- name: Run Rust clippy
83+
run: cargo clippy --all-targets --all-features -- -D warnings
84+
85+
- name: Check Python formatting
86+
run: uv run ruff format --check .
87+
88+
- name: Run Python linting
89+
run: uv run ruff check .
2290
linux:
2391
runs-on: ${{ matrix.platform.runner }}
92+
needs: [test, lint]
2493
strategy:
2594
matrix:
2695
platform:
@@ -56,6 +125,7 @@ jobs:
56125

57126
windows:
58127
runs-on: ${{ matrix.platform.runner }}
128+
needs: [test, lint]
59129
strategy:
60130
matrix:
61131
platform:
@@ -83,6 +153,7 @@ jobs:
83153

84154
macos:
85155
runs-on: ${{ matrix.platform.runner }}
156+
needs: [test, lint]
86157
strategy:
87158
matrix:
88159
platform:
@@ -109,6 +180,7 @@ jobs:
109180

110181
sdist:
111182
runs-on: ubuntu-latest
183+
needs: [test, lint]
112184
steps:
113185
- uses: actions/checkout@v4
114186
- name: Build sdist

.github/workflows/security.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Security
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
schedule:
8+
# Run weekly security scans
9+
- cron: '0 2 * * 1'
10+
workflow_dispatch:
11+
12+
jobs:
13+
security:
14+
name: Security Scan
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Run Rust security audit
20+
uses: rustsec/[email protected]
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v4
26+
with:
27+
version: "latest"
28+
29+
- name: Set up Python
30+
run: uv python install 3.12
31+
32+
- name: Install dependencies
33+
run: uv sync --dev
34+
35+
- name: Run Python security scan
36+
run: |
37+
uv add --dev safety
38+
uv run safety check --ignore 70612
39+
continue-on-error: true # Don't fail CI on security advisories, just report
40+
41+
codeql:
42+
name: CodeQL Analysis
43+
runs-on: ubuntu-latest
44+
permissions:
45+
actions: read
46+
contents: read
47+
security-events: write
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Initialize CodeQL
53+
uses: github/codeql-action/init@v3
54+
with:
55+
languages: python
56+
57+
- name: Autobuild
58+
uses: github/codeql-action/autobuild@v3
59+
60+
- name: Perform CodeQL Analysis
61+
uses: github/codeql-action/analyze@v3

examples/basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import cel
2+
23
expressions = [
34
"1 + 2",
45
"1 > 2",
@@ -20,5 +21,4 @@
2021

2122
for ex in expressions:
2223
result = cel.evaluate(ex)
23-
print(ex, '=>', result, type(result))
24-
24+
print(ex, "=>", result, type(result))

pyproject.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,60 @@ dev-dependencies = [
4242
"ruff>=0.12.7",
4343
"mypy>=1.17.1",
4444
]
45+
46+
[tool.ruff]
47+
target-version = "py311"
48+
line-length = 100
49+
extend-exclude = [
50+
".venv",
51+
"target",
52+
"__pycache__",
53+
]
54+
55+
[tool.ruff.lint]
56+
select = [
57+
"E", # pycodestyle errors
58+
"W", # pycodestyle warnings
59+
"F", # pyflakes
60+
"I", # isort
61+
"B", # flake8-bugbear
62+
"C4", # flake8-comprehensions
63+
]
64+
ignore = [
65+
"E501", # line too long (handled by formatter)
66+
"F403", # star imports (needed for Rust extension)
67+
"F405", # undefined from star imports (expected with Rust extension)
68+
"F401", # unused imports (CLI module imported for side effects)
69+
"RUF001", # ambiguous unicode characters (intentional in tests)
70+
]
71+
72+
[tool.ruff.format]
73+
quote-style = "double"
74+
indent-style = "space"
75+
76+
[tool.mypy]
77+
python_version = "3.11"
78+
warn_return_any = true
79+
warn_unused_configs = true
80+
disallow_untyped_defs = true
81+
check_untyped_defs = true
82+
warn_redundant_casts = true
83+
warn_unused_ignores = true
84+
show_error_codes = true
85+
namespace_packages = true
86+
exclude = [
87+
"tests/",
88+
".venv/",
89+
"target/",
90+
]
91+
92+
[tool.pytest.ini_options]
93+
testpaths = ["tests"]
94+
python_files = ["test_*.py"]
95+
python_classes = ["Test*"]
96+
python_functions = ["test_*"]
97+
addopts = [
98+
"--strict-markers",
99+
"--strict-config",
100+
"--verbose",
101+
]

python/cel/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Import the Rust extension
2-
from .cel import *
3-
4-
# Import CLI functionality
2+
# Import CLI functionality
53
from . import cli
4+
from .cel import *
65

76
__doc__ = cel.__doc__
87
if hasattr(cel, "__all__"):
9-
__all__ = cel.__all__
8+
__all__ = cel.__all__

python/cel/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
from .cli import cli_entry
77

88
if __name__ == "__main__":
9-
cli_entry()
9+
cli_entry()
358 Bytes
Binary file not shown.
338 Bytes
Binary file not shown.
26.7 KB
Binary file not shown.
5.47 MB
Binary file not shown.

0 commit comments

Comments
 (0)