From 95f325ae38b65dc2269e0fff204b8491a79af4df Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 16:08:48 -0400 Subject: [PATCH 01/15] update README now that we use ifversion everywhere --- data/features/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/features/README.md b/data/features/README.md index 717a06510b..1253b84f45 100644 --- a/data/features/README.md +++ b/data/features/README.md @@ -21,7 +21,7 @@ The format and allowed values are the same as the [frontmatter versions property ### Liquid conditionals -Now you can use `{% if meow %} ... {% endif %}` in content files! Note this is the `if` tag, not the new `ifversion` tag. +Now you can use `{% ifversion meow %} ... {% endif %}` in content files! ### Frontmatter @@ -45,7 +45,7 @@ versions: ## Schema enforcement -The schema for validating the feature versioning lives in [`tests/helpers/schemas/feature-versions-schema.js`](/tests/helpers/schemas/feature-versions-schema.js) and is exercised by [`tests/linting/lint-files.js`](/tests/linting/lint-files.js). +The schema for validating the feature versioning lives in [`tests/helpers/schemas/feature-versions-schema.js`](/tests/helpers/schemas/feature-versions-schema.js) and is exercised by [`tests/linting/lint-versioning.js`](/tests/linting/lint-versioning.js). ## Script to remove feature tags From 959b4f8f12b9afe91900afdf27e6563313045649 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 16:11:00 -0400 Subject: [PATCH 02/15] add allowed patterns to all-versions --- lib/all-versions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/all-versions.js b/lib/all-versions.js index 0284fd5cfb..4f9ee836c0 100644 --- a/lib/all-versions.js +++ b/lib/all-versions.js @@ -16,6 +16,7 @@ const plans = [ releases: [latestNonNumberedRelease], latestRelease: latestNonNumberedRelease, nonEnterpriseDefault: true, // permanent way to refer to this plan if the name changes + hasNumberedReleases: false, openApiBaseName: 'api.github.com', // used for REST miscBaseName: 'dotcom', // used for GraphQL and webhooks }, @@ -25,6 +26,7 @@ const plans = [ shortName: 'ghec', releases: [latestNonNumberedRelease], latestRelease: latestNonNumberedRelease, + hasNumberedReleases: false, openApiBaseName: 'api.github.com', miscBaseName: 'ghec', }, @@ -44,8 +46,11 @@ const plans = [ shortName: 'ghae', releases: [latestNonNumberedRelease], latestRelease: latestNonNumberedRelease, + hasNumberedReleases: false, openApiBaseName: 'github.ae', miscBaseName: 'ghae', + allowedFrontmatterPattern: /^issue-\d+?(-and-\d+?)?|next$/, + allowedInlinePattern: /^ghae-(issue-\d+?(-and-\d+?)?|next)$/, }, ] From 37242bca7d1834e2e347eb2ae2b832d8bb1aed1d Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 16:13:14 -0400 Subject: [PATCH 03/15] this is where we do the validation --- lib/frontmatter.js | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/lib/frontmatter.js b/lib/frontmatter.js index fdf7d3d8a9..7b17312ec9 100644 --- a/lib/frontmatter.js +++ b/lib/frontmatter.js @@ -14,13 +14,6 @@ const layoutNames = [ 'release-notes', false, ] -const semverValidRange = semver.validRange -const semverRange = { - type: 'string', - conform: semverValidRange, - message: 'Must be a valid SemVer range', -} -const versionObjs = Object.values(allVersions) const guideTypes = ['overview', 'quick_start', 'tutorial', 'how_to', 'reference'] const featureVersions = fs @@ -246,19 +239,46 @@ const featureVersionsProp = { }, } +const asteriskPattern = /^\*$/ + schema.properties.versions = { type: ['object', 'string'], // allow a '*' string to indicate all versions required: true, - properties: versionObjs.reduce((acc, versionObj) => { - acc[versionObj.plan] = semverRange - acc[versionObj.shortName] = semverRange + additionalProperties: false, // don't allow any versions in FM that aren't defined in lib/all-versions + properties: Object.values(allVersions).reduce((acc, versionObj) => { + acc[versionObj.plan] = getValidProps(versionObj) + acc[versionObj.shortName] = getValidProps(versionObj) return acc }, featureVersionsProp), } -// Support 'github-ae': next -schema.properties.versions.properties['github-ae'] = 'next' -schema.properties.versions.properties.ghae = 'next' +function getValidProps(versionObj) { + const valid = { type: 'string' } + + // The properties attached to versionObj are defined in lib/all-versions.js. + + // If a version has no numbered releases or exception pattern, the only valid value is '*'. + if (!(versionObj.hasNumberedReleases || versionObj.allowedFrontmatterPattern)) { + valid.pattern = asteriskPattern + valid.message = `Must have a value of '*'` + } + + // If a version has an exception pattern, both '*' and the exception pattern are valid. + if (versionObj.allowedFrontmatterPattern) { + valid.pattern = new RegExp( + `${asteriskPattern.source}|${versionObj.allowedFrontmatterPattern.source}` + ) + valid.message = `Must have a value of '*' or ${versionObj.allowedFrontmatterPattern}` + } + + // If a version has numbered releases, any semver range is valid. Note '*' is a valid semver range. + if (versionObj.hasNumberedReleases) { + valid.conform = semver.validRange + valid.message = 'Must be a valid SemVer range' + } + + return valid +} function frontmatter(markdown, opts = {}) { const defaults = { From 2a03cad6dc45aaaeca6fa528ba4224760cd3d19a Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 16:13:38 -0400 Subject: [PATCH 04/15] remove redundant test --- tests/linting/lint-files.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/linting/lint-files.js b/tests/linting/lint-files.js index 4edc27fc67..7e735c132c 100644 --- a/tests/linting/lint-files.js +++ b/tests/linting/lint-files.js @@ -410,15 +410,13 @@ describe('lint markdown content', () => { isEarlyAccess, isSitePolicy, hasExperimentalAlternative, - frontmatterErrors, frontmatterData beforeAll(async () => { const fileContents = await fs.readFile(markdownAbsPath, 'utf8') - const { data, content: bodyContent, errors } = frontmatter(fileContents) + const { data, content: bodyContent } = frontmatter(fileContents) content = bodyContent - frontmatterErrors = errors frontmatterData = data ast = fromMarkdown(content) isHidden = data.hidden === true @@ -611,13 +609,6 @@ describe('lint markdown content', () => { }) if (!markdownRelPath.includes('data/reusables')) { - test('contains valid frontmatter', () => { - const errorMessage = frontmatterErrors - .map((error) => `- [${error.property}]: ${error.actual}, ${error.message}`) - .join('\n') - expect(frontmatterErrors.length, errorMessage).toBe(0) - }) - test('frontmatter contains valid liquid', async () => { const fmKeysWithLiquid = ['title', 'shortTitle', 'intro', 'product', 'permission'].filter( (key) => Boolean(frontmatterData[key]) From 092de5186ee8e81c707cb103733b3ac229e0c11e Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 16:14:03 -0400 Subject: [PATCH 05/15] improve the validation --- tests/linting/lint-versioning.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/linting/lint-versioning.js b/tests/linting/lint-versioning.js index d1b04d7ffb..898c5a9fc4 100644 --- a/tests/linting/lint-versioning.js +++ b/tests/linting/lint-versioning.js @@ -2,7 +2,7 @@ import { jest } from '@jest/globals' import fs from 'fs/promises' import revalidator from 'revalidator' import semver from 'semver' -import { allVersions } from '../../lib/all-versions.js' +import { allVersions, allVersionShortnames } from '../../lib/all-versions.js' import { supported, next, nextNext, deprecated } from '../../lib/enterprise-server-releases.js' import { getLiquidConditionals } from '../../script/helpers/get-liquid-conditionals.js' import allowedVersionOperators from '../../lib/liquid-tags/ifversion-supported-operators.js' @@ -11,18 +11,20 @@ import walkFiles from '../../script/helpers/walk-files' import frontmatter from '../../lib/frontmatter.js' import loadSiteData from '../../lib/site-data.js' -const versionShortNames = Object.values(allVersions).map((v) => v.shortName) -const versionShortNameExceptions = ['ghae-next', 'ghae-issue-'] +/* + NOTE: This test suite does NOT validate the `versions` frontmatter in content files. + That's because lib/page.js validates frontmatter when loading all the pages (which happens + when running npm start or tests) and throws an error immediately if there are any issues. + This test suite DOES validate the data/features `versions` according to the same FM schema. + Some tests/unit/page.js tests also exercise the frontmatter validation. +*/ jest.useFakeTimers('legacy') const siteData = loadSiteData() const featureVersions = Object.entries(siteData.en.site.data.features) const featureVersionNames = featureVersions.map((fv) => fv[0]) - -const versionKeywords = versionShortNames - .concat(['currentVersion', 'enterpriseServerReleases']) - .concat(featureVersionNames) +const allowedVersionNames = Object.keys(allVersionShortnames).concat(featureVersionNames) // Make sure data/features/*.yml contains valid versioning. describe('lint feature versions', () => { @@ -79,7 +81,7 @@ describe('lint Liquid versioning', () => { // Now that `ifversion` supports feature-based versioning, we should have few other `if` tags. test('ifversion, not if, is used for versioning', async () => { const ifsForVersioning = ifConditionals.filter((cond) => - versionKeywords.some((keyword) => cond.includes(keyword)) + allowedVersionNames.some((keyword) => cond.includes(keyword)) ) const errorMessage = `Found ${ ifsForVersioning.length @@ -98,12 +100,16 @@ describe('lint Liquid versioning', () => { }) }) +// Return true if the shortname in the conditional is supported (fpt, ghec, ghes, ghae, all feature names). +// If not, see if the shortname matches any exception pattern defined in lib/all-versions.js. function validateVersion(version) { - return ( - versionShortNames.includes(version) || - versionShortNameExceptions.some((exception) => version.startsWith(exception)) || - featureVersionNames.includes(version) + const isSupported = allowedVersionNames.includes(version) + const isException = Object.values(allVersions).some( + (v) => v.allowedInlinePattern && v.allowedInlinePattern.test(version) ) + const isValid = isSupported || isException + + return isValid } function validateIfversionConditionals(conds) { From ebbc664578db23a73ef5aaf1267377266a4cc5d6 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 16:14:29 -0400 Subject: [PATCH 06/15] add a new test to validate versions FM in fixture --- tests/fixtures/page-with-invalid-product-version.md | 7 +++++++ tests/unit/page.js | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/fixtures/page-with-invalid-product-version.md diff --git a/tests/fixtures/page-with-invalid-product-version.md b/tests/fixtures/page-with-invalid-product-version.md new file mode 100644 index 0000000000..1d86c307fc --- /dev/null +++ b/tests/fixtures/page-with-invalid-product-version.md @@ -0,0 +1,7 @@ +--- +title: This is an article +intro: I am missing productVersions frontmatter +versions: + fpt: '*' + ghae: 'issue-foo' # Only issue- is allowed, per lib/all-versions.js +--- diff --git a/tests/unit/page.js b/tests/unit/page.js index 24dcc6d774..4fa5fd3ce7 100644 --- a/tests/unit/page.js +++ b/tests/unit/page.js @@ -794,6 +794,18 @@ describe('catches errors thrown in Page class', () => { await expect(getPage).rejects.toThrowError('versions') }) + test('invalid versions frontmatter', async () => { + async function getPage() { + return await Page.init({ + relativePath: 'page-with-invalid-product-version.md', + basePath: path.join(__dirname, '../fixtures'), + languageCode: 'en', + }) + } + + await expect(getPage).rejects.toThrowError('versions') + }) + test('English page with a version in frontmatter that its parent product is not available in', async () => { async function getPage() { return await Page.init({ From 79976e30000c0b1c58098814a784d15f54dd1685 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 16:15:03 -0400 Subject: [PATCH 07/15] fix issues raised by new validation --- .../organizing-information-with-collapsed-sections.md | 4 ++-- .../using-keywords-in-issues-and-pull-requests.md | 4 ++-- data/features/actions-inherit-secrets-reusable-workflows.yml | 1 - .../organizing-information-with-collapsed-sections.md | 4 ++-- .../using-keywords-in-issues-and-pull-requests.md | 4 ++-- .../organizing-information-with-collapsed-sections.md | 4 ++-- .../using-keywords-in-issues-and-pull-requests.md | 4 ++-- .../organizing-information-with-collapsed-sections.md | 4 ++-- .../using-keywords-in-issues-and-pull-requests.md | 4 ++-- .../organizing-information-with-collapsed-sections.md | 4 ++-- .../using-keywords-in-issues-and-pull-requests.md | 4 ++-- 11 files changed, 20 insertions(+), 21 deletions(-) diff --git a/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md b/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md index 1cccbccd66..05d74c1ce9 100644 --- a/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md +++ b/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections shortTitle: Collapsed sections --- ## Creating a collapsed section diff --git a/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md b/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md index a6ea7be3a1..514684c33f 100644 --- a/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md +++ b/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests topics: - Issues - Pull requests diff --git a/data/features/actions-inherit-secrets-reusable-workflows.yml b/data/features/actions-inherit-secrets-reusable-workflows.yml index 2b7e38e99c..f7fbe416d6 100644 --- a/data/features/actions-inherit-secrets-reusable-workflows.yml +++ b/data/features/actions-inherit-secrets-reusable-workflows.yml @@ -4,4 +4,3 @@ versions: fpt: '*' ghec: '*' ghes: '>= 3.6' - ghae: diff --git a/translations/es-ES/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md b/translations/es-ES/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md index 43e8019c53..ff1bd4187e 100644 --- a/translations/es-ES/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md +++ b/translations/es-ES/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections shortTitle: Secciones colapsadas --- diff --git a/translations/es-ES/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md b/translations/es-ES/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md index 4b52622590..af74450c58 100644 --- a/translations/es-ES/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md +++ b/translations/es-ES/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests topics: - Issues - Pull requests diff --git a/translations/ja-JP/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md b/translations/ja-JP/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md index e09621c96e..da34780b10 100644 --- a/translations/ja-JP/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md +++ b/translations/ja-JP/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections shortTitle: Collapsed sections --- diff --git a/translations/ja-JP/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md b/translations/ja-JP/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md index 095ed3c125..6446f4c74c 100644 --- a/translations/ja-JP/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md +++ b/translations/ja-JP/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests topics: - Issues - Pull requests diff --git a/translations/pt-BR/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md b/translations/pt-BR/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md index 901ed8d0c0..50c44bc523 100644 --- a/translations/pt-BR/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md +++ b/translations/pt-BR/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections shortTitle: Seções colapsadas --- diff --git a/translations/pt-BR/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md b/translations/pt-BR/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md index 73ea6cb9a8..b41b352dcd 100644 --- a/translations/pt-BR/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md +++ b/translations/pt-BR/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests topics: - Issues - Pull requests diff --git a/translations/zh-CN/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md b/translations/zh-CN/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md index efacfc140e..02a38edb8a 100644 --- a/translations/zh-CN/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md +++ b/translations/zh-CN/content/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections shortTitle: 折叠部分 --- diff --git a/translations/zh-CN/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md b/translations/zh-CN/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md index dd19fe4f50..ea3d5d0c8f 100644 --- a/translations/zh-CN/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md +++ b/translations/zh-CN/content/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests.md @@ -6,8 +6,8 @@ versions: ghes: '*' ghae: '*' ghec: '*' - redirect_from: - - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests +redirect_from: + - /github/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests topics: - Issues - Pull requests From f3bd3559411893ac56f6df55c0f8c880ca4840c3 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 16:43:00 -0400 Subject: [PATCH 08/15] fix test fixture --- tests/fixtures/page-with-invalid-product-version.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/page-with-invalid-product-version.md b/tests/fixtures/page-with-invalid-product-version.md index 1d86c307fc..18bbb3ca51 100644 --- a/tests/fixtures/page-with-invalid-product-version.md +++ b/tests/fixtures/page-with-invalid-product-version.md @@ -1,6 +1,6 @@ --- title: This is an article -intro: I am missing productVersions frontmatter +intro: I have invalid versions frontmatter versions: fpt: '*' ghae: 'issue-foo' # Only issue- is allowed, per lib/all-versions.js From 56c1531708e92a4674124fdb9c01eeab3e23f10c Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 18:38:50 -0400 Subject: [PATCH 09/15] make the pattern a string in all-versions so it can be serialized, and regex-ify it during implementation --- lib/all-versions.js | 4 ++-- lib/frontmatter.js | 4 +--- tests/linting/lint-versioning.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/all-versions.js b/lib/all-versions.js index 4f9ee836c0..2a5db4943b 100644 --- a/lib/all-versions.js +++ b/lib/all-versions.js @@ -49,8 +49,8 @@ const plans = [ hasNumberedReleases: false, openApiBaseName: 'github.ae', miscBaseName: 'ghae', - allowedFrontmatterPattern: /^issue-\d+?(-and-\d+?)?|next$/, - allowedInlinePattern: /^ghae-(issue-\d+?(-and-\d+?)?|next)$/, + allowedFrontmatterPattern: '^issue-\\d+?(-and-\\d+?)?|next$', + allowedInlinePattern: '^ghae-(issue-\\d+?(-and-\\d+?)?|next)$', }, ] diff --git a/lib/frontmatter.js b/lib/frontmatter.js index 7b17312ec9..3c749810b9 100644 --- a/lib/frontmatter.js +++ b/lib/frontmatter.js @@ -265,9 +265,7 @@ function getValidProps(versionObj) { // If a version has an exception pattern, both '*' and the exception pattern are valid. if (versionObj.allowedFrontmatterPattern) { - valid.pattern = new RegExp( - `${asteriskPattern.source}|${versionObj.allowedFrontmatterPattern.source}` - ) + valid.pattern = new RegExp(`${asteriskPattern.source}|${versionObj.allowedFrontmatterPattern}`) valid.message = `Must have a value of '*' or ${versionObj.allowedFrontmatterPattern}` } diff --git a/tests/linting/lint-versioning.js b/tests/linting/lint-versioning.js index 898c5a9fc4..33fcea6408 100644 --- a/tests/linting/lint-versioning.js +++ b/tests/linting/lint-versioning.js @@ -105,7 +105,7 @@ describe('lint Liquid versioning', () => { function validateVersion(version) { const isSupported = allowedVersionNames.includes(version) const isException = Object.values(allVersions).some( - (v) => v.allowedInlinePattern && v.allowedInlinePattern.test(version) + (v) => v.allowedInlinePattern && new RegExp(v.allowedInlinePattern).test(version) ) const isValid = isSupported || isException From 61123762d35a9988f84f5ce35298e9c5dd9f5e26 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Tue, 7 Jun 2022 18:48:20 -0400 Subject: [PATCH 10/15] add the two new props to the versions schema --- tests/helpers/schemas/versions-schema.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/helpers/schemas/versions-schema.js b/tests/helpers/schemas/versions-schema.js index b77dc3e331..c0bc2f9cd2 100644 --- a/tests/helpers/schemas/versions-schema.js +++ b/tests/helpers/schemas/versions-schema.js @@ -86,5 +86,14 @@ export default { description: 'final name used to map GraphQL and webhook schema names to the current version', type: 'string', }, + allowedFrontmatterPattern: { + desciption: 'pattern used in a regex to validate versions frontmatter in lib/frontmatter.js', + type: 'string', + }, + allowedInlinePattern: { + desciption: + 'pattern used in a regex to valid ifversion tag in tests/linting/lint-versioning.js', + type: 'string', + }, }, } From 18b8062d26e8bacf6379a123406f330607d047a4 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Wed, 8 Jun 2022 09:06:55 -0400 Subject: [PATCH 11/15] we no longer need ghae next handling --- lib/all-versions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/all-versions.js b/lib/all-versions.js index 2a5db4943b..b6c6ffbad2 100644 --- a/lib/all-versions.js +++ b/lib/all-versions.js @@ -49,8 +49,8 @@ const plans = [ hasNumberedReleases: false, openApiBaseName: 'github.ae', miscBaseName: 'ghae', - allowedFrontmatterPattern: '^issue-\\d+?(-and-\\d+?)?|next$', - allowedInlinePattern: '^ghae-(issue-\\d+?(-and-\\d+?)?|next)$', + allowedFrontmatterPattern: '^issue-\\d+?(-and-\\d+?)?$', + allowedInlinePattern: '^ghae-issue-\\d+?(-and-\\d+?)?$', }, ] From 3e80775d38a04ce2f6acfe34a183f48eefd0651f Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Wed, 8 Jun 2022 09:07:26 -0400 Subject: [PATCH 12/15] make the error message easier to understand --- lib/frontmatter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/frontmatter.js b/lib/frontmatter.js index 3c749810b9..6d51a066d6 100644 --- a/lib/frontmatter.js +++ b/lib/frontmatter.js @@ -266,7 +266,7 @@ function getValidProps(versionObj) { // If a version has an exception pattern, both '*' and the exception pattern are valid. if (versionObj.allowedFrontmatterPattern) { valid.pattern = new RegExp(`${asteriskPattern.source}|${versionObj.allowedFrontmatterPattern}`) - valid.message = `Must have a value of '*' or ${versionObj.allowedFrontmatterPattern}` + valid.message = `Must have a value of '*' or 'issue-###', where ### is an integer` } // If a version has numbered releases, any semver range is valid. Note '*' is a valid semver range. From 333a08804ae900857ff2d03bd36faa578da21c6f Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Wed, 8 Jun 2022 09:19:57 -0400 Subject: [PATCH 13/15] we do not need this test anymore --- tests/fixtures/page-versioned-for-ghae-next.md | 5 ----- tests/unit/page.js | 18 ------------------ 2 files changed, 23 deletions(-) delete mode 100644 tests/fixtures/page-versioned-for-ghae-next.md diff --git a/tests/fixtures/page-versioned-for-ghae-next.md b/tests/fixtures/page-versioned-for-ghae-next.md deleted file mode 100644 index 7829f629ad..0000000000 --- a/tests/fixtures/page-versioned-for-ghae-next.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Page versioned for next GitHub AE release -versions: - github-ae: 'next' ---- diff --git a/tests/unit/page.js b/tests/unit/page.js index 4fa5fd3ce7..b97add0ffd 100644 --- a/tests/unit/page.js +++ b/tests/unit/page.js @@ -297,24 +297,6 @@ describe('Page class', () => { return page.render(context) }).not.toThrow() }) - - test('support next GitHub AE version in frontmatter', async () => { - // This fixture has `github-ae: 'next'` hardcoded in the frontmatter - const page = await Page.init({ - relativePath: 'page-versioned-for-ghae-next.md', - basePath: path.join(__dirname, '../fixtures'), - languageCode: 'en', - }) - // set version to @latest - const context = { - currentVersion: 'github-ae@latest', - currentLanguage: 'en', - } - context.currentPath = `/${context.currentLanguage}/${context.currentVersion}` - await expect(() => { - return page.render(context) - }).not.toThrow() - }) }) test('preserves `languageCode`', async () => { From 73086ea806cd4e570603422535ccb3217b9b199a Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Fri, 10 Jun 2022 14:58:45 -0400 Subject: [PATCH 14/15] update allowed GHAE patterns to only allow one issue- --- lib/all-versions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/all-versions.js b/lib/all-versions.js index b6c6ffbad2..fc56249840 100644 --- a/lib/all-versions.js +++ b/lib/all-versions.js @@ -49,8 +49,8 @@ const plans = [ hasNumberedReleases: false, openApiBaseName: 'github.ae', miscBaseName: 'ghae', - allowedFrontmatterPattern: '^issue-\\d+?(-and-\\d+?)?$', - allowedInlinePattern: '^ghae-issue-\\d+?(-and-\\d+?)?$', + allowedFrontmatterPattern: '^issue-\\d+?$', + allowedInlinePattern: '^ghae-issue-\\d+?$', }, ] From ddd08403ff6fd2a4a5d9a144f3855b446f50cd90 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Fri, 10 Jun 2022 14:59:17 -0400 Subject: [PATCH 15/15] update the ghae versioning tag that uses two issue numbers --- .../using-openid-connect-with-reusable-workflows.md | 2 +- .../using-openid-connect-with-reusable-workflows.md | 2 +- .../using-openid-connect-with-reusable-workflows.md | 2 +- .../using-openid-connect-with-reusable-workflows.md | 2 +- .../using-openid-connect-with-reusable-workflows.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md b/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md index 984cc104d4..1fb177d065 100644 --- a/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md +++ b/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md @@ -7,7 +7,7 @@ redirect_from: - /actions/deployment/security-hardening-your-deployments/using-oidc-with-your-reusable-workflows versions: fpt: '*' - ghae: issue-4757-and-5856 + ghae: issue-4757 ghec: '*' ghes: '>=3.5' type: how_to diff --git a/translations/es-ES/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md b/translations/es-ES/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md index 984cc104d4..1fb177d065 100644 --- a/translations/es-ES/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md +++ b/translations/es-ES/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md @@ -7,7 +7,7 @@ redirect_from: - /actions/deployment/security-hardening-your-deployments/using-oidc-with-your-reusable-workflows versions: fpt: '*' - ghae: issue-4757-and-5856 + ghae: issue-4757 ghec: '*' ghes: '>=3.5' type: how_to diff --git a/translations/ja-JP/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md b/translations/ja-JP/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md index c832e1235a..b481d6a0a5 100644 --- a/translations/ja-JP/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md +++ b/translations/ja-JP/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md @@ -7,7 +7,7 @@ redirect_from: - /actions/deployment/security-hardening-your-deployments/using-oidc-with-your-reusable-workflows versions: fpt: '*' - ghae: issue-4757-and-5856 + ghae: issue-4757 ghec: '*' ghes: '>=3.5' type: how_to diff --git a/translations/pt-BR/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md b/translations/pt-BR/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md index b9a58e6fd5..92913fb61b 100644 --- a/translations/pt-BR/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md +++ b/translations/pt-BR/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md @@ -7,7 +7,7 @@ redirect_from: - /actions/deployment/security-hardening-your-deployments/using-oidc-with-your-reusable-workflows versions: fpt: '*' - ghae: issue-4757-and-5856 + ghae: issue-4757 ghec: '*' ghes: '>=3.5' type: how_to diff --git a/translations/zh-CN/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md b/translations/zh-CN/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md index 1ad05f7087..3d3d21dcfd 100644 --- a/translations/zh-CN/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md +++ b/translations/zh-CN/content/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows.md @@ -7,7 +7,7 @@ redirect_from: - /actions/deployment/security-hardening-your-deployments/using-oidc-with-your-reusable-workflows versions: fpt: '*' - ghae: issue-4757-and-5856 + ghae: issue-4757 ghec: '*' ghes: '>=3.5' type: how_to