Skip to content

Commit

Permalink
Fix false negatives in markdown URL checks in C/CD
Browse files Browse the repository at this point in the history
This commit improves CI/CD workflows reliability by configuring URL
validation to avoid false positives.

The separate config files makes URL validation rules more maintainable
and easier to update. Allowlisting specific domains prevents workflow
disruptions.

Key changes:

- Move URL validation config to dedicated file for better
  maintainability
- Add allowlist for known valid domains triggering false negatives
- Update GitHub docs URL to prevent link failures
  • Loading branch information
undergroundwires committed Jan 26, 2025
1 parent e11821f commit ba9feb2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- npm run lint:md:relative-urls
- npm run lint:md:external-urls
os: [ macos, ubuntu, windows ]
fail-fast: false # Still interested to see results from other combinations
fail-fast: false # Still interested to see results from other commands
steps:
-
name: Checkout
Expand Down
20 changes: 20 additions & 0 deletions .remark-lint-no-dead-urls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import remarkLintNoDeadUrls from 'remark-lint-no-dead-urls';

/** @type {import('remark-lint-no-dead-urls').Options} */
const Options = {
skipUrlPatterns: [
// These result in false negatives
'archive.ph',
'scoop.sh',
].map(buildUrlPattern),
};

/** @type {Omit<import('unified-engine').Preset} */
export default {
plugins: [[remarkLintNoDeadUrls, Options]],
};

function buildUrlPattern(fqdn) {
const escaped = fqdn.replace(/\./g, '\\.');
return `^https://${escaped}/.*$`;
}
2 changes: 1 addition & 1 deletion docs/ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Convention for naming pipeline files: **`<type>.<name>.yaml`**.
- Kebab-case allows to have better URL references to them.
- [README.md](./../README.md) uses URL references to show status badges for actions.

[1]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#about-yaml-syntax-for-workflows
[1]: https://web.archive.org/web/20250126141528/https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#about-yaml-syntax-for-workflows "Workflow syntax for GitHub Actions - GitHub Docs | docs.github.com"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"lint:md": "markdownlint **/*.md --ignore node_modules",
"lint:md:consistency": "remark . --frail --use remark-preset-lint-consistent",
"lint:md:relative-urls": "remark . --frail --use remark-validate-links",
"lint:md:external-urls": "remark . --frail --use remark-lint-no-dead-urls",
"lint:md:external-urls": "remark . --frail --rc-path .remark-lint-no-dead-urls.js",
"lint:yaml": "yamllint **/*.yaml --ignore=node_modules/**/*.yaml",
"lint:pylint": "pylint **/*.py",
"postinstall": "electron-builder install-app-deps",
Expand Down

0 comments on commit ba9feb2

Please sign in to comment.