-
Notifications
You must be signed in to change notification settings - Fork 0
/
Earthfile
88 lines (69 loc) · 3.01 KB
/
Earthfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
VERSION 0.8
# cspell: words markdownlint
MDLINT_LOCALLY:
# DO NOT RUN THIS FUNCTION INSIDE CONTAINER BUILDS.
# IT IS NOT FOR CONTAINER BUILDS.
# See: https://github.com/earthly/earthly/issues/580
# Linting is done with MarkdownLint CLI2
# See: https://github.com/DavidAnson/markdownlint-cli2
# We use a special container which includes all rule extensions to markdownlint
# Notably, we rely on the `max-one-sentence-per-line` rule which helps keep
# diffs of markdown files small and legible. This rule is only currently
# in the `next` branch of `markdownlint`.
# Container is built by:
# https://github.com/DavidAnson/markdownlint-cli2/blob/next/docker/Dockerfile-rules
FUNCTION
# Directory we need to run lint checks against.
ARG --required src
# Optional `fix` argument. Must be either not set, or set to `--fix` anything else is an error.
ARG fix
# Unlikely this ever needs to be changed.
ARG cfg_file=.markdownlint-cli2.jsonc
# Status line for what we are about to do.
RUN echo Linting Markdown Recursively from: $src
# Run the linter with the given arguments, and recursively check all markdown files.
# The directory to be checked `MUST` have a `.markdownlint-sli2.jsonc` file.
# cspell: words davidanson
RUN docker run \
--rm \
-v $src:/workdir \
davidanson/markdownlint-cli2-rules:v0.11.0 \
"**/*.md" \
--config $cfg_file \
$fix
# Markdown check used in standard CI target check.
CHECK:
# DO NOT RUN THIS FUNCTION INSIDE CONTAINER BUILDS.
# IT IS NOT FOR CONTAINER BUILDS.
# See: https://github.com/earthly/earthly/issues/580
# Linting is done with MarkdownLint CLI2
# See: https://github.com/DavidAnson/markdownlint-cli2
# We use a special container which includes all rule extensions to markdownlint
# Notably, we rely on the `max-one-sentence-per-line` rule which helps keep
# diffs of markdown files small and legible. This rule is only currently
# in the `next` branch of `markdownlint`.
# Container is built by:
# https://github.com/DavidAnson/markdownlint-cli2/blob/next/docker/Dockerfile-rules
FUNCTION
ARG src = .
# Unlikely this ever needs to be changed.
ARG cfg_file=.markdownlint-cli2.jsonc
FROM davidanson/markdownlint-cli2-rules:v0.11.0
# Status line for what we are about to do.
RUN echo Linting Markdown Recursively from: $src
# Run the linter with the given arguments, and recursively check all markdown files.
# The directory to be checked `MUST` have a `.markdownlint-sli2.jsonc` file.
# cspell: words davidanson
WORKDIR /work
COPY $src .
RUN markdownlint-cli2 \
"**/*.md" \
--config $cfg_file
# A Test and example invocation of the above FUNCTION.
mdlint-test:
# Test Markdown lint checks.
# Run with `earthly -P +mdlint-test
# Must be run LOCALLY as described above.
LOCALLY
ARG src=$(echo ${PWD}/../../)
RUN +MDLINT_LOCALLY --src=${src}