Add documentation links checking to CI (#9244)

This commit is contained in:
Álvaro Mondéjar 2023-08-10 09:25:53 -06:00 committed by GitHub
parent ca71dcbbc4
commit e7ee69ebe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 37 deletions

View File

@ -44,6 +44,21 @@ jobs:
run: npm i
- name: Run linter
run: npm run lint
- name: Detect changed documentation files
uses: dorny/paths-filter@v2
id: changes
with:
list-files: shell
filters: |
docs:
- '*.md'
- '.github/**.md'
- name: Check documentation links
if: steps.changes.outputs.docs == 'true'
run: |
npx markdown-link-check --retry \
${{ steps.changes.outputs.docs_files }}
continue-on-error: ${{ github.ref == 'refs/heads/develop' }}
- name: Verify file permissions
run: |
CHECK_DIRS="icons/ _data/"

View File

@ -157,7 +157,7 @@ echo file_get_contents('path/to/package/icons/simpleicons.svg');
| [Drawio library](https://github.com/mondeja/simple-icons-drawio) <img src="https://cdn.simpleicons.org/diagramsdotnet/000/fff" alt="Drawio" align=left width=24 height=24> | [@mondeja](https://github.com/mondeja) |
| [Drupal module](https://www.drupal.org/project/simple_icons) <img src="https://cdn.simpleicons.org/drupal/000/fff" alt="Drupal" align=left width=24 height=24> | [Phil Wolstenholme](https://www.drupal.org/u/phil-wolstenholme) |
| [Figma plugin](https://www.figma.com/community/plugin/1149614463603005908/Simple-Icons) <img src="https://cdn.simpleicons.org/figma/000/fff" alt="Figma" align=left width=24 height=24> | [@LitoMore](https://github.com/LitoMore) |
| [Flutter package](https://pub.dev/packages/simple_icons) <img src="https://cdn.simpleicons.org/flutter/000/fff" alt="Flutter" align=left width=24 height=24> | [@jlnrrg](https://jlnrrg.github.io/) |
| [Flutter package](https://pub.dev/packages/simple_icons) <img src="https://cdn.simpleicons.org/flutter/000/fff" alt="Flutter" align=left width=24 height=24> | [@jlnrrg](https://github.com/jlnrrg) |
| [Framer component](https://github.com/LitoMore/simple-icons-framer) <img src="https://cdn.simpleicons.org/framer/000/fff" alt="Framer" align=left width=24 height=24> | [@LitoMore](https://github.com/LitoMore) |
| [Hexo plugin](https://github.com/nidbCN/hexo-simpleIcons) <img src="https://cdn.simpleicons.org/hexo/000/fff" alt="Hexo" align=left width=24 height=24> | [@nidbCN](https://github.com/nidbCN/) |
| [Home Assistant plugin](https://github.com/vigonotion/hass-simpleicons) <img src="https://cdn.simpleicons.org/homeassistant/000/fff" alt="Home Assistant" align=left width=24 height=24> | [@vigonotion](https://github.com/vigonotion/) |

View File

@ -69,6 +69,7 @@
"husky": "8.0.3",
"is-ci": "3.0.1",
"jsonschema": "1.4.1",
"markdown-link-check": "3.11.2",
"mocha": "10.2.0",
"named-html-entities-json": "1.0.0",
"npm-run-all": "4.1.5",

View File

@ -1,19 +1,6 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import { test } from 'mocha';
import { strict as assert } from 'node:assert';
import {
getThirdPartyExtensions,
getDirnameFromImportMeta,
URL_REGEX,
} from '../sdk.mjs';
const __dirname = getDirnameFromImportMeta(import.meta.url);
const root = path.dirname(__dirname);
const getLinksRegex = new RegExp(
URL_REGEX.source.replace('^https', 'https?'),
'gm',
);
import { getThirdPartyExtensions } from '../sdk.mjs';
test('README third party extensions must be alphabetically sorted', async () => {
const thirdPartyExtensions = await getThirdPartyExtensions();
@ -30,25 +17,3 @@ test('README third party extensions must be alphabetically sorted', async () =>
'Wrong alphabetical order of third party extensions in README.',
);
});
test('Only allow HTTPS links in documentation pages', async () => {
const ignoreHttpLinks = ['http://www.w3.org/2000/svg'];
const docsFiles = (await fs.readdir(root)).filter((fname) =>
fname.endsWith('.md'),
);
for (const docsFile of docsFiles) {
const docsFilePath = path.join(root, docsFile);
const docsFileContent = await fs.readFile(docsFilePath, 'utf8');
for (const match of docsFileContent.matchAll(getLinksRegex)) {
const link = match[0];
assert.ok(
ignoreHttpLinks.includes(link) || link.startsWith('https://'),
`Link '${link}' in '${docsFile}' (at index ${match.index})` +
` must use the HTTPS protocol.`,
);
}
}
});