Skip to content

Commit

Permalink
Rework testing/CI setup to rely more on Hatch
Browse files Browse the repository at this point in the history
This is largely the same setup as I use for my other projects
  • Loading branch information
oprypin committed Sep 16, 2023
1 parent bcde908 commit 063f350
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 182 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI
on:
push:
pull_request:
schedule:
- cron: '0 6 * * 6'
defaults:
run:
shell: bash
jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- python: '^3.10'
os: macos-latest
- python: '3.10'
os: windows-latest
- python: 3.9
os: ubuntu-latest
- python: 3.8
os: macos-latest
- python: 3.7
os: windows-latest
- python: 3.7
os: ubuntu-latest
versions: minimal
runs-on: ${{matrix.os}}
steps:
- name: Download source
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{matrix.python}}
- name: Pin to lowest versions
if: matrix.versions == 'minimal'
run: |
sed -i -E 's/#min //; s/\b >=([0-9])/ ==\1/' pyproject.toml
- name: Install Hatch
run: |
pip install hatch
- name: Install dependencies
run: |
hatch run test:pip freeze
- name: Run tests
run: |
hatch run test:test
style:
runs-on: ubuntu-latest
steps:
- name: Download source
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Hatch
run: |
pip install hatch
- name: Install dependencies
run: |
hatch run style:pip freeze
hatch run types:pip freeze
- name: Check style
if: always()
run: |
hatch run style:fix
- name: Check formatting
if: always()
run: |
hatch run style:format
git diff --color --exit-code
- name: Check types
if: always()
run: |
hatch run types:check
35 changes: 0 additions & 35 deletions .github/workflows/tests.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ venv.bak/
.ropeproject

# mkdocs documentation
/site
site

# mypy
.mypy_cache/
Expand Down
22 changes: 5 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,29 @@ To start developing on this project, create a fork of this repository on GitHub,

```bash
git clone https://github.com/<USERNAME>/mkdocs-click
```

You can now install development dependencies using:

```bash
cd mkdocs-click
scripts/install
```

## Example docs site

You can run the example docs site that lives in `example/` locally using:

```bash
scripts/docs serve
hatch run test:mkdocs serve -f example/mkdocs.yml
```

## Testing and linting

Once dependencies are installed, you can run the test suite using:

```bash
scripts/test
```

You can run code auto-formatting using:
You can run the test suite using:

```bash
scripts/format
hatch run test:test
```

To run style checks, use:
You can run code auto-formatting and style checks using:

```bash
scripts/style
hatch run style:fix
```

## Releasing
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions mkdocs.yml → example/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
site_name: mkdocs-click example
theme: readthedocs

docs_dir: example

markdown_extensions:
- attr_list
- mkdocs-click
116 changes: 97 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,126 @@ name = "mkdocs-click"
description = "An MkDocs extension to generate documentation for Click command line applications"
readme = "README.md"
license = "Apache-2.0"
requires-python = ">=3.7"
keywords = ["click", "datadog", "mkdocs", "mkdocs-plugin"]
authors = [
{ name = "Datadog", email = "[email protected]" },
]
keywords = [
"click",
"datadog",
"mkdocs",
{name = "Datadog", email = "[email protected]"},
]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Documentation",
"Topic :: Software Development :: Documentation",
"Topic :: Text Processing :: Markup :: Markdown",
"Typing :: Typed",
]
dynamic = ["version"]
requires-python = ">=3.7"
dependencies = [
"click~=8.1",
"markdown==3.*",
"click >=8.1",
"markdown >=3.3",
]
dynamic = ["version"]

[project.urls]
Source = "https://github.com/mkdocs/mkdocs-click"
Issues = "https://github.com/mkdocs/mkdocs-click/issues"
Changelog = "https://github.com/mkdocs/mkdocs-click/blob/master/CHANGELOG.md"

[project.entry-points."markdown.extensions"]
mkdocs-click = "mkdocs_click:MKClickExtension"

[project.urls]
Homepage = "https://github.com/DataDog/mkdocs-click"
Changelog = "https://github.com/DataDog/mkdocs-click/blob/master/CHANGELOG.md"

[tool.hatch.version]
path = "mkdocs_click/__version__.py"

[tool.hatch.build.targets.sdist]
include = [
"/mkdocs_click",
"/CHANGELOG.md",
include = ["/mkdocs_click", "/CHANGELOG.md", "/tests"]

[tool.hatch.envs.default.scripts]
all = [
"hatch run style:fix",
"hatch run types:check",
"hatch run test:test",
]

[tool.hatch.envs.test]
dependencies = [
"pytest",
"mkdocs >=1.1.2",
]
[tool.hatch.envs.test.scripts]
test = [
"pytest -q",
"mkdocs build -q --strict -f example/mkdocs.yml",
]

[tool.hatch.envs.types]
dependencies = [
"mypy",
"types-Markdown >=3.4.2",
]
[tool.hatch.envs.types.scripts]
check = [
"mypy mkdocs_click"
]

[tool.hatch.envs.style]
skip-install = true
dependencies = [
"ruff",
"isort",
"black",
]
[tool.hatch.envs.style.scripts]
fix = [
"ruff check --fix mkdocs_click tests",
"format",
]
format = [
"isort -q mkdocs_click tests",
"black -q mkdocs_click tests",
]

[tool.black]
line-length = 120
target-version = ["py37"]

[tool.isort]
profile = "black"
line_length = 120

[tool.ruff]
select = [
"F", "W", "E", "UP", "YTT", "C4", "FA", "PIE", "T20", "RSE", "TCH", "DTZ",
"B002", "B003", "B005", "B007", "B009", "B012", "B013", "B014", "B015", "B018", "B020", "B021", "B023", "B026", "B033", "B034", "B905",
"COM818",
"PERF101",
"PGH002", "PGH004", "PGH005",
"PLE", "PLW0120", "PLW0127",
"RUF001", "RUF007", "RUF010", "RUF100", "RUF200",
"SIM101", "SIM107", "SIM201", "SIM202", "SIM208", "SIM210", "SIM211", "SIM300", "SIM401", "SIM910",
]
ignore = ["E501", "E731"]
[tool.ruff.flake8-comprehensions]
allow-dict-calls-with-keyword-arguments = true

[tool.mypy]
disallow_untyped_defs = true
ignore_missing_imports = true
warn_unreachable = true
no_implicit_optional = true
show_error_codes = true

[tool.pytest.ini_options]
addopts = "--tb=native"
enable_assertion_pass_hook = true
filterwarnings = ["ignore::DeprecationWarning:.*:",
"default::DeprecationWarning:mkdocs_click.*:"]
testpaths = ["tests"]
18 changes: 0 additions & 18 deletions requirements.txt

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/build

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/docs

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/format

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/install

This file was deleted.

Loading

0 comments on commit 063f350

Please sign in to comment.