Skip to content

Commit 70bc0ba

Browse files
Merge pull request #28 from ASFOpenSARlab/cs/markdown-lint
Adding Makefile linting to the project
2 parents 687820e + 5bb4345 commit 70bc0ba

9 files changed

Lines changed: 1403 additions & 7 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: Reusable - Code Quality - Markdown
3+
4+
on: # yamllint disable-line rule:truthy
5+
workflow_call:
6+
inputs:
7+
osl-utils-tag:
8+
type: string
9+
description: 'Tag of the osl-utils docker image to use'
10+
required: true
11+
12+
jobs:
13+
linting:
14+
runs-on: ubuntu-latest
15+
container:
16+
image: ghcr.io/asfopensarlab/osl-utils:${{ inputs.osl-utils-tag }}
17+
volumes:
18+
- ${{ github.workspace }}:/code
19+
steps:
20+
- name: Checkout Code
21+
uses: actions/checkout@v5
22+
23+
- name: Run Markdown Linting
24+
run: |
25+
cd /app
26+
make markdown_lint

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
node_modules/

.markdownlint-cli2.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// https://github.com/theoludwig/markdownlint-rule-relative-links
2+
3+
import relativeLinksRule from "markdownlint-rule-relative-links"
4+
5+
const config = {
6+
config: {
7+
default: true,
8+
"relative-links": {
9+
// The root of the project for resolving paths,
10+
// NOT the path to start looking for md's from.
11+
root_path: "/code",
12+
},
13+
},
14+
// HERE is where you specify the path to files to lint:
15+
globs: ["/code/**/*.md"],
16+
ignores: [
17+
"**/node_modules",
18+
"**/.venv",
19+
"**/cdk.out",
20+
],
21+
customRules: [relativeLinksRule],
22+
}
23+
24+
export default config

.markdownlint.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Config File for markdownlint
2+
# Full example and options at:
3+
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
4+
5+
default: true
6+
7+
# # MD013/line-length : Line length - Disable
8+
MD013: false

Dockerfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,8 @@ RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2
4444
unzip awscliv2.zip && \
4545
./aws/install
4646

47-
## Install AWS CDK:
48-
# Install node/aws-cdk
49-
# hadolint ignore=DL3016
50-
RUN npm install -g aws-cdk
51-
47+
### PYTHON STUFF:
5248
COPY ./requirements.txt /requirements.txt
53-
5449
# Install wheel first so it can be used with the rest of the packages
5550
# hadolint ignore=DL3013
5651
RUN python3.11 -m pip install --no-cache-dir --upgrade wheel && \
@@ -61,5 +56,18 @@ RUN ln -sf /usr/bin/pip3.11 /usr/bin/pip && \
6156
ln -sf /usr/bin/python3.11 /usr/bin/python3 && \
6257
ln -sf /usr/bin/python3.11 /usr/bin/python
6358

59+
# Make the path, relative to here for the rest of the commands:
6460
WORKDIR /app
61+
62+
### NODE STUFF:
63+
# Copy package.json and package-lock.json
64+
COPY package*.json .
65+
66+
## Install AWS CDK:
67+
# Install aws-cdk, markdownlint stuff
68+
# hadolint ignore=DL3016
69+
RUN npm install --no-audit --no-fund
70+
6571
COPY linting.Makefile /app/Makefile
72+
COPY .markdownlint.yaml /app/.markdownlint.yaml
73+
COPY .markdownlint-cli2.mjs /app/.markdownlint-cli2.mjs

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,20 @@ jobs:
187187
# The osl-utils docker tag. Can also be `dev`, initials, etc. Should match the tag above in prod.
188188
osl-utils-tag: v#.#.#
189189
```
190+
191+
### [`reusable-code-quality-markdown.yaml`](.github/workflows/reusable-code-quality-markdown.yaml)
192+
193+
Uses [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) to lint the markdown files themselves, and [`markdownlint-rule-relative-links`](https://github.com/theoludwig/markdownlint-rule-relative-links) to verify relative links.
194+
195+
```yaml
196+
name: Lint Markdown
197+
on:
198+
pull_request:
199+
200+
jobs:
201+
shell:
202+
uses: ASFOpenSARlab/osl-utils/.github/workflows/reusable-code-quality-markdown.yaml@v#.#.#
203+
with:
204+
# The osl-utils docker tag. Can also be `dev`, initials, etc. Should match the tag above in prod.
205+
osl-utils-tag: v#.#.#
206+
```

linting.Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fix: jinja_format_fix python_lint_fix python_format_fix shell_format_fix yaml_fo
1414
define HELP_MESSAGE
1515

1616
make all: lint check
17-
make lint: docker_lint jinja_lint python_lint_check shell_lint yaml_lint
17+
make lint: docker_lint jinja_lint markdown_lint python_lint_check shell_lint yaml_lint
1818
make check: jinja_format_check python_format_check shell_format_check yaml_format_check
1919
make fix: jinja_format_fix python_lint_fix python_format_fix shell_format_fix yaml_format_fix
2020

@@ -66,6 +66,10 @@ jinja_format_fix:
6666
djlint /code --reformat --extension=j2; \
6767
djlint /code --reformat --extension=html
6868

69+
# NO `cd /code`, it points to /code in it's configs, but needs to be in /app
70+
markdown_lint:
71+
node --run lint:markdown
72+
6973
python_lint_check:
7074
cd /code; \
7175
ruff check /code --output-format=github

0 commit comments

Comments
 (0)