diff --git a/.github/workflows/browser-test.yml b/.github/workflows/browser-test.yml index 3f93beb10fb1..bcf79c7be5f7 100644 --- a/.github/workflows/browser-test.yml +++ b/.github/workflows/browser-test.yml @@ -17,7 +17,7 @@ jobs: with: cancel_others: 'false' github_token: ${{ github.token }} - paths: '["assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]' + paths: '[".github/workflows/browser-test.yml","assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]' build: needs: see_if_should_skip runs-on: ubuntu-latest diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml index 0dfe678cb9f2..af350664b039 100644 --- a/.github/workflows/crowdin.yml +++ b/.github/workflows/crowdin.yml @@ -4,9 +4,8 @@ name: Crowdin Sync on: workflow_dispatch: - push: - branches: - - main + schedule: + - cron: "33 2 * * *" # every day at 2:33 UTC at least until automerge is working jobs: sync_with_crowdin: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05b91f72067c..ae9b3bfc7299 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: with: cancel_others: 'false' github_token: ${{ github.token }} - paths_ignore: '[".all-contributorsrc", ".env.example", ".gitattributes", ".vscode/**", "app.json", "assets/**", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "contributing/**", "crowdin-actions-config.yml", "crowdin.yml", "docs", "javascripts/**", "jest-puppeteer.config.js", "LICENSE-CODE", "LICENSE", "nodemon.json", "ownership.yaml", "README.md", "script/**", "stylesheets/**"]' + paths: '[".github/workflows/test.yml",".node-version", ".npmrc", "app.json", "content/**", "data/**","lib/**", "Dockerfile", "feature-flags.json", "Gemfile", "Gemfile.lock", "middleware/**", "node_modules/**","package.json", "package-lock.json", "server.js", "tests/**", "translations/**", "Procfile", "webpack.config.js"]' lint: needs: see_if_should_skip runs-on: ubuntu-latest diff --git a/lib/redirects/precompile.js b/lib/redirects/precompile.js index 91f57591efbf..2854568eb827 100755 --- a/lib/redirects/precompile.js +++ b/lib/redirects/precompile.js @@ -50,6 +50,22 @@ module.exports = async function precompileRedirects (pages) { const developerRouteWithLanguage = `/en${developerRoute}` allRedirects[developerRouteWithLanguage] = newPath + // TODO until we update all the old /v3 and /v4 links, we need to support redirects + // from the old /enterprise//v3 format to the new /enterprise-server@ /en/enterprise-server@2.20/rest/reference/pulls#comments + // /en/enterprise-server@2.20/v3/pulls/comments -> /en/enterprise-server@2.20/rest/reference/pulls#comments + // NOTE: after we update all the /v3 and /v4 links, we can yank the following block + if (developerRoute.includes('/enterprise/')) { + const developerRouteWithNewFormat = developerRoute.replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/') + const developerRouteWithNewFormatWithLanguage = `/en${developerRouteWithNewFormat}` + allRedirects[developerRouteWithNewFormat] = newPath + allRedirects[developerRouteWithNewFormatWithLanguage] = newPath + } + // TODO ENDYANK + // although we only support developer Enterprise paths up to 2.21, we make // an exception to always redirect versionless paths to the latest version if (developerRoute.includes('/2.21/')) { @@ -58,18 +74,32 @@ module.exports = async function precompileRedirects (pages) { const developerRouteWithLanguageWithoutVersion = `/en${developerRouteWithoutVersion}` allRedirects[developerRouteWithoutVersion] = newPathOnLatestVersion allRedirects[developerRouteWithLanguageWithoutVersion] = newPathOnLatestVersion + // TODO after we update all the /v3 and /v4 links, we can yank the following + const developerRouteWithoutVersionWithNewFormat = developerRouteWithoutVersion + .replace('/enterprise/', 'enterprise-server') + const developerRouteWithoutVersionWithNewFormatWithLanguage = `/en${developerRouteWithoutVersionWithNewFormat}` + allRedirects[developerRouteWithoutVersionWithNewFormat] = newPathOnLatestVersion + allRedirects[developerRouteWithoutVersionWithNewFormatWithLanguage] = newPathOnLatestVersion + // TODO ENDYANK } // TODO: TEMPORARILY support explicit 2.22 redirects (created on page render by lib/rewrite-local-links) - // we should eventually yank this block because 2.22 never existed on developer site - // the better solution is to change `/v3` and `/v4` links in content to `/rest` and `/graphql` + // after we update `/v3` and `/v4` links everywhere to `/rest` and `/graphql`, we can + // yank this entire block because 2.22 never existed on developer site if (developerRoute.includes('/2.21/')) { const newPath222 = newPath.replace('@2.21/', '@2.22/') const developerRoute222 = developerRoute.replace('/2.21/', '/2.22/') const developerRouteWithLanguage222 = `/en${developerRoute222}` allRedirects[developerRoute222] = newPath222 allRedirects[developerRouteWithLanguage222] = newPath222 + + const developerRouteWithNewFormat222 = developerRoute222 + .replace('/enterprise/2.22/', '/enterprise-server@2.22/') + const developerRouteWithNewFormatWithLanguage222 = `/en${developerRouteWithNewFormat222}` + allRedirects[developerRouteWithNewFormat222] = newPath222 + allRedirects[developerRouteWithNewFormatWithLanguage222] = newPath222 } + // TODO ENDYANK // given a developer route like `/enterprise/2.19/v3/activity`, // add a veriation like `/enterprise/2.19/user/v3/activity`; diff --git a/tests/routing/developer-site-redirects.js b/tests/routing/developer-site-redirects.js index 52c8f9808842..112feed352b5 100644 --- a/tests/routing/developer-site-redirects.js +++ b/tests/routing/developer-site-redirects.js @@ -1,6 +1,7 @@ const { eachOfLimit } = require('async') const enterpriseServerReleases = require('../../lib/enterprise-server-releases') const { get } = require('../helpers') +const { getEnterpriseVersionNumber } = require('../../lib/patterns') const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version') const restRedirectFixtures = require('../fixtures/rest-redirects') const graphqlRedirectFixtures = require('../fixtures/graphql-redirects') @@ -125,6 +126,29 @@ describe('developer redirects', () => { ) }) + // TODO temprarily ensure we redirect old links using the new enterprise format + // for currently supported enterprise releases only + // EXAMPLE: /en/enterprise-server@2.20/v3/pulls/comments -> /en/enterprise-server@2.20/rest/reference/pulls#comments + // We can remove test after we update all the old `/v3` links to point to `/rest` + test('temporary rest reference enterprise redirects', async () => { + await eachOfLimit( + restRedirectFixtures, + MAX_CONCURRENT_REQUESTS, + async (newPath, oldPath) => { + const releaseNumber = oldPath.match(getEnterpriseVersionNumber) + if (!releaseNumber) return + if (!enterpriseServerReleases.supported.includes(releaseNumber[1])) return + + oldPath = oldPath + .replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/') + .replace('/user/', '/') + const res = await get(oldPath) + expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301) + expect(res.headers.location).toBe(newPath) + } + ) + }) + // this fixtures file includes /v4 and /enterprise/v4 paths test('graphql reference redirects', async () => { await eachOfLimit( @@ -140,5 +164,28 @@ describe('developer redirects', () => { } ) }) + + // TODO temprarily ensure we redirect old links using the new enterprise format + // for currently supported enterprise releases only + // EXAMPLE: /en/enterprise-server@2.20/v4/interface/actor -> /en/enterprise-server@2.20/graphql/reference/interfaces#actor + // We can remove test after we update all the old `/v4` links to point to `/graphql` + test('temporary rest reference enterprise redirects', async () => { + await eachOfLimit( + graphqlRedirectFixtures, + MAX_CONCURRENT_REQUESTS, + async (newPath, oldPath) => { + const releaseNumber = oldPath.match(getEnterpriseVersionNumber) + if (!releaseNumber) return + if (!enterpriseServerReleases.supported.includes(releaseNumber[1])) return + + oldPath = oldPath + .replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/') + .replace('/user/', '/') + const res = await get(oldPath) + expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301) + expect(res.headers.location).toBe(newPath) + } + ) + }) }) })