Skip to content

Commit 5181b86

Browse files
Merge pull request #4 from arduino/check-markdown
Add CI workflow to check Markdown files for problems
2 parents 3705df5 + 079e799 commit 5181b86

File tree

11 files changed

+1613
-10
lines changed

11 files changed

+1613
-10
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md
2+
name: Check Markdown
3+
4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
8+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
9+
on:
10+
create:
11+
push:
12+
paths:
13+
- ".github/workflows/check-markdown-task.ya?ml"
14+
- ".markdown-link-check.json"
15+
- "package.json"
16+
- "package-lock.json"
17+
- "Taskfile.ya?ml"
18+
- "**/.markdownlint*"
19+
- "**.mdx?"
20+
- "**.mkdn"
21+
- "**.mdown"
22+
- "**.markdown"
23+
pull_request:
24+
paths:
25+
- ".github/workflows/check-markdown-task.ya?ml"
26+
- ".markdown-link-check.json"
27+
- "package.json"
28+
- "package-lock.json"
29+
- "Taskfile.ya?ml"
30+
- "**/.markdownlint*"
31+
- "**.mdx?"
32+
- "**.mkdn"
33+
- "**.mdown"
34+
- "**.markdown"
35+
schedule:
36+
# Run every Tuesday at 8 AM UTC to catch breakage caused by external changes.
37+
- cron: "0 8 * * TUE"
38+
workflow_dispatch:
39+
repository_dispatch:
40+
41+
jobs:
42+
run-determination:
43+
runs-on: ubuntu-latest
44+
outputs:
45+
result: ${{ steps.determination.outputs.result }}
46+
steps:
47+
- name: Determine if the rest of the workflow should run
48+
id: determination
49+
run: |
50+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
51+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
52+
if [[
53+
"${{ github.event_name }}" != "create" ||
54+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
55+
]]; then
56+
# Run the other jobs.
57+
RESULT="true"
58+
else
59+
# There is no need to run the other jobs.
60+
RESULT="false"
61+
fi
62+
63+
echo "::set-output name=result::$RESULT"
64+
65+
lint:
66+
needs: run-determination
67+
if: needs.run-determination.outputs.result == 'true'
68+
runs-on: ubuntu-latest
69+
70+
steps:
71+
- name: Checkout repository
72+
uses: actions/checkout@v3
73+
74+
- name: Setup Node.js
75+
uses: actions/setup-node@v3
76+
with:
77+
node-version: ${{ env.NODE_VERSION }}
78+
79+
- name: Initialize markdownlint-cli problem matcher
80+
uses: xt0rted/markdownlint-problem-matcher@v1
81+
82+
- name: Install Task
83+
uses: arduino/setup-task@v1
84+
with:
85+
repo-token: ${{ secrets.GITHUB_TOKEN }}
86+
version: 3.x
87+
88+
- name: Lint
89+
run: task markdown:lint
90+
91+
links:
92+
needs: run-determination
93+
if: needs.run-determination.outputs.result == 'true'
94+
runs-on: ubuntu-latest
95+
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@v3
99+
100+
- name: Setup Node.js
101+
uses: actions/setup-node@v3
102+
with:
103+
node-version: ${{ env.NODE_VERSION }}
104+
105+
- name: Install Task
106+
uses: arduino/setup-task@v1
107+
with:
108+
repo-token: ${{ secrets.GITHUB_TOKEN }}
109+
version: 3.x
110+
111+
- name: Check links
112+
run: task --silent markdown:check-links

.gitignore

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

.markdown-link-check.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"httpHeaders": [
3+
{
4+
"urls": ["https://docs.github.com/"],
5+
"headers": {
6+
"Accept-Encoding": "gzip, deflate, br"
7+
}
8+
}
9+
],
10+
"retryOn429": true,
11+
"retryCount": 3,
12+
"aliveStatusCodes": [200, 206]
13+
}

.markdownlint.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown/.markdownlint.yml
2+
# See: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
3+
# The code style defined in this file is the official standardized style to be used in all Arduino projects and should
4+
# not be modified.
5+
# Note: Rules disabled solely because they are redundant to Prettier are marked with a "Prettier" comment.
6+
7+
default: false
8+
MD001: false
9+
MD002: false
10+
MD003: false # Prettier
11+
MD004: false # Prettier
12+
MD005: false # Prettier
13+
MD006: false # Prettier
14+
MD007: false # Prettier
15+
MD008: false # Prettier
16+
MD009:
17+
br_spaces: 0
18+
strict: true
19+
list_item_empty_lines: false # Prettier
20+
MD010: false # Prettier
21+
MD011: true
22+
MD012: false # Prettier
23+
MD013: false
24+
MD014: false
25+
MD018: true
26+
MD019: false # Prettier
27+
MD020: true
28+
MD021: false # Prettier
29+
MD022: false # Prettier
30+
MD023: false # Prettier
31+
MD024: false
32+
MD025:
33+
level: 1
34+
front_matter_title: '^\s*"?title"?\s*[:=]'
35+
MD026: false
36+
MD027: false # Prettier
37+
MD028: false
38+
MD029:
39+
style: one
40+
MD030:
41+
ul_single: 1
42+
ol_single: 1
43+
ul_multi: 1
44+
ol_multi: 1
45+
MD031: false # Prettier
46+
MD032: false # Prettier
47+
MD033: false
48+
MD034: false
49+
MD035: false # Prettier
50+
MD036: false
51+
MD037: true
52+
MD038: true
53+
MD039: true
54+
MD040: false
55+
MD041: false
56+
MD042: true
57+
MD043: false
58+
MD044: false
59+
MD045: true
60+
MD046:
61+
style: fenced
62+
MD047: false # Prettier

.markdownlintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown/.markdownlintignore
2+
.licenses/
3+
__pycache__/
4+
node_modules/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Docker crossbuild
22

33
[![Sync Labels status](https://github.com/arduino/crossbuild/actions/workflows/sync-labels.yml/badge.svg)](https://github.com/arduino/crossbuild/actions/workflows/sync-labels.yml)
4+
[![Check Markdown status](https://github.com/arduino/crossbuild/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/crossbuild/actions/workflows/check-markdown-task.yml)
45

56
This docker container has been created to allow us to easily crosscompile our c++ tools. The idea comes from [multiarch/crossbuild](https://github.com/multiarch/crossbuild), but that container unfortunately is outdated and the apt sources are no longer available.
67

Taskfile.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# See: https://taskfile.dev/#/usage
2+
version: "3"
3+
4+
tasks:
5+
docs:generate:
6+
desc: Create all generated documentation content
7+
8+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
9+
markdown:check-links:
10+
desc: Check for broken links
11+
deps:
12+
- task: docs:generate
13+
- task: npm:install-deps
14+
cmds:
15+
- |
16+
if [[ "{{.OS}}" == "Windows_NT" ]]; then
17+
# npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows,
18+
# so the Windows user is required to have markdown-link-check installed and in PATH.
19+
if ! which markdown-link-check &>/dev/null; then
20+
echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme"
21+
exit 1
22+
fi
23+
# Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero
24+
# exit status, but it's better to check all links before exiting.
25+
set +o errexit
26+
STATUS=0
27+
# Using -regex instead of -name to avoid Task's behavior of globbing even when quoted on Windows
28+
# The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives
29+
# \ characters special treatment on Windows in an attempt to support them as path separators.
30+
for file in $(
31+
find . \
32+
-type d -name '.git' -prune -o \
33+
-type d -name '.licenses' -prune -o \
34+
-type d -name '__pycache__' -prune -o \
35+
-type d -name 'node_modules' -prune -o \
36+
-regex ".*[.]md" -print
37+
); do
38+
markdown-link-check \
39+
--quiet \
40+
--config "./.markdown-link-check.json" \
41+
"$file"
42+
STATUS=$(( $STATUS + $? ))
43+
done
44+
exit $STATUS
45+
else
46+
npx --package=markdown-link-check --call='
47+
STATUS=0
48+
for file in $(
49+
find . \
50+
-type d -name '.git' -prune -o \
51+
-type d -name '.licenses' -prune -o \
52+
-type d -name '__pycache__' -prune -o \
53+
-type d -name 'node_modules' -prune -o \
54+
-regex ".*[.]md" -print
55+
); do
56+
markdown-link-check \
57+
--quiet \
58+
--config "./.markdown-link-check.json" \
59+
"$file"
60+
STATUS=$(( $STATUS + $? ))
61+
done
62+
exit $STATUS
63+
'
64+
fi
65+
66+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
67+
markdown:fix:
68+
desc: Automatically correct linting violations in Markdown files where possible
69+
deps:
70+
- task: npm:install-deps
71+
cmds:
72+
- npx markdownlint-cli --fix "**/*.md"
73+
74+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-markdown-task/Taskfile.yml
75+
markdown:lint:
76+
desc: Check for problems in Markdown files
77+
deps:
78+
- task: npm:install-deps
79+
cmds:
80+
- npx markdownlint-cli "**/*.md"
81+
82+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
83+
npm:install-deps:
84+
desc: Install dependencies managed by npm
85+
cmds:
86+
- npm install

deps/eudev-3.2.10/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ Contact: You can email us as a group below.
1616
IRC: Freenode/#gentoo-udev
1717

1818
Committers (alphabetical order by last name):
19-
19+
```
2020
Luca Barbato (lu_zero) <[email protected]>
2121
Anthony G. Basile (blueness) <[email protected]>
2222
Francisco Izquierdo (klondike) <[email protected]>
2323
Ian Stakenvicius (axs) <[email protected]>
2424
Matthew Thode (prometheanfire) <[email protected]>
2525
Tony Vroon (chainsaw) <[email protected]>
2626
Richard Yao (ryao) <[email protected]>
27-
27+
```
2828
## Build status
2929
[![Build Status](https://travis-ci.org/gentoo/eudev.svg?branch=master)](https://travis-ci.org/gentoo/eudev)

deps/hidapi-0.12.0/BUILD.cmake.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ To build HIDAPI with CMake, it has to be [installed](#installing-cmake)/availabl
55
Make sure you've checked [prerequisites](BUILD.md#prerequisites) and installed all required dependencies.
66

77
HIDAPI CMake build system allows you to build HIDAPI in two generally different ways:
8-
1) As a [standalone package/library](#standalone-package-build);
9-
2) As [part of a larger CMake project](#hidapi-as-a-subdirectory).
8+
1. As a [standalone package/library](#standalone-package-build);
9+
1. As [part of a larger CMake project](#hidapi-as-a-subdirectory).
1010

1111
**TL;DR**: if you're experienced developer and have been working with CMake projects or have been written some of your own -
1212
most of this document may not be of interest for you; just check variables names, its default values and the target names.
@@ -107,11 +107,11 @@ _NOTE_: HIDAPI packages built by CMake can be used with `pkg-config`, as if buil
107107
It is possible to build a CMake project (including HIDAPI) using MSVC compiler and Ninja (for medium and larger projects it is so much faster than msbuild).
108108

109109
For that:
110-
1) Open cmd.exe;
111-
2) Setup MSVC build environment variables, e.g.: `vcvarsall.bat x64`, where:
110+
1. Open cmd.exe;
111+
1. Setup MSVC build environment variables, e.g.: `vcvarsall.bat x64`, where:
112112
- `vcvarsall.bat` is an environment setup script of your MSVC toolchain installation;<br>For MSVC 2019 Community edition it is located at: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\`;
113113
- `x64` -a target architecture to build;
114-
3) Follow general build steps, and use `Ninja` as a generator.
114+
1. Follow general build steps, and use `Ninja` as a generator.
115115

116116
### Using HIDAPI in a CMake project
117117

@@ -187,15 +187,15 @@ add_subdirectory(hidapi)
187187

188188
There are several important differences in the behavior of HIDAPI CMake build system when CMake is built as standalone package vs subdirectory build:
189189

190-
1) In _standalone build_ a number of standard and HIDAPI-specific variables are marked as _cache variables_ or _options_.
190+
1. In _standalone build_ a number of standard and HIDAPI-specific variables are marked as _cache variables_ or _options_.
191191
This is done for convenience: when you're building HIDAPI as a standalone package and using tools like `cmake-gui` - those are highlighted as variables that can be changed and has some short description/documentation. E.g.:
192192
![an example of highlighted variables in cmake-gui](documentation/cmake-gui-highlights.png "cmake-gui highlighted variables")<br>
193193
E.g.2:<br>
194194
![an example of drop-down menu in cmake-gui](documentation/cmake-gui-drop-down.png "cmake-gui drop-down menu")<br>
195195
When HIDAPI is built as a _subdirectory_ - **_none of the variables are marked for cache or as options_** by HIDAPI.
196196
This is done to let the host project's developer decide what is important (what needs to be highlighted) and what's not.
197197

198-
2) The default behavior/default value for some of the variables is a bit different:
198+
1. The default behavior/default value for some of the variables is a bit different:
199199
- by default, none of HIDAPI targets are [installed](https://cmake.org/cmake/help/latest/command/install.html); if required, HIDAPI targets can be installed by host project _after_ including HIDAPI subdirectory (requires CMake 3.13 or later); **or**, the default installation can be enabled by setting `HIDAPI_INSTALL_TARGETS` variable _before_ including HIDAPI subdirectory.
200200
HIDAPI uses [GNUInstallDirs](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html) to specify install locations. Variables like `CMAKE_INSTALL_LIBDIR` can be used to control HIDAPI's installation locations. E.g.:
201201
```cmake
@@ -207,7 +207,7 @@ This is done to let the host project's developer decide what is important (what
207207
```
208208
- HIDAPI prints its version during the configuration when built as a standalone package; to enable this for subdirectory builds - set `HIDAPI_PRINT_VERSION` to TRUE before including HIDAPI;
209209

210-
3) In a subdirectory build, HIDAPI _doesn't modify or set any of the CMake variables_ that may change the build behavior.
210+
1. In a subdirectory build, HIDAPI _doesn't modify or set any of the CMake variables_ that may change the build behavior.
211211
For instance, in a _standalone build_, if CMAKE_BUILD_TYPE or BUILD_SHARED_LIBS variables are not set, those are defaulted to "Release" and "TRUE" explicitly.
212212
In a _subdirectory build_, even if not set, those variables remain unchanged, so a host project's developer has a full control over the HIDAPI build configuration.
213213

0 commit comments

Comments
 (0)