Skip to content

Commit 245df40

Browse files
Add markdown linting
1 parent a54b825 commit 245df40

4 files changed

Lines changed: 120 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main", "v2"]
6+
pull_request:
7+
branches: ["main", "v2"]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: false
12+
13+
jobs:
14+
dp-operations-lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 0
20+
- uses: tj-actions/changed-files@v46
21+
id: changed-files
22+
with:
23+
files: '**/*.md'
24+
separator: ","
25+
- uses: DavidAnson/markdownlint-cli2-action@v20
26+
if: steps.changed-files.outputs.any_changed == 'true'
27+
with:
28+
globs: ${{ steps.changed-files.outputs.all_changed_files }}
29+
separator: ","

.markdownlint-cli2.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
config:
3+
line-length: false
4+
ul-style:
5+
style: dash
6+
ignores:
7+
- "LICENSE.md"

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Keeping the hooks versions up to date can be done by running `pre-commit autoupdate` validate that the examples still pass correctly before pushing the updated version changes
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks: # Available hooks https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md
6+
# Git style
7+
- id: check-added-large-files # prevents giant files from being committed.
8+
- id: check-merge-conflict # checks for files that contain merge conflict strings.
9+
- id: check-vcs-permalinks # ensures that links to vcs websites are permalinks.
10+
- id: no-commit-to-branch # Protect specific branches from direct commits.
11+
args: [--branch, main] # Protected in the repo config. but this will prevent you even getting that far
12+
# Common errors
13+
- id: end-of-file-fixer # Ensures that a file is either empty, or ends with one newline.
14+
- id: trailing-whitespace # Trims trailing whitespace.
15+
args: [--markdown-linebreak-ext=md] # Preserve hard line breaks in MD files
16+
- id: check-yaml # Attempts to load all yaml files to verify syntax.
17+
- id: check-executables-have-shebangs # Checks that non-binary executables have a proper shebang.
18+
# Cross platform
19+
- id: check-case-conflict # Check for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT.
20+
- id: mixed-line-ending # Replaces or checks mixed line ending.
21+
args: [--fix=lf] # Forces to replace line ending with LF
22+
# Security
23+
- id: detect-aws-credentials # Checks for the existence of AWS secrets that you have set up with the AWS CLI.
24+
args: ['--allow-missing-credentials'] # Allow hook to pass when no credentials are detected.
25+
- id: detect-private-key # Checks for the existence of private keys.
26+
27+
- repo: https://github.com/zricethezav/gitleaks
28+
rev: v8.23.3
29+
hooks:
30+
- id: gitleaks
31+
32+
- repo: https://github.com/DavidAnson/markdownlint-cli2
33+
rev: v0.18.1
34+
hooks:
35+
- id: markdownlint-cli2

CONTRIBUTING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing guidelines
2+
3+
## Git workflow
4+
5+
- We use trunk based development - create a feature branch from `main`, e.g. `feature/new-feature`
6+
- Pull requests must contain a succinct, clear summary of what the user need is driving this document change
7+
- Ensure your branch contains logical atomic commits following our [commit standards](https://github.com/ONSdigital/dp-standards/blob/main/COMMIT_STANDARDS.md) before submitting a pull request
8+
- You may rebase your branch after feedback if it's to include relevant updates from the main branch. We prefer a rebase here to a merge commit as we prefer a clean and straight history on develop with discrete merge commits for changes
9+
10+
## Pre-commit
11+
12+
We encourage the use of [pre-commit](https://pre-commit.com/) locally, this reduces the amount of common mistakes and engineers can just focus on reviewing the actual changes.
13+
14+
```sh
15+
# Install pre-commit
16+
brew install pre-commit
17+
# This will enable pre-commit to run every time you git commit
18+
pre-commit install
19+
```
20+
21+
If you want to do an adhoc run of pre-commit
22+
23+
⚠️ This will only run on files that are staged in git
24+
25+
```sh
26+
pre-commit run --all-files
27+
```
28+
29+
If you want to commit and skip checks
30+
31+
```sh
32+
git commit --no-verify -m "some message"
33+
```
34+
35+
## Markdown linting
36+
37+
This respository uses [markdown linting](https://github.com/DavidAnson/markdownlint-cli2) for all PRs.
38+
39+
To install:
40+
41+
```sh
42+
brew install markdownlint-cli2
43+
```
44+
45+
To run:
46+
47+
```sh
48+
markdownlint-cli2 **/*.md
49+
```

0 commit comments

Comments
 (0)