Skip to content

Commit 79eb4cb

Browse files
authored
Merge pull request #10 from Hasenpfote/markdown-lint
Add support for markdown lint
2 parents 168b427 + 9f531ec commit 79eb4cb

File tree

6 files changed

+366
-62
lines changed

6 files changed

+366
-62
lines changed

.github/settings/filters.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,30 @@
44
lint:
55
shared: &lint-shared
66
- '.github/actions/read-yaml/action.yml'
7+
- '.github/settings/filters.yml'
8+
- '.github/workflows/lint.yml'
9+
# python scripts
10+
py-shared: &lint-py-shared
711
- '.github/actions/setup-poetry/action.yml'
812
- '.github/actions/setup-poetry-dependencies/action.yml'
913
- '.github/settings/env.yml'
10-
- '.github/settings/filters.yml'
11-
- '.github/workflows/lint.yml'
14+
- '.github/workflows/py_lint.yml'
1215
- 'poetry.lock'
1316
- 'pyproject.toml'
14-
tox: &lint-tox
17+
py-lint: &lint-py-lint
1518
- 'tox.ini'
16-
py: &lint-py
1719
- added|modified: '**/*.py'
20+
py:
21+
- *lint-shared
22+
- *lint-py-shared
23+
- *lint-py-lint
24+
# markdown files
25+
md-lint: &lint-md-lint
26+
- '.markdownlint.yml'
27+
- added|modified: '**/*.md'
28+
md:
29+
- *lint-shared
30+
- *lint-md-lint
1831

1932
test:
2033
shared: &test-shared

.github/workflows/lint.yml

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ jobs:
1010
if: |
1111
github.event_name != 'pull_request' ||
1212
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
13-
1413
runs-on: ubuntu-latest
1514
outputs:
16-
tox: ${{ steps.filter.outputs.tox }}
17-
py: ${{ steps.filter.outputs.py }}
1815
has-changes: ${{ fromJson(steps.filter.outputs.changes)[0] != null }}
16+
py: ${{ steps.filter.outputs.py }}
17+
py-lint: ${{ steps.filter.outputs.py-lint }}
18+
md: ${{ steps.filter.outputs.md }}
19+
md-lint: ${{ steps.filter.outputs.md-lint }}
1920
steps:
2021
- name: Checkout
2122
uses: actions/checkout@v3
@@ -33,60 +34,23 @@ jobs:
3334
with:
3435
filters: ${{ steps.read-file.outputs.content }}
3536

36-
env_prep:
37+
py-lint:
3738
needs: determine-changes
38-
if: needs.determine-changes.outputs.has-changes == 'true'
39-
40-
runs-on: ubuntu-latest
41-
outputs:
42-
env: ${{ steps.read-file.outputs.content }}
43-
steps:
44-
- name: Checkout
45-
uses: actions/checkout@v3
46-
47-
- name: Read YAML file
48-
id: read-file
49-
uses: ./.github/actions/read-yaml
50-
with:
51-
path: .github/settings/env.yml
52-
filter: '.env'
53-
54-
build:
55-
needs: [determine-changes, env_prep]
56-
env: ${{ fromJson(needs.env_prep.outputs.env) }}
39+
if: needs.determine-changes.outputs.py == 'true'
40+
uses: ./.github/workflows/py_lint.yml
41+
with:
42+
enable-lint: ${{ fromJson(needs.determine-changes.outputs.py-lint) }}
5743

44+
md-lint:
45+
needs: determine-changes
46+
if: needs.determine-changes.outputs.md == 'true'
5847
runs-on: ubuntu-latest
5948
steps:
6049
- name: Checkout
6150
uses: actions/checkout@v3
6251

63-
- name: Set up Python ${{ env.python-version }}
64-
id: setup-python
65-
uses: actions/setup-python@v4
52+
- name: Lint all markdown files
53+
if: needs.determine-changes.outputs.md-lint == 'true'
54+
uses: DavidAnson/markdownlint-cli2-action@v9
6655
with:
67-
python-version: ${{ env.python-version }}
68-
69-
- name: Set up Poetry ${{ env.poetry-version }}
70-
id: setup-poetry
71-
uses: ./.github/actions/setup-poetry
72-
with:
73-
cache-path: ${{ env.poetry-cache-paths }}
74-
cache-key: ${{ format(env.poetry-cache-key-fmt, env.poetry-version, runner.os, steps.setup-python.outputs.python-version) }}
75-
poetry-version: ${{ env.poetry-version }}
76-
poetry-home: ${{ env.poetry-home }}
77-
poetry-path: ${{ env.poetry-path }}
78-
79-
- name: Set up Poetry dependencies
80-
id: setup-poetry-dependencies
81-
uses: ./.github/actions/setup-poetry-dependencies
82-
with:
83-
cache-key: ${{ format(env.venv-cache-key-fmt, runner.os, steps.setup-python.outputs.python-version, hashFiles('**/poetry.lock')) }}
84-
python-version: ${{ steps.setup-python.outputs.python-version }}
85-
poetry-install-args: --no-interaction --no-root --with dev
86-
87-
- name: Lint with tox
88-
if: |
89-
needs.determine-changes.outputs.tox == 'true' ||
90-
needs.determine-changes.outputs.py == 'true'
91-
run: |
92-
poetry run tox -e black,isort,flake8,mypy -p all -q
56+
globs: '**/*.md'

.github/workflows/py_lint.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
enable-lint:
5+
description: 'Enable lint'
6+
default: true
7+
required: false
8+
type: boolean
9+
10+
jobs:
11+
env_prep:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
env: ${{ steps.read-file.outputs.content }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Read YAML file
20+
id: read-file
21+
uses: ./.github/actions/read-yaml
22+
with:
23+
path: .github/settings/env.yml
24+
filter: '.env'
25+
26+
build:
27+
needs: env_prep
28+
env: ${{ fromJson(needs.env_prep.outputs.env) }}
29+
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v3
34+
35+
- name: Set up Python ${{ env.python-version }}
36+
id: setup-python
37+
uses: actions/setup-python@v4
38+
with:
39+
python-version: ${{ env.python-version }}
40+
41+
- name: Set up Poetry ${{ env.poetry-version }}
42+
id: setup-poetry
43+
uses: ./.github/actions/setup-poetry
44+
with:
45+
cache-path: ${{ env.poetry-cache-paths }}
46+
cache-key: ${{ format(env.poetry-cache-key-fmt, env.poetry-version, runner.os, steps.setup-python.outputs.python-version) }}
47+
poetry-version: ${{ env.poetry-version }}
48+
poetry-home: ${{ env.poetry-home }}
49+
poetry-path: ${{ env.poetry-path }}
50+
51+
- name: Set up Poetry dependencies
52+
id: setup-poetry-dependencies
53+
uses: ./.github/actions/setup-poetry-dependencies
54+
with:
55+
cache-key: ${{ format(env.venv-cache-key-fmt, runner.os, steps.setup-python.outputs.python-version, hashFiles('**/poetry.lock')) }}
56+
python-version: ${{ steps.setup-python.outputs.python-version }}
57+
poetry-install-args: --no-interaction --no-root --with dev
58+
59+
- name: Lint all python scripts
60+
if: inputs.enable-lint == true
61+
run: |
62+
poetry run tox -e black,isort,flake8,mypy -p all -q

0 commit comments

Comments
 (0)