Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit d074077

Browse files
authored
Use setuptools for plugin mechanism. (#72)
* Convert to pyproject.toml configuration. * Drop Python 3.8. * Add Python 3.13. * Add ubuntu-24.04 to CI. * Remove proselint plugin. Not used as far as I know, and causing too many issues with type hints and unit tests. * Be explicit that we are ignoring unit test line coverage for now. * Use runner.os to simplify Linux-specific action steps.
1 parent a4290ea commit d074077

File tree

76 files changed

+265
-710
lines changed

Some content is hidden

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

76 files changed

+265
-710
lines changed

.codecov.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 0%
6+
threshold: null

.github/workflows/publish.yaml

+10-36
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
33

4-
on: # NOLINT
4+
on: # NOLINT
55
push:
66
tags:
77
- "*"
@@ -10,6 +10,11 @@ jobs:
1010
build-n-publish:
1111
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
1212
runs-on: ubuntu-latest
13+
environment:
14+
name: pypi
15+
url: https://pypi.org/p/statick-md
16+
permissions:
17+
id-token: write
1318

1419
steps:
1520
- uses: actions/checkout@v3
@@ -18,47 +23,16 @@ jobs:
1823
uses: actions/setup-python@v4
1924
with:
2025
python-version: "3.11"
21-
22-
- uses: actions/cache@v3
23-
if: startsWith(runner.os, 'Linux')
24-
with:
25-
path: ~/.cache/pip
26-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
27-
restore-keys: |
28-
${{ runner.os }}-pip-
29-
30-
- uses: actions/cache@v3
31-
if: startsWith(runner.os, 'macOS')
32-
with:
33-
path: ~/Library/Caches/pip
34-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
35-
restore-keys: |
36-
${{ runner.os }}-pip-
37-
38-
- uses: actions/cache@v3
39-
if: startsWith(runner.os, 'Windows')
40-
with:
41-
path: ~\AppData\Local\pip\Cache
42-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
43-
restore-keys: |
44-
${{ runner.os }}-pip-
26+
cache: 'pip'
4527

4628
- name: Install tools
4729
run: |
48-
python -m pip install --upgrade setuptools
49-
python -m pip install --upgrade wheel
30+
pip install .[dist]
5031
5132
- name: Build a binary wheel and a source tarball
5233
run: |
53-
python setup.py sdist bdist_wheel
54-
55-
- name: Publish distribution 📦 to Test PyPI
56-
uses: pypa/gh-action-pypi-publish@release/v1
57-
with:
58-
password: ${{ secrets.PYPI_TEST_TOKEN }}
59-
repository_url: https://test.pypi.org/legacy/
34+
pip install -q build
35+
python -m build
6036
6137
- name: Publish distribution 📦 to PyPI
6238
uses: pypa/gh-action-pypi-publish@release/v1
63-
with:
64-
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/tests.yaml

+14-45
Original file line numberDiff line numberDiff line change
@@ -14,86 +14,55 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
os: [macos-latest, ubuntu-20.04, ubuntu-22.04, windows-latest]
18-
python-version: ['3.8', '3.9', '3.10', '3.11']
17+
os: [macos-latest, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, windows-latest]
18+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222

23-
- uses: actions/setup-node@v3
23+
- uses: actions/setup-node@v4
2424
with:
25-
node-version: '16'
25+
node-version: '20'
2626

2727
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v4
28+
uses: actions/setup-python@v5
2929
with:
3030
python-version: ${{ matrix.python-version }}
31-
32-
- uses: actions/cache@v3
33-
if: startsWith(runner.os, 'Linux')
34-
with:
35-
path: ~/.cache/pip
36-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
37-
restore-keys: |
38-
${{ runner.os }}-pip-
39-
40-
- uses: actions/cache@v3
41-
if: startsWith(runner.os, 'macOS')
42-
with:
43-
path: ~/Library/Caches/pip
44-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
45-
restore-keys: |
46-
${{ runner.os }}-pip-
47-
48-
- uses: actions/cache@v3
49-
if: startsWith(runner.os, 'Windows')
50-
with:
51-
path: ~\AppData\Local\pip\Cache
52-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
53-
restore-keys: |
54-
${{ runner.os }}-pip-
31+
cache: 'pip'
5532

5633
- name: Install dependencies
5734
run: |
5835
python -m pip install --upgrade pip
59-
python -m pip install --upgrade setuptools
60-
python -m pip install --upgrade wheel
61-
python -m pip install --upgrade coverage
62-
python -m pip install --upgrade mypy
63-
python -m pip install --upgrade types-docutils
64-
python -m pip install --upgrade tox
65-
python -m pip install --upgrade tox-gh-actions
66-
python -m pip install --upgrade virtualenv
36+
pip install .[docs,test]
6737
68-
# Have to install newer version from non-apt source due to SSL library compatibility issues.
69-
- name: Install Node and node-based tools (Linux)
70-
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04'
38+
- name: Install Node tools (Linux)
39+
if: runner.os == 'Linux'
7140
run: |
7241
npm install -g markdownlint-cli
7342
npm install -g write-good
7443
7544
- name: Mypy
7645
run: |
77-
mypy --ignore-missing-imports --strict src/
46+
mypy --ignore-missing-imports --strict src/statick_tool/
7847
7948
- name: Tox
8049
run: |
8150
python -m tox
8251
8352
- name: Upload coverage to Codecov
84-
uses: codecov/codecov-action@v3
53+
uses: codecov/codecov-action@v5
8554
with:
8655
fail_ci_if_error: false
8756

8857
- name: Statick Documentation
89-
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04'
58+
if: runner.os == 'Linux'
9059
uses: sscpac/statick-action@v0.9.2
9160
with:
9261
profile: documentation.yaml
9362
timings: true
9463

9564
- name: Self check
96-
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04'
65+
if: runner.os == 'Linux'
9766
uses: sscpac/statick-action@v0.9.2
9867
with:
9968
profile: self_check.yaml

CHANGELOG.md

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66

77
## Unreleased
88

9+
### Added
10+
11+
- Support for Python 3.12 and 3.13.
12+
- Use of `pyproject.toml` instead of `setup.py` and `requirements.txt`.
13+
- Supports new plugin discovery mechanism for the main Statick tool.
14+
- Switched from yapsy to setuptools for plugin mechanism. (sscpac/statick#508)
15+
16+
### Changed
17+
18+
- Disabled code coverage requirements in CI for now.
19+
- Unable to get line coverage working with new plugin mechanism.
20+
Unit tests still work to find problems.
21+
- Updated README to use more modern approach to installing Python and NPM packages.
22+
- Rename plugin modules so they are shorter and less redundant.
23+
24+
### Removed
25+
26+
- No longer support Python 3.8.
27+
- Proselint tool removed.
28+
- Unable to resolve type hint and unit test issues.
29+
Tool not used as far as Statick developers are aware.
30+
931
## v0.2.0 - 2025-01-03
1032

1133
### Removed

README.md

+45-51
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,61 @@ Custom exceptions can be applied the same way they are with
1818

1919
## Table of Contents
2020

21-
* [Installation](#installation)
22-
* [Usage](#usage)
23-
* [Existing Plugins](#existing-plugins)
24-
* [Discovery Plugins](#discovery-plugins)
25-
* [Tool Plugins](#tool-plugins)
26-
* [Contributing](#contributing)
27-
* [Mypy](#mypy)
28-
* [Formatting](#formatting)
21+
- [Statick Markdown Plugins](#statick-markdown-plugins)
22+
- [Table of Contents](#table-of-contents)
23+
- [Installation](#installation)
24+
- [Usage](#usage)
25+
- [Dependency Versions](#dependency-versions)
26+
- [Pip Install](#pip-install)
27+
- [Pip Install and Custom Configuration](#pip-install-and-custom-configuration)
28+
- [Existing Plugins](#existing-plugins)
29+
- [Discovery Plugins](#discovery-plugins)
30+
- [Tool Plugins](#tool-plugins)
31+
- [Contributing](#contributing)
32+
- [Mypy](#mypy)
33+
- [Formatting](#formatting)
2934

3035
## Installation
3136

3237
The recommended method to install these Statick plugins is via pip:
3338

3439
```shell
35-
python3 -m pip install statick-md
40+
pip install statick-md
3641
```
3742

3843
You can also clone the repository and use it locally.
3944

4045
## Usage
4146

42-
Make sure you install all the dependencies from apt/npm:
47+
Make sure you install all the dependencies from apt/npm.
48+
See <https://github.com/nodesource/distributions> for Node/npm installation instructions.
49+
50+
Configure npm to allow a non-root user to install packages.
51+
52+
```shell
53+
npm config set prefix '~/.local/'
54+
```
55+
56+
Make sure `~/.local/bin` exists.
57+
Check your `PATH` with `echo $PATH`.
58+
If `~/.local/bin` is not listed then add it to your `PATH`.
4359

4460
```shell
45-
cat install.txt | xargs sudo apt-get install -y
46-
cat npm-deps.txt | xargs sudo npm install -g
61+
mkdir -p ~/.local/bin
62+
echo 'export PATH="$HOME/.local/bin/:$PATH"' >> ~/.bashrc
63+
```
64+
65+
Install packages.
66+
67+
```shell
68+
npm install -g markdownlint-cli
69+
npm install -g write-good
4770
```
4871

4972
### Dependency Versions
5073

5174
Markdownlint-cli has occasionally changed defaults via an upgrade that results in lots of new warnings.
52-
To mitigate this you can pin the version of markdownlint-cli in npm-deps.txt by changing `markdownlint-cli` to `markdownlint-cli@0.19`.
75+
To mitigate this you can pin the version of markdownlint-cli when installing by changing `markdownlint-cli` to `markdownlint-cli@0.19`.
5376

5477
### Pip Install
5578

@@ -59,13 +82,12 @@ In that case your directory structure will look like the following:
5982
```shell
6083
project-root
6184
|- md-project
62-
|- statick-output
6385
```
6486

6587
To run with the default configuration for the statick-md tools use:
6688

6789
```shell
68-
statick md-project/ --output-directory statick-output/ --profile md-profile.yaml --config md-config.yaml
90+
statick md-project/ -o /tmp/statick-output/ --level md --log info
6991
```
7092

7193
### Pip Install and Custom Configuration
@@ -77,40 +99,16 @@ This example will have custom exceptions in the md-project, such that the direct
7799

78100
```shell
79101
project-root
80-
|- md-project
81-
|- statick-config
82-
|- rsc
83-
|- exceptions.yaml
84-
|- statick-output
102+
|- md-project
103+
|- statick-config
104+
|- rsc
105+
|- exceptions.yaml
85106
```
86107

87108
For this setup you will run the following:
88109

89110
```shell
90-
statick md-project/ --output-directory statick-output/ --user-paths md-project/statick-config/ --profile md-profile.yaml --config md-config.yaml
91-
```
92-
93-
### Source Install and Custom Configuration
94-
95-
The last type of setup will be to have all of the tools available from cloning repositories, not installing from pip.
96-
The directory structure will look like:
97-
98-
```shell
99-
project-root
100-
|- md-project
101-
|- statick-config
102-
|- rsc
103-
|- exceptions.yaml
104-
|- statick-output
105-
|- statick
106-
|- statick-md
107-
```
108-
109-
Using the example where we want to override the default exceptions with
110-
custom ones in the md-project, the command to run would be:
111-
112-
```shell
113-
./statick/statick md-project/ --output-directory statick-output/ --user-paths statick-md/,statick-md/src/statick_md,md-project/statick-config/ --profile md-profile.yaml --config md-config.yaml
111+
statick md-project/ --o /tmp/statick-output/ -u md-project/statick-config/ --level md
114112
```
115113

116114
## Existing Plugins
@@ -127,7 +125,6 @@ reStructuredText | `.rst`
127125
Tool | About
128126
:--- | :----
129127
[markdownlint][markdownlint] | A Node.js style checker and lint tool for Markdown/CommonMark files.
130-
[proselint][proselint] | A linter for prose.
131128
[rstcheck][rstcheck] | Checks syntax of reStructuredText and code blocks nested within it.
132129
[rst-lint][rst-lint] | Checks syntax of reStructuredText and code blocks nested within it.
133130
[write-good] | Naive linter for English prose.
@@ -150,25 +147,22 @@ To determine if proper types are being used in Statick Markdown the following co
150147
types of reports that can be viewed with a text editor or web browser.
151148

152149
```shell
153-
python3 -m pip install mypy
150+
pip install mypy
154151
mkdir report
155-
mypy --ignore-missing-imports --strict --html-report report/ --txt-report report src
152+
mypy --ignore-missing-imports --strict src
156153
```
157154

158-
It is hoped that in the future we will generate coverage reports from mypy and use those to check for regressions.
159-
160155
### Formatting
161156

162157
Statick code is formatted using [black](https://github.com/psf/black).
163158
To fix locally use
164159

165160
```shell
166-
python3 -m pip install black
161+
pip install black
167162
black src tests
168163
```
169164

170165
[markdownlint]: https://github.com/igorshubovych/markdownlint-cli
171-
[proselint]: https://github.com/amperser/proselint
172166
[rstcheck]: https://github.com/myint/rstcheck
173167
[rst-lint]: https://github.com/twolfson/restructuredtext-lint
174168
[write-good]: https://github.com/btford/write-good

clean.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

3-
rm -rf build/ dist/ output-py* .pytest_cache statick_md.egg-info/ statick_output/* .tox/
3+
rm -rf build/ .coverage dist/ output-py* .pytest_cache statick_md.egg-info/ statick_output/* .tox/ ./*.log
44
find . -type d -name .mypy_cache -exec rm -rf {} +;
55
find . -type d -name __pycache__ -exec rm -rf {} +;

install.txt

-1
This file was deleted.

npm-deps.txt

-1
This file was deleted.

0 commit comments

Comments
 (0)