Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/reusable-code-quality-markdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Reusable - Code Quality - Markdown

on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
osl-utils-tag:
type: string
description: 'Tag of the osl-utils docker image to use'
required: true

jobs:
linting:
runs-on: ubuntu-latest
container:
image: ghcr.io/asfopensarlab/osl-utils:${{ inputs.osl-utils-tag }}
volumes:
- ${{ github.workspace }}:/code
steps:
- name: Checkout Code
uses: actions/checkout@v5

- name: Run Markdown Linting
run: |
cd /app
make markdown_lint
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

node_modules/
24 changes: 24 additions & 0 deletions .markdownlint-cli2.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// https://github.com/theoludwig/markdownlint-rule-relative-links

import relativeLinksRule from "markdownlint-rule-relative-links"

const config = {
config: {
default: true,
"relative-links": {
// The root of the project for resolving paths,
// NOT the path to start looking for md's from.
root_path: "/code",
},
},
// HERE is where you specify the path to files to lint:
globs: ["/code/**/*.md"],
ignores: [
"**/node_modules",
"**/.venv",
"**/cdk.out",
],
customRules: [relativeLinksRule],
}

export default config
8 changes: 8 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Config File for markdownlint
# Full example and options at:
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml

default: true

# # MD013/line-length : Line length - Disable
MD013: false
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,8 @@ RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2
unzip awscliv2.zip && \
./aws/install

## Install AWS CDK:
# Install node/aws-cdk
# hadolint ignore=DL3016
RUN npm install -g aws-cdk

### PYTHON STUFF:
COPY ./requirements.txt /requirements.txt

# Install wheel first so it can be used with the rest of the packages
# hadolint ignore=DL3013
RUN python3.11 -m pip install --no-cache-dir --upgrade wheel && \
Expand All @@ -61,5 +56,18 @@ RUN ln -sf /usr/bin/pip3.11 /usr/bin/pip && \
ln -sf /usr/bin/python3.11 /usr/bin/python3 && \
ln -sf /usr/bin/python3.11 /usr/bin/python

# Make the path, relative to here for the rest of the commands:
WORKDIR /app

### NODE STUFF:
# Copy package.json and package-lock.json
COPY package*.json .

## Install AWS CDK:
# Install aws-cdk, markdownlint stuff
# hadolint ignore=DL3016
RUN npm install --no-audit --no-fund

COPY linting.Makefile /app/Makefile
COPY .markdownlint.yaml /app/.markdownlint.yaml
COPY .markdownlint-cli2.mjs /app/.markdownlint-cli2.mjs
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,20 @@ jobs:
# The osl-utils docker tag. Can also be `dev`, initials, etc. Should match the tag above in prod.
osl-utils-tag: v#.#.#
```

### [`reusable-code-quality-markdown.yaml`](.github/workflows/reusable-code-quality-markdown.yaml)

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.

```yaml
name: Lint Markdown
on:
pull_request:

jobs:
shell:
uses: ASFOpenSARlab/osl-utils/.github/workflows/reusable-code-quality-markdown.yaml@v#.#.#
with:
# The osl-utils docker tag. Can also be `dev`, initials, etc. Should match the tag above in prod.
osl-utils-tag: v#.#.#
```
6 changes: 5 additions & 1 deletion linting.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fix: jinja_format_fix python_lint_fix python_format_fix shell_format_fix yaml_fo
define HELP_MESSAGE

make all: lint check
make lint: docker_lint jinja_lint python_lint_check shell_lint yaml_lint
make lint: docker_lint jinja_lint markdown_lint python_lint_check shell_lint yaml_lint
make check: jinja_format_check python_format_check shell_format_check yaml_format_check
make fix: jinja_format_fix python_lint_fix python_format_fix shell_format_fix yaml_format_fix

Expand Down Expand Up @@ -66,6 +66,10 @@ jinja_format_fix:
djlint /code --reformat --extension=j2; \
djlint /code --reformat --extension=html

# NO `cd /code`, it points to /code in it's configs, but needs to be in /app
markdown_lint:
node --run lint:markdown

python_lint_check:
cd /code; \
ruff check /code --output-format=github
Expand Down
Loading