From f42530c35da2f691041ecb25518fb37bd020d5d6 Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Thu, 15 Oct 2020 09:20:27 -0400 Subject: [PATCH 1/4] Support redirects to /v3 and /v4 links that have the new version format (#16037) * add temporary redirect support * add temporary redirect tests * add ENDYANK comments per @zeke suggestion --- lib/redirects/precompile.js | 34 +++++++++++++++- tests/routing/developer-site-redirects.js | 47 +++++++++++++++++++++++ 2 files changed, 79 insertions(+), 2 deletions(-) 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) + } + ) + }) }) }) From 68ca82f2271cba412b1f46406e6335c2d0b372e4 Mon Sep 17 00:00:00 2001 From: Chiedo John <2156688+chiedo@users.noreply.github.com> Date: Thu, 15 Oct 2020 09:48:40 -0400 Subject: [PATCH 2/4] Move from paths-ignore to paths to be less confusing (#16040) * Move from paths-ignore to paths to be less confusing * Include feature flags * Make sure test and browser workflows run fully when changed Co-authored-by: Chiedo --- .github/workflows/browser-test.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/browser-test.yml b/.github/workflows/browser-test.yml index 91a7905d73c5..d7b707320608 100644 --- a/.github/workflows/browser-test.yml +++ b/.github/workflows/browser-test.yml @@ -16,7 +16,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/test.yml b/.github/workflows/test.yml index 4b0e9cec9932..e395b98d15ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,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/**", "Procfile", "webpack.config.js"]' lint: needs: see_if_should_skip runs-on: ubuntu-latest From d96352d13a01b7fececf698aa1fca94b7e0c9f80 Mon Sep 17 00:00:00 2001 From: Chiedo John <2156688+chiedo@users.noreply.github.com> Date: Thu, 15 Oct 2020 13:58:54 -0400 Subject: [PATCH 3/4] Make sure transalations trigger node tests (#16064) Co-authored-by: Chiedo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e395b98d15ef..5ee30b10ef03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: with: cancel_others: 'false' github_token: ${{ github.token }} - 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/**", "Procfile", "webpack.config.js"]' + 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 From 126d46fbebb299c09b531962995bc672d875edd3 Mon Sep 17 00:00:00 2001 From: Chiedo John <2156688+chiedo@users.noreply.github.com> Date: Thu, 15 Oct 2020 14:11:51 -0400 Subject: [PATCH 4/4] Make crowdin run daily instead of on git push to main (#16065) * Make crowdin daily * Trigger new build Co-authored-by: Chiedo --- .github/workflows/crowdin.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml index 0c4cfe2b1307..bb0f92d61a92 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: