Skip to content

Commit 39b6165

Browse files
committed
enrich CI: add linters for Markdown, YAML, Python (PEP8)
1 parent ba2a4fa commit 39b6165

File tree

5 files changed

+114
-0
lines changed

5 files changed

+114
-0
lines changed

.config/.flake8

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# flake8 checks for PEP-8 compliance
2+
# https://flake8.pycqa.org/en/latest/user/configuration.html
3+
4+
[flake8]
5+
6+
max-line-length = 120
7+
8+
exclude =
9+
.git,
10+
.temp

.config/.markdownlint.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Manual for `.markdownlint.yaml` config:
2+
# https://github.com/DavidAnson/markdownlint#optionsconfig
3+
# Config file JSON schema:
4+
# https://github.com/DavidAnson/markdownlint/blob/main/schema/markdownlint-config-schema.json
5+
---
6+
default: true
7+
8+
# Trailing spaces
9+
MD009:
10+
br_spaces: 2
11+
12+
# Line length
13+
MD013:
14+
line_length: 140
15+
code_blocks: false
16+
tables: false
17+
18+
# Multiple headers with same content
19+
MD024:
20+
siblings_only: true
21+
22+
# Inline HTML
23+
MD033:
24+
allowed_elements:
25+
- br

.config/.yamllint.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Manual for `.yamllint.yaml` config:
2+
# https://yamllint.readthedocs.io/en/stable/configuration.html
3+
---
4+
extends: default
5+
6+
yaml-files:
7+
- '*.yaml'
8+
- '*.yml'
9+
- '.yamllint'
10+
11+
rules:
12+
line-length:
13+
max: 120
14+
level: warning
15+
brackets:
16+
min-spaces-inside: 1
17+
max-spaces-inside: 1
18+
comments:
19+
min-spaces-from-content: 1
20+
new-lines:
21+
type: unix

.github/workflows/build_cmake.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ jobs:
6464
steps:
6565
- uses: actions/checkout@v2
6666

67+
- name: Check Markdown syntax (docker)
68+
if: runner.os == 'Linux'
69+
shell: sh
70+
run: |
71+
make -- check-md
72+
73+
- name: Check YAML syntax (docker)
74+
if: runner.os == 'Linux'
75+
shell: sh
76+
run: |
77+
make -- check-yaml
78+
79+
- name: Check Python syntax (PEP8) (docker)
80+
if: runner.os == 'Linux'
81+
shell: sh
82+
run: |
83+
make -- check-pep8
84+
6785
- name: Set up Python ${{ env.PYTHON_VERSION }}
6886
uses: actions/setup-python@v3
6987
with:

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# =================================
2+
CODE_DIR_ROOT = ./
3+
4+
FLAKE8_CONFIG = ./.config/.flake8
5+
MARKDOWNLINT_CONFIG = ./.config/.markdownlint.yaml
6+
YAMLLINT_CONFIG = ./.config/.yamllint.yaml
7+
8+
# =================================
9+
10+
check-all: check-md check-yaml check-pep8
11+
12+
# =================================
13+
14+
check-md:
15+
# Using two slashes at the beginning of the paths for Windows bash shell
16+
docker run --rm --tty --network=none --volume="${CURDIR}:/markdown:ro" \
17+
--workdir=//markdown/ \
18+
06kellyjac/markdownlint-cli:0.27.1-alpine \
19+
--config=${MARKDOWNLINT_CONFIG} \
20+
--ignore=./dependency/CrowCpp/README.md \
21+
-- ./
22+
23+
check-yaml:
24+
# Using two slashes at the beginning of the paths for Windows bash shell
25+
docker run --rm --tty --network=none --volume="$(CURDIR):/data:ro" \
26+
--workdir=//data/ \
27+
cytopia/yamllint:1.26-0.9 \
28+
-c=${YAMLLINT_CONFIG} \
29+
--strict \
30+
-- ./
31+
32+
check-pep8:
33+
# Using two slashes at the beginning of the paths for Windows bash shell
34+
docker run --rm --tty --network=none --volume="${CURDIR}:/apps:ro" \
35+
--workdir=//apps/ \
36+
alpine/flake8:4.0.1 \
37+
--config=${FLAKE8_CONFIG} \
38+
-- ${CODE_DIR_ROOT}
39+
40+
# =================================

0 commit comments

Comments
 (0)