diff --git a/.github/actions-scripts/compress-large-files.js b/.github/actions-scripts/compress-large-files.js deleted file mode 100755 index 40b535a967c6..000000000000 --- a/.github/actions-scripts/compress-large-files.js +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env node - -import path from 'path' -import fs from 'fs' -import zlib from 'zlib' -import walk from 'walk-sync' - -const DRY_RUN = Boolean(JSON.parse(process.env.DRY_RUN || 'false')) -// Roughly 100KiB means about 25 files at the moment. -// Set this too low and the overheads will be more than the disk and -// network I/O that this intends to serve. -const MIN_GZIP_SIZE = Number(process.env.MIN_GZIP_SIZE || 1024 * 100) - -const BROTLI_OPTIONS = { - params: { - [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT, - [zlib.constants.BROTLI_PARAM_QUALITY]: 6, - }, -} -main() - -async function main() { - compressFromPattern('lib/**/static/**/*.json') -} - -async function compressFromPattern(pattern) { - const glob = pattern.includes('*') ? pattern.split(path.sep).slice(1).join(path.sep) : undefined - const walkOptions = { - globs: glob ? [glob] : undefined, - directories: false, - includeBasePath: true, - } - const root = path.resolve(pattern.includes('*') ? pattern.split(path.sep)[0] : pattern) - const filePaths = walk(root, walkOptions).filter((filePath) => { - return fs.statSync(filePath).size > MIN_GZIP_SIZE - }) - - if (!DRY_RUN) { - console.time(`Compress ${filePaths.length} files`) - const compressed = await Promise.all(filePaths.map(compressFile)) - console.timeEnd(`Compress ${filePaths.length} files`) - - console.time(`Delete ${compressed.length} files`) - compressed.forEach((filePath) => fs.unlinkSync(filePath)) - console.timeEnd(`Delete ${compressed.length} files`) - } -} - -function compressFile(filePath) { - return new Promise((resolve, reject) => { - const contentStream = fs.createReadStream(filePath) - const newFilePath = `${filePath}.br` - const writeStream = fs.createWriteStream(newFilePath) - const compressor = zlib.createBrotliCompress(BROTLI_OPTIONS) - contentStream - .pipe(compressor) - .pipe(writeStream) - .on('finish', (err) => { - if (err) return reject(err) - resolve(filePath) - }) - }) -} diff --git a/.github/workflows/azure-preview-env-deploy.yml b/.github/workflows/azure-preview-env-deploy.yml index d8f674f416a2..416ae13ca6c7 100644 --- a/.github/workflows/azure-preview-env-deploy.yml +++ b/.github/workflows/azure-preview-env-deploy.yml @@ -112,7 +112,7 @@ jobs: - name: Get preview app info env: APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }} - run: .github/actions-scripts/get-preview-app-info.sh + run: src/workflows/get-preview-app-info.sh - name: 'Set env vars' run: | @@ -210,7 +210,7 @@ jobs: # In addition to making the final image smaller, we also save time by not sending unnecessary files to the docker build context - name: 'Prune for preview env' - run: .github/actions-scripts/prune-for-preview-env.sh + run: src/workflows/prune-for-preview-env.sh - name: 'Build and push image' uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 diff --git a/.github/workflows/azure-preview-env-destroy.yml b/.github/workflows/azure-preview-env-destroy.yml index f2d8319f9937..c0ac240f6c4d 100644 --- a/.github/workflows/azure-preview-env-destroy.yml +++ b/.github/workflows/azure-preview-env-destroy.yml @@ -45,7 +45,7 @@ jobs: - name: Get preview app info env: APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }} - run: .github/actions-scripts/get-preview-app-info.sh + run: src/workflows/get-preview-app-info.sh # Succeed despite any non-zero exit code (e.g. if there is no deployment to cancel) - name: 'Cancel any in progress deployments' diff --git a/.github/workflows/content-changes-table-comment.yml b/.github/workflows/content-changes-table-comment.yml index 12e3119812ab..6c6e53cdc8f9 100644 --- a/.github/workflows/content-changes-table-comment.yml +++ b/.github/workflows/content-changes-table-comment.yml @@ -54,7 +54,7 @@ jobs: - name: Get preview app info env: APP_NAME_SEED: ${{ secrets.PREVIEW_ENV_NAME_SEED }} - run: .github/actions-scripts/get-preview-app-info.sh + run: src/workflows/get-preview-app-info.sh - name: Setup Node.js uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 @@ -72,7 +72,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} APP_URL: ${{ env.APP_URL }} - run: .github/actions-scripts/content-changes-table-comment.js + run: src/workflows/content-changes-table-comment.js - name: Find content directory changes comment uses: peter-evans/find-comment@f4499a714d59013c74a08789b48abe4b704364a0 diff --git a/.github/workflows/docs-review-collect.yml b/.github/workflows/docs-review-collect.yml index 8a6347f8b72f..8ccbbe577820 100644 --- a/.github/workflows/docs-review-collect.yml +++ b/.github/workflows/docs-review-collect.yml @@ -33,7 +33,7 @@ jobs: - name: Run script for github run: | - node .github/actions-scripts/fr-add-docs-reviewers-requests.js + node src/workflows/fr-add-docs-reviewers-requests.js env: TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} PROJECT_NUMBER: 2936 @@ -44,7 +44,7 @@ jobs: - name: Run script for audit-log-allowlists run: | - node .github/actions-scripts/fr-add-docs-reviewers-requests.js + node src/workflows/fr-add-docs-reviewers-requests.js env: TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} PROJECT_NUMBER: 2936 diff --git a/.github/workflows/enterprise-dates.yml b/.github/workflows/enterprise-dates.yml index f19f3b3d82e2..9adb9a5cd9ec 100644 --- a/.github/workflows/enterprise-dates.yml +++ b/.github/workflows/enterprise-dates.yml @@ -71,7 +71,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }} AUTOMERGE_PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }} - run: node .github/actions-scripts/enable-automerge.js + run: node src/workflows/enable-automerge.js - if: ${{ failure() && env.FREEZE != 'true' }} name: Delete remote branch (if previous steps failed) diff --git a/.github/workflows/lint-entire-content-data-markdown.yml b/.github/workflows/lint-entire-content-data-markdown.yml index d5f675f758d3..cab4e1e4c89d 100644 --- a/.github/workflows/lint-entire-content-data-markdown.yml +++ b/.github/workflows/lint-entire-content-data-markdown.yml @@ -41,4 +41,4 @@ jobs: REPORT_AUTHOR: docs-bot REPORT_LABEL: broken content markdown report REPORT_REPOSITORY: github/docs-content - run: node .github/actions-scripts/post-lints.js --path /tmp/error-lints.json + run: node src/content-linter/scripts/post-lints.js --path /tmp/error-lints.json diff --git a/.github/workflows/local-dev.yml b/.github/workflows/local-dev.yml index e69fdc3ef6a2..56d621f32b16 100644 --- a/.github/workflows/local-dev.yml +++ b/.github/workflows/local-dev.yml @@ -38,7 +38,7 @@ jobs: curl --fail --retry-connrefused --retry 5 http://localhost:4000/ - name: Run basic tests - run: node .github/actions-scripts/test-local-dev.js + run: node src/workflows/test-local-dev.js - if: ${{ failure() }} name: Debug server outputs on errors diff --git a/.github/workflows/main-preview-docker-cache.yml b/.github/workflows/main-preview-docker-cache.yml index 4fba88a2b73b..459afbb3a4f1 100644 --- a/.github/workflows/main-preview-docker-cache.yml +++ b/.github/workflows/main-preview-docker-cache.yml @@ -65,7 +65,7 @@ jobs: # In addition to making the final image smaller, we also save time by not sending unnecessary files to the docker build context - name: 'Prune for preview env' - run: .github/actions-scripts/prune-for-preview-env.sh + run: src/workflows/prune-for-preview-env.sh - name: 'Build and push image' uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 diff --git a/.github/workflows/manually-purge-fastly.yml b/.github/workflows/manually-purge-fastly.yml index 3c02ddf41ef4..686e1e155d7b 100644 --- a/.github/workflows/manually-purge-fastly.yml +++ b/.github/workflows/manually-purge-fastly.yml @@ -25,4 +25,4 @@ jobs: FASTLY_TOKEN: ${{ secrets.FASTLY_TOKEN }} FASTLY_SERVICE_ID: ${{ secrets.FASTLY_SERVICE_ID }} FASTLY_SURROGATE_KEY: 'manual-purge' - run: .github/actions-scripts/purge-fastly-edge-cache.js + run: src/workflows/purge-fastly-edge-cache.js diff --git a/.github/workflows/notify-about-deployment.yml b/.github/workflows/notify-about-deployment.yml index 8b06b4469de4..377fcb706736 100644 --- a/.github/workflows/notify-about-deployment.yml +++ b/.github/workflows/notify-about-deployment.yml @@ -39,7 +39,7 @@ jobs: timeout-minutes: 3 env: GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }} - run: .github/actions-scripts/find-past-built-pr.js + run: src/workflows/find-past-built-pr.js - name: Find content directory changes comment if: ${{ steps.get-number.outputs.number != '' }} diff --git a/.github/workflows/os-ready-for-review.yml b/.github/workflows/os-ready-for-review.yml index 34897612863b..29a9d7a59c9d 100644 --- a/.github/workflows/os-ready-for-review.yml +++ b/.github/workflows/os-ready-for-review.yml @@ -57,7 +57,7 @@ jobs: - name: Run script run: | - node .github/actions-scripts/ready-for-docs-review.js + node src/workflows/ready-for-docs-review.js env: TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} PROJECT_NUMBER: 2936 diff --git a/.github/workflows/purge-fastly.yml b/.github/workflows/purge-fastly.yml index 10bdff004699..72cd50ea29e4 100644 --- a/.github/workflows/purge-fastly.yml +++ b/.github/workflows/purge-fastly.yml @@ -40,7 +40,7 @@ jobs: - name: Purge Fastly edge cache independent of language if: ${{ inputs.nuke_all }} - run: .github/actions-scripts/purge-fastly-edge-cache.js + run: src/workflows/purge-fastly-edge-cache.js - name: Purge Fastly edge cache per language if: ${{ !inputs.nuke_all }} diff --git a/.github/workflows/purge-old-deployment-environments.yml b/.github/workflows/purge-old-deployment-environments.yml index a886207dccaa..9f55e3a47599 100644 --- a/.github/workflows/purge-old-deployment-environments.yml +++ b/.github/workflows/purge-old-deployment-environments.yml @@ -31,7 +31,7 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} # Necessary to be able to delete deployment environments GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }} - run: .github/actions-scripts/purge-old-deployment-environments.js + run: src/workflows/purge-old-deployment-environments.js - name: Send Slack notification if workflow fails uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad diff --git a/.github/workflows/purge-old-workflow-runs.yml b/.github/workflows/purge-old-workflow-runs.yml index 2becfb140beb..a059296499b9 100644 --- a/.github/workflows/purge-old-workflow-runs.yml +++ b/.github/workflows/purge-old-workflow-runs.yml @@ -28,7 +28,7 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} # Necessary to be able to delete deployment environments GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }} - run: .github/actions-scripts/purge-old-workflow-runs.js + run: src/workflows/purge-old-workflow-runs.js - name: Send Slack notification if workflow fails uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad diff --git a/.github/workflows/ready-for-doc-review.yml b/.github/workflows/ready-for-doc-review.yml index f8c2f7d55529..11fbe8471a8e 100644 --- a/.github/workflows/ready-for-doc-review.yml +++ b/.github/workflows/ready-for-doc-review.yml @@ -34,7 +34,7 @@ jobs: - name: Run script run: | - node .github/actions-scripts/ready-for-docs-review.js + node src/workflows/ready-for-docs-review.js env: TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} PROJECT_NUMBER: 2936 diff --git a/.github/workflows/sync-graphql.yml b/.github/workflows/sync-graphql.yml index 6f70c1922462..f93c589dd0e5 100644 --- a/.github/workflows/sync-graphql.yml +++ b/.github/workflows/sync-graphql.yml @@ -66,7 +66,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }} AUTOMERGE_PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }} - run: node .github/actions-scripts/enable-automerge.js + run: node src/workflows/enable-automerge.js - if: ${{ failure() && env.FREEZE != 'true'}} name: Delete remote branch (if previous steps failed) diff --git a/.github/workflows/sync-search-elasticsearch.yml b/.github/workflows/sync-search-elasticsearch.yml index cb1e93966055..9856c6648626 100644 --- a/.github/workflows/sync-search-elasticsearch.yml +++ b/.github/workflows/sync-search-elasticsearch.yml @@ -203,7 +203,7 @@ jobs: FASTLY_TOKEN: ${{ secrets.FASTLY_TOKEN }} FASTLY_SERVICE_ID: ${{ secrets.FASTLY_SERVICE_ID }} FASTLY_SURROGATE_KEY: api-search:${{ matrix.language }} - run: .github/actions-scripts/purge-fastly-edge-cache.js + run: src/workflows/purge-fastly-edge-cache.js - name: Send Slack notification if workflow fails uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c9f003b86bd8..d01f7c7a5707 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,6 +77,7 @@ jobs: # - tools - versions - webhooks + # - workflows # The languages suite only runs on docs-internal isPrivateRepo: diff --git a/script/content-changes-table-comment.js b/script/content-changes-table-comment.js index 020541c7eab3..bf820ce19cd8 100755 --- a/script/content-changes-table-comment.js +++ b/script/content-changes-table-comment.js @@ -23,7 +23,7 @@ // [end-readme] import { program } from 'commander' -import main from '../.github/actions-scripts/content-changes-table-comment.js' +import main from '#src/workflows/content-changes-table-comment.js' program .description('Produce a nice table based on the branch diff') diff --git a/.github/actions-scripts/post-lints.js b/src/content-linter/scripts/post-lints.js similarity index 90% rename from .github/actions-scripts/post-lints.js rename to src/content-linter/scripts/post-lints.js index 42460f6551b4..a0d3dfbd9a4b 100644 --- a/.github/actions-scripts/post-lints.js +++ b/src/content-linter/scripts/post-lints.js @@ -4,9 +4,9 @@ import { program } from 'commander' import fs from 'fs' import coreLib from '@actions/core' -import github from '../../script/helpers/github.js' -import { getEnvInputs } from './lib/get-env-inputs.js' -import { createReportIssue, linkReports } from './lib/issue-report.js' +import github from '../../../script/helpers/github.js' +import { getEnvInputs } from '../../../src/workflows/get-env-inputs.js' +import { createReportIssue, linkReports } from '../../../src/workflows/issue-report.js' // [start-readme] // diff --git a/.github/actions-scripts/lib/debug-time-taken.js b/src/links/scripts/debug-time-taken.js similarity index 100% rename from .github/actions-scripts/lib/debug-time-taken.js rename to src/links/scripts/debug-time-taken.js diff --git a/src/links/scripts/rendered-content-link-checker.js b/src/links/scripts/rendered-content-link-checker.js index aeb5ef43d837..e31ac2d0469b 100755 --- a/src/links/scripts/rendered-content-link-checker.js +++ b/src/links/scripts/rendered-content-link-checker.js @@ -17,19 +17,13 @@ import warmServer from '../../../lib/warm-server.js' import { liquid } from '#src/content-render/index.js' import { deprecated } from '#src/versions/lib/enterprise-server-releases.js' import excludedLinks from '#src/links/lib/excluded-links.js' -import { getEnvInputs, boolEnvVar } from '../../../.github/actions-scripts/lib/get-env-inputs.js' -import { - debugTimeEnd, - debugTimeStart, -} from '../../../.github/actions-scripts/lib/debug-time-taken.js' -import { uploadArtifact as uploadArtifactLib } from '../../../.github/actions-scripts/lib/upload-artifact.js' +import { getEnvInputs, boolEnvVar } from '../../../src/workflows/get-env-inputs.js' +import { debugTimeEnd, debugTimeStart } from './debug-time-taken.js' +import { uploadArtifact as uploadArtifactLib } from './upload-artifact.js' import github from '../../../script/helpers/github.js' -import { getActionContext } from '../../../.github/actions-scripts/lib/action-context.js' +import { getActionContext } from '../../../src/workflows/action-context.js' import { createMinimalProcessor } from '#src/content-render/unified/processor.js' -import { - createReportIssue, - linkReports, -} from '../../../.github/actions-scripts/lib/issue-report.js' +import { createReportIssue, linkReports } from '../../../src/workflows/issue-report.js' const STATIC_PREFIXES = { assets: path.resolve('assets'), diff --git a/.github/actions-scripts/lib/upload-artifact.js b/src/links/scripts/upload-artifact.js similarity index 100% rename from .github/actions-scripts/lib/upload-artifact.js rename to src/links/scripts/upload-artifact.js diff --git a/src/workflows/README.md b/src/workflows/README.md new file mode 100644 index 000000000000..1ec35abbec91 --- /dev/null +++ b/src/workflows/README.md @@ -0,0 +1,3 @@ +# Workflows + +This directory contains workflow scripts that cannot otherwise be in other subject folders. diff --git a/.github/actions-scripts/lib/action-context.js b/src/workflows/action-context.js similarity index 100% rename from .github/actions-scripts/lib/action-context.js rename to src/workflows/action-context.js diff --git a/.github/actions-scripts/content-changes-table-comment.js b/src/workflows/content-changes-table-comment.js similarity index 98% rename from .github/actions-scripts/content-changes-table-comment.js rename to src/workflows/content-changes-table-comment.js index 40b2cb07dc21..faba75ca4d87 100755 --- a/.github/actions-scripts/content-changes-table-comment.js +++ b/src/workflows/content-changes-table-comment.js @@ -8,7 +8,7 @@ import parse from '../../lib/read-frontmatter.js' import getApplicableVersions from '#src/versions/lib/get-applicable-versions.js' import nonEnterpriseDefaultVersion from '#src/versions/lib/non-enterprise-default-version.js' import { allVersionShortnames } from '#src/versions/lib/all-versions.js' -import { waitUntilUrlIsHealthy } from './lib/wait-until-url-is-healthy.js' +import { waitUntilUrlIsHealthy } from './wait-until-url-is-healthy.js' const { GITHUB_TOKEN, APP_URL } = process.env const context = github.context diff --git a/.github/actions-scripts/enable-automerge.js b/src/workflows/enable-automerge.js similarity index 100% rename from .github/actions-scripts/enable-automerge.js rename to src/workflows/enable-automerge.js diff --git a/.github/actions-scripts/find-past-built-pr.js b/src/workflows/find-past-built-pr.js similarity index 95% rename from .github/actions-scripts/find-past-built-pr.js rename to src/workflows/find-past-built-pr.js index b1dc99e16b9f..af0c7d1b6d65 100755 --- a/.github/actions-scripts/find-past-built-pr.js +++ b/src/workflows/find-past-built-pr.js @@ -4,7 +4,7 @@ import got from 'got' import { setOutput } from '@actions/core' import github from '../../script/helpers/github.js' -import { getActionContext } from './lib/action-context.js' +import { getActionContext } from './action-context.js' async function main() { const sha = await getBuiltSHA() diff --git a/.github/actions-scripts/fr-add-docs-reviewers-requests.js b/src/workflows/fr-add-docs-reviewers-requests.js similarity index 100% rename from .github/actions-scripts/fr-add-docs-reviewers-requests.js rename to src/workflows/fr-add-docs-reviewers-requests.js diff --git a/.github/actions-scripts/lib/get-env-inputs.js b/src/workflows/get-env-inputs.js similarity index 100% rename from .github/actions-scripts/lib/get-env-inputs.js rename to src/workflows/get-env-inputs.js diff --git a/.github/actions-scripts/get-preview-app-info.sh b/src/workflows/get-preview-app-info.sh similarity index 100% rename from .github/actions-scripts/get-preview-app-info.sh rename to src/workflows/get-preview-app-info.sh diff --git a/.github/actions-scripts/lib/issue-report.js b/src/workflows/issue-report.js similarity index 100% rename from .github/actions-scripts/lib/issue-report.js rename to src/workflows/issue-report.js diff --git a/.github/actions-scripts/projects.js b/src/workflows/projects.js similarity index 100% rename from .github/actions-scripts/projects.js rename to src/workflows/projects.js diff --git a/.github/actions-scripts/prune-for-preview-env.sh b/src/workflows/prune-for-preview-env.sh similarity index 100% rename from .github/actions-scripts/prune-for-preview-env.sh rename to src/workflows/prune-for-preview-env.sh diff --git a/.github/actions-scripts/purge-fastly-edge-cache.js b/src/workflows/purge-fastly-edge-cache.js similarity index 100% rename from .github/actions-scripts/purge-fastly-edge-cache.js rename to src/workflows/purge-fastly-edge-cache.js diff --git a/.github/actions-scripts/purge-old-deployment-environments.js b/src/workflows/purge-old-deployment-environments.js similarity index 100% rename from .github/actions-scripts/purge-old-deployment-environments.js rename to src/workflows/purge-old-deployment-environments.js diff --git a/.github/actions-scripts/purge-old-workflow-runs.js b/src/workflows/purge-old-workflow-runs.js similarity index 100% rename from .github/actions-scripts/purge-old-workflow-runs.js rename to src/workflows/purge-old-workflow-runs.js diff --git a/.github/actions-scripts/ready-for-docs-review.js b/src/workflows/ready-for-docs-review.js similarity index 100% rename from .github/actions-scripts/ready-for-docs-review.js rename to src/workflows/ready-for-docs-review.js diff --git a/.github/actions-scripts/test-local-dev.js b/src/workflows/test-local-dev.js similarity index 98% rename from .github/actions-scripts/test-local-dev.js rename to src/workflows/test-local-dev.js index 94bfe46c5cca..6ea79096f864 100755 --- a/.github/actions-scripts/test-local-dev.js +++ b/src/workflows/test-local-dev.js @@ -17,7 +17,7 @@ import got from 'got' * For engineers to test this locally do the following: * * 1. Start `npm run dev` in one terminal - * 2. Run `./.github/actions-scripts/test-local-dev.js` in another terminal + * 2. Run `src/workflows/test-local-dev.js` in another terminal * */ diff --git a/.github/actions-scripts/lib/wait-until-url-is-healthy.js b/src/workflows/wait-until-url-is-healthy.js similarity index 100% rename from .github/actions-scripts/lib/wait-until-url-is-healthy.js rename to src/workflows/wait-until-url-is-healthy.js