From 228fb991949d32e0feed78e487be177ef35d2164 Mon Sep 17 00:00:00 2001 From: Rachael Sewell Date: Tue, 6 Jun 2023 17:14:59 -0700 Subject: [PATCH 1/2] add markdownlint custom rule unit test (#37628) --- .../lib/default-markdownlint-options.js | 13 +++++++++++++ .../tests/unit/image-alt-text-length.js | 19 +++++++++++++++++++ .../tests/unit/image-alt-text-length.md | 7 +++++++ 3 files changed, 39 insertions(+) create mode 100644 src/content-linter/lib/default-markdownlint-options.js create mode 100644 src/content-linter/tests/unit/image-alt-text-length.js create mode 100644 src/content-linter/tests/unit/image-alt-text-length.md diff --git a/src/content-linter/lib/default-markdownlint-options.js b/src/content-linter/lib/default-markdownlint-options.js new file mode 100644 index 0000000000..45970a0f28 --- /dev/null +++ b/src/content-linter/lib/default-markdownlint-options.js @@ -0,0 +1,13 @@ +export function testOptions(rule, module, fixtureFile) { + const config = { + default: false, + [rule]: true, + } + + const options = { + files: [fixtureFile], + customRules: [module], + config, + } + return options +} diff --git a/src/content-linter/tests/unit/image-alt-text-length.js b/src/content-linter/tests/unit/image-alt-text-length.js new file mode 100644 index 0000000000..2357a62a04 --- /dev/null +++ b/src/content-linter/tests/unit/image-alt-text-length.js @@ -0,0 +1,19 @@ +import { jest } from '@jest/globals' +import markdownlint from 'markdownlint' + +import { incorrectAltTextLength } from '../../lib/linting-rules/image-alt-text-length.js' +import { testOptions } from '../../lib/default-markdownlint-options.js' +const fixtureFile = 'src/content-linter/tests/unit/image-alt-text-length.md' + +describe('image alt text length rule', () => { + jest.setTimeout(60 * 1000) + const options = testOptions('MD111', incorrectAltTextLength, fixtureFile) + + const result = markdownlint.sync(options) + test('image with correct length alt text', () => { + const errors = result[fixtureFile] + expect(Object.keys(result).length).toBe(1) + expect(errors.length).toBe(2) + expect(errors.map((error) => error.lineNumber)).toEqual([1, 7]) + }) +}) diff --git a/src/content-linter/tests/unit/image-alt-text-length.md b/src/content-linter/tests/unit/image-alt-text-length.md new file mode 100644 index 0000000000..2fef08d245 --- /dev/null +++ b/src/content-linter/tests/unit/image-alt-text-length.md @@ -0,0 +1,7 @@ +![012345678901234567890123456789012345678](./image.png) + +![0123456789012345678901234567890123456789](./image.png) + +![012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789](./image.png) + +![0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891](./image.png) From 38e5e4ed8f8cf0bd5ea81c2abeea7d6874af4fc0 Mon Sep 17 00:00:00 2001 From: Dan Rigby <114417+DanRigby@users.noreply.github.com> Date: Tue, 6 Jun 2023 20:29:40 -0400 Subject: [PATCH 2/2] Add note on `/refs/` usage. (#37389) Co-authored-by: Siara <108543037+SiaraMist@users.noreply.github.com> --- data/reusables/actions/reusable-workflow-calling-syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/reusables/actions/reusable-workflow-calling-syntax.md b/data/reusables/actions/reusable-workflow-calling-syntax.md index 436bdccba0..3fcebb36e9 100644 --- a/data/reusables/actions/reusable-workflow-calling-syntax.md +++ b/data/reusables/actions/reusable-workflow-calling-syntax.md @@ -1,4 +1,4 @@ * `{owner}/{repo}/.github/workflows/{filename}@{ref}`{% ifversion fpt or ghec or ghes > 3.4 or ghae > 3.4 %} for reusable workflows in {% ifversion fpt %}public and private{% elsif ghec or ghes > 3.7 or ghae > 3.7 %}public, internal and private{% else %}public and internal{% endif %} repositories. * `./.github/workflows/{filename}` for reusable workflows in the same repository.{% endif %} -`{ref}` can be a SHA, a release tag, or a branch name. Using the commit SHA is the safest for stability and security. For more information, see "[AUTOTITLE](/actions/security-guides/security-hardening-for-github-actions#reusing-third-party-workflows)." {% ifversion fpt or ghec or ghes > 3.4 or ghae > 3.4 %}If you use the second syntax option (without `{owner}/{repo}` and `@{ref}`) the called workflow is from the same commit as the caller workflow.{% endif %} +`{ref}` can be a SHA, a release tag, or a branch name. Using the commit SHA is the safest for stability and security. For more information, see "[AUTOTITLE](/actions/security-guides/security-hardening-for-github-actions#reusing-third-party-workflows)."{% ifversion fpt or ghec or ghes > 3.4 or ghae > 3.4 %} If you use the second syntax option (without `{owner}/{repo}` and `@{ref}`) the called workflow is from the same commit as the caller workflow.{% endif %} Ref prefixes such as `refs/heads` and `refs/tags` are not allowed.