Skip to content

Commit 5e3de3d

Browse files
Ci maintenance and collagraph update (#3)
* Add ci for Python 3.14 * Remove twine from dev dependencies * Configure trusted publishing to PyPi * Bump collagraph dependency to 0.8.0 and adjust imports * Bump version to 0.1.1
1 parent fa94742 commit 5e3de3d

5 files changed

Lines changed: 22 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
pyversion: "3.12"
4545
- name: Linux py313
4646
pyversion: "3.13"
47+
- name: Linux py314
48+
pyversion: "3.14"
4749
steps:
4850
- uses: actions/checkout@v5
4951
- name: Install uv
@@ -73,7 +75,7 @@ jobs:
7375
- name: Build wheel
7476
run: uv build
7577
- name: Twine check
76-
run: uv run twine check dist/*
78+
run: uvx twine check dist/*
7779
- name: Upload wheel artifact
7880
uses: actions/upload-artifact@v4
7981
with:
@@ -85,6 +87,12 @@ jobs:
8587
runs-on: ubuntu-latest
8688
needs: [lint, test, build]
8789
if: success() && startsWith(github.ref, 'refs/tags/v')
90+
environment:
91+
name: pypi
92+
url: https://pypi.org/p/ruff-cgx
93+
permissions:
94+
id-token: write
95+
contents: write
8896
steps:
8997
- uses: actions/checkout@v5
9098
- name: Download wheel artifact
@@ -102,7 +110,4 @@ jobs:
102110
draft: true
103111
prerelease: false
104112
- name: Publish to PyPI
105-
uses: pypa/gh-action-pypi-publish@master
106-
with:
107-
user: __token__
108-
password: ${{ secrets.PYPI_PASSWORD }}
113+
uses: pypa/gh-action-pypi-publish@release/v1

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "ruff-cgx"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "Ruff linter and formatter for collagraph single-file components"
55
readme = "README.md"
66
requires-python = ">=3.10"
77
dependencies = [
8-
"collagraph>=0.7.0",
8+
"collagraph>=0.8.0",
99
"ruff"
1010
]
1111
authors = [
@@ -19,7 +19,6 @@ ruff-cgx = "ruff_cgx.__main__:main"
1919
[dependency-groups]
2020
dev = [
2121
"pytest",
22-
"twine"
2322
]
2423
ruff = [
2524
"ruff"

ruff_cgx/formatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import tempfile
55
from pathlib import Path
66

7-
from collagraph.cgx import cgx
7+
from collagraph.sfc.parser import CGXParser
88

99
from .template_formatter import format_template
1010

@@ -59,7 +59,7 @@ def format_file(path, check=False, write=True):
5959
if path.suffix != ".cgx":
6060
return
6161

62-
parser = cgx.CGXParser()
62+
parser = CGXParser()
6363
parser.feed(path.read_text())
6464

6565
with path.open(mode="r") as fh:

ruff_cgx/linter.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import tokenize
88
from pathlib import Path
99

10-
from collagraph.cgx import cgx
10+
from collagraph.sfc.compiler import construct_ast
11+
from collagraph.sfc.parser import CGXParser
1112

1213

1314
def escape_ansi(line):
@@ -17,15 +18,15 @@ def escape_ansi(line):
1718

1819
def lint_file(path, fix=False, write=True):
1920
# plain_result = ast.unparse(tree)
20-
parser = cgx.CGXParser()
21+
parser = CGXParser()
2122
parser.feed(Path(path).read_text())
2223

2324
# Read the data from script block
2425
script_node = parser.root.child_with_tag("script")
2526
start, end = script_node.location[0], script_node.end[0] - 1
2627
script_range = range(start, end)
2728

28-
tree, _ = cgx.construct_ast(path)
29+
tree, _ = construct_ast(path)
2930

3031
# The only thing that we can't check is: RUF100: whether
3132
# there are unneeded noqa statement. That's because we use
@@ -90,7 +91,7 @@ def lint_file(path, fix=False, write=True):
9091
def read_lines_from_filename_patched(path: Path) -> list[str]:
9192
"""Read the lines for a file."""
9293
try:
93-
parser = cgx.CGXParser()
94+
parser = CGXParser()
9495
parser.feed(Path(path).read_text())
9596

9697
# Read the data from script block

ruff_cgx/template_formatter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collagraph.cgx import cgx
1+
from collagraph.sfc.parser import Comment, TextElement
22

33
INDENT = " "
44
SORTING = [
@@ -81,9 +81,9 @@ def format_node(node, depth, parser):
8181
result = []
8282
indent = depth * INDENT
8383

84-
if isinstance(node, cgx.Comment):
84+
if isinstance(node, Comment):
8585
result.append(f"{indent}<!--{node.content}-->")
86-
elif isinstance(node, cgx.TextElement):
86+
elif isinstance(node, TextElement):
8787
result.append(f"{indent}{node.content.strip()}")
8888
else:
8989
start = f"{indent}<{node.tag}"

0 commit comments

Comments
 (0)