-
Notifications
You must be signed in to change notification settings - Fork 17
176 lines (166 loc) · 6.3 KB
/
Copy pathlint.yml
File metadata and controls
176 lines (166 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Linters
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
name:
description: 'Reason'
required: false
default: 'Just Cause'
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
outputs:
python: ${{ steps.filter.outputs.python }}
typescript: ${{ steps.filter.outputs.typescript }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: filter
with:
filters: |
python:
- '**/*.py'
- 'requirements*.txt'
- 'pyproject.toml'
- '.github/workflows/lint.yml'
typescript:
- 'viewer/**'
- 'ingest/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- '.github/workflows/lint.yml'
build:
needs: changes
if: needs.changes.outputs.python == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python 3.14
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.14"
- name: Install uv
run: pip install uv
- name: Install dependencies
run: |
uv pip install --system -r requirements-dev.txt
uv pip install --system -e .
- name: Lint with ruff
run: |
python -m ruff check papyri
- name: Format check with ruff
if: always()
run: |
python -m ruff format --check papyri
- name: Test with mypy
if: always()
run: |
python -m mypy papyri
typescript:
needs: changes
if: needs.changes.outputs.typescript == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# No version pin: action-setup reads it from the root package.json
# "packageManager" field — the single source shared with the Dockerfile.
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22"
cache: "pnpm"
cache-dependency-path: "pnpm-lock.yaml"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint with ESLint (viewer)
run: pnpm --filter papyri-viewer run lint
- name: Format check with Prettier (viewer)
if: always()
run: pnpm --filter papyri-viewer run format:check
- name: Check TypeScript (Astro)
if: always()
run: pnpm --filter papyri-viewer run check
- name: Lint with ESLint (ingest)
if: always()
run: pnpm --filter papyri-ingest run lint
- name: Format check with Prettier (ingest)
if: always()
run: pnpm --filter papyri-ingest run format:check
- name: Check TypeScript (ingest)
if: always()
run: pnpm --filter papyri-ingest run check
ir-schema:
# Several TypeScript files mirror the Python IR (papyri/nodes.py) and can
# silently drift from it. This job catches that:
# - viewer/src/lib/ir-schema.ts is generated by scripts/gen_ir_schema.py,
# so we regenerate it (Python emit + Prettier, the two steps a
# contributor runs) and fail if it differs from what's committed.
# - ingest/src/encoder.ts FIELD_ORDER (the positional CBOR decoder) and
# viewer/src/lib/ir-types.ts IR_TYPE_NAMES are hand-maintained, so
# scripts/check_ir_sync.py validates them against papyri/nodes.py.
needs: changes
if: needs.changes.outputs.python == 'true' || needs.changes.outputs.typescript == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python 3.14
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.14"
- name: Install uv
run: pip install uv
- name: Install papyri
run: uv pip install --system -e .
# No version pin: action-setup reads it from the root package.json
# "packageManager" field — the single source shared with the Dockerfile.
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22"
cache: "pnpm"
cache-dependency-path: "pnpm-lock.yaml"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Regenerate ir-schema.ts
run: |
python scripts/gen_ir_schema.py
pnpm --filter papyri-viewer exec prettier --write src/lib/ir-schema.ts
- name: Fail if ir-schema.ts is out of sync
run: |
if ! git diff --exit-code -- viewer/src/lib/ir-schema.ts; then
echo "::error::viewer/src/lib/ir-schema.ts is out of sync with papyri/nodes.py."
echo "Regenerate it with: python scripts/gen_ir_schema.py && pnpm -C viewer run format"
exit 1
fi
- name: Check hand-maintained IR mirrors (encoder.ts, ir-types.ts)
run: python scripts/check_ir_sync.py
actionlint:
# No paths filter: invalid workflow YAML is silently rejected by GitHub
# Actions, so the only way to catch a regression is to validate on every
# PR before merge. ubuntu-latest ships Go, so we run actionlint via
# `go run` (downloads + executes in one step, pinned by version) — no
# curl|bash, no docker pull, no GOPATH/PATH dance.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Lint workflows
run: go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.7 -color