From 1836cb65d5c41b0958006b452721fb0b72c37966 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Mon, 5 Feb 2024 13:57:13 -0500 Subject: [PATCH 1/4] Bail if no translation orphan files to delete (#49030) --- .github/workflows/delete-orphan-translation-files.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/delete-orphan-translation-files.yml b/.github/workflows/delete-orphan-translation-files.yml index 2ce1de12cf..7713dd6ea8 100644 --- a/.github/workflows/delete-orphan-translation-files.yml +++ b/.github/workflows/delete-orphan-translation-files.yml @@ -91,6 +91,14 @@ jobs: # Needed for gh GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }} run: | + # If nothing to commit, exit now. It's fine. No orphans. + changes=$(git diff --name-only | wc -l) + untracked=$(git status --untracked-files --short | wc -l) + if [[ $changes -eq 0 ]] && [[ $untracked -eq 0 ]]; then + echo "There are no changes to commit after running src/rest/scripts/update-files.js. Exiting..." + exit 0 + fi + git status current_timestamp=$(date '+%Y-%m-%d-%H%M%S') branch_name="delete-orphan-files-$current_timestamp" From f9eaf2403b2c2d57b4816b7d1ddda4e53ce89bec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 11:07:08 -0800 Subject: [PATCH 2/4] Bump dorny/paths-filter from 2.11.1 to 3.0.0 (#48960) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/codeowners-legal.yml | 2 +- .github/workflows/triage-unallowed-contributions.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeowners-legal.yml b/.github/workflows/codeowners-legal.yml index bd0842ae31..85820b3fcf 100644 --- a/.github/workflows/codeowners-legal.yml +++ b/.github/workflows/codeowners-legal.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Get files changed - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 + uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd id: filter with: # Base branch used to get changed files diff --git a/.github/workflows/triage-unallowed-contributions.yml b/.github/workflows/triage-unallowed-contributions.yml index 8e2099b118..8ad7d08d78 100644 --- a/.github/workflows/triage-unallowed-contributions.yml +++ b/.github/workflows/triage-unallowed-contributions.yml @@ -29,7 +29,7 @@ jobs: uses: ./.github/actions/node-npm-setup - name: Get files changed - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 + uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd id: filter with: # Base branch used to get changed files From 1fe7e5ef532f430dae9135891f7f4c355e131702 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Mon, 5 Feb 2024 14:09:26 -0500 Subject: [PATCH 3/4] Make it possible to precompute across all versions (#48776) --- .../actions/precompute-pageinfo/action.yml | 2 +- src/pageinfo/scripts/precompute-pageinfo.ts | 39 ++++++++++++++----- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/actions/precompute-pageinfo/action.yml b/.github/actions/precompute-pageinfo/action.yml index 0e88137540..1886f93c05 100644 --- a/.github/actions/precompute-pageinfo/action.yml +++ b/.github/actions/precompute-pageinfo/action.yml @@ -36,7 +36,7 @@ runs: - name: Run script if: ${{ inputs.restore-only == '' }} shell: bash - run: npm run precompute-pageinfo + run: npm run precompute-pageinfo -- --max-versions 2 - name: Cache .remotejson-cache (save) if: ${{ inputs.restore-only == '' }} diff --git a/src/pageinfo/scripts/precompute-pageinfo.ts b/src/pageinfo/scripts/precompute-pageinfo.ts index e95c027ad6..40c12583b2 100644 --- a/src/pageinfo/scripts/precompute-pageinfo.ts +++ b/src/pageinfo/scripts/precompute-pageinfo.ts @@ -40,21 +40,24 @@ program .description('Generates a JSON file with precompute pageinfo data by pathname') .addOption( new Option('-l, --language ', 'Which languages to focus on') - .choices(languageKeys) + .choices(languageKeys.concat('all')) .default(['en']), ) .option('-o, --output-file ', 'path to output file', CACHE_FILE_PATH) + .option('--max-versions ', 'max. number of permalink versions per page') .parse(process.argv) type Options = { outputFile: string languages: string[] + maxVersions: number } const opts = program.opts() main({ outputFile: opts.outputFile, languages: opts.language, + maxVersions: isNaN(opts.maxVersions) ? 1 : Number(opts.maxVersions), }) const CI = Boolean(JSON.parse(process.env.CI || 'false')) @@ -66,10 +69,16 @@ type PageInfo = { } async function main(options: Options) { - const { outputFile, languages } = options + const { outputFile, languages, maxVersions } = options if (outputFile !== CACHE_FILE_PATH) { console.warn(chalk.yellow(`Writing to ${outputFile} instead of ${CACHE_FILE_PATH}`)) } + if (languages.includes('all')) { + // This sets it to [], which when sent into loadUnversionedTree means + // it does all languages that it can find. + languages.length = 0 + } + const unversionedTree = await loadUnversionedTree(languages) const pageList = await loadPages(unversionedTree, languages) @@ -79,15 +88,25 @@ async function main(options: Options) { [pathname: string]: PageInfo } = {} for (const page of pageList) { - const pathname = page.permalinks[0].href - try { - const computed = await getPageInfo(page, pathname) - if (computed) { - pageinfos[pathname] = computed + let countVersions = 0 + for (const permalink of page.permalinks) { + const pathname = permalink.href + try { + const computed = await getPageInfo(page, pathname) + if (computed) { + pageinfos[pathname] = computed + } + } catch (error) { + console.error(`Error computing pageinfo for ${page.fullPath} (${pathname})`) + throw error + } + // By default, we only compute the first permalink href. + // But you can do more if you want. + if (++countVersions >= maxVersions) { + // This means we're content with only doing the first permalink href. + // That's 99% the free-pro-team permalink pathname. + break } - } catch (error) { - console.error(`Error computing pageinfo for ${page.fullPath} (${pathname})`) - throw error } } console.timeEnd(label) From a5a6d5a332e752a01f1dd467e9d6549011c22f42 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Mon, 5 Feb 2024 11:14:59 -0800 Subject: [PATCH 4/4] Update annotate.js (#49031) --- src/content-render/unified/annotate.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/content-render/unified/annotate.js b/src/content-render/unified/annotate.js index d61fd8b1d1..65fcc057b4 100644 --- a/src/content-render/unified/annotate.js +++ b/src/content-render/unified/annotate.js @@ -87,10 +87,12 @@ function createAnnotatedNode(node) { // Group groups into rows const rows = chunk(groups, 2) - for (const [, note] of rows) { - if (note === undefined) { + + // Check the rows are formatted correctly + for (const [note, code] of rows) { + if (note === undefined || code === undefined) { throw new Error( - "Unbalanced code meaning there's a comment (note) that is not followed by any code.", + "Each annotation must have a note and a code block. If you're trying to create a blank annotation, you can use a single line comment with a space after it.", ) } }