Skip to content

Commit 9a0b8b6

Browse files
authored
repo sync
2 parents a70fe53 + a7d2a3f commit 9a0b8b6

File tree

5 files changed

+83
-7
lines changed

5 files changed

+83
-7
lines changed

.github/workflows/browser-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
cancel_others: 'false'
1919
github_token: ${{ github.token }}
20-
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"]'
20+
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"]'
2121
build:
2222
needs: see_if_should_skip
2323
runs-on: ubuntu-latest

.github/workflows/crowdin.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ name: Crowdin Sync
44

55
on:
66
workflow_dispatch:
7-
push:
8-
branches:
9-
- main
7+
schedule:
8+
- cron: "33 2 * * *" # every day at 2:33 UTC at least until automerge is working
109

1110
jobs:
1211
sync_with_crowdin:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
cancel_others: 'false'
2929
github_token: ${{ github.token }}
30-
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/**"]'
30+
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"]'
3131
lint:
3232
needs: see_if_should_skip
3333
runs-on: ubuntu-latest

lib/redirects/precompile.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ module.exports = async function precompileRedirects (pages) {
5050
const developerRouteWithLanguage = `/en${developerRoute}`
5151
allRedirects[developerRouteWithLanguage] = newPath
5252

53+
// TODO until we update all the old /v3 and /v4 links, we need to support redirects
54+
// from the old /enterprise/<number>/v3 format to the new /enterprise-server@<number/rest format
55+
// AS WELL AS /enterprise-server@<number/v3 to /enterprise-server@<number/rest.
56+
// This is because the new format gets created dynamically even when the links point to /v3 or /v4.
57+
// EXAMPLES:
58+
// /en/enterprise/2.20/v3/pulls/comments -> /en/[email protected]/rest/reference/pulls#comments
59+
// /en/[email protected]/v3/pulls/comments -> /en/[email protected]/rest/reference/pulls#comments
60+
// NOTE: after we update all the /v3 and /v4 links, we can yank the following block
61+
if (developerRoute.includes('/enterprise/')) {
62+
const developerRouteWithNewFormat = developerRoute.replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/')
63+
const developerRouteWithNewFormatWithLanguage = `/en${developerRouteWithNewFormat}`
64+
allRedirects[developerRouteWithNewFormat] = newPath
65+
allRedirects[developerRouteWithNewFormatWithLanguage] = newPath
66+
}
67+
// TODO ENDYANK
68+
5369
// although we only support developer Enterprise paths up to 2.21, we make
5470
// an exception to always redirect versionless paths to the latest version
5571
if (developerRoute.includes('/2.21/')) {
@@ -58,18 +74,32 @@ module.exports = async function precompileRedirects (pages) {
5874
const developerRouteWithLanguageWithoutVersion = `/en${developerRouteWithoutVersion}`
5975
allRedirects[developerRouteWithoutVersion] = newPathOnLatestVersion
6076
allRedirects[developerRouteWithLanguageWithoutVersion] = newPathOnLatestVersion
77+
// TODO after we update all the /v3 and /v4 links, we can yank the following
78+
const developerRouteWithoutVersionWithNewFormat = developerRouteWithoutVersion
79+
.replace('/enterprise/', 'enterprise-server')
80+
const developerRouteWithoutVersionWithNewFormatWithLanguage = `/en${developerRouteWithoutVersionWithNewFormat}`
81+
allRedirects[developerRouteWithoutVersionWithNewFormat] = newPathOnLatestVersion
82+
allRedirects[developerRouteWithoutVersionWithNewFormatWithLanguage] = newPathOnLatestVersion
83+
// TODO ENDYANK
6184
}
6285

6386
// TODO: TEMPORARILY support explicit 2.22 redirects (created on page render by lib/rewrite-local-links)
64-
// we should eventually yank this block because 2.22 never existed on developer site
65-
// the better solution is to change `/v3` and `/v4` links in content to `/rest` and `/graphql`
87+
// after we update `/v3` and `/v4` links everywhere to `/rest` and `/graphql`, we can
88+
// yank this entire block because 2.22 never existed on developer site
6689
if (developerRoute.includes('/2.21/')) {
6790
const newPath222 = newPath.replace('@2.21/', '@2.22/')
6891
const developerRoute222 = developerRoute.replace('/2.21/', '/2.22/')
6992
const developerRouteWithLanguage222 = `/en${developerRoute222}`
7093
allRedirects[developerRoute222] = newPath222
7194
allRedirects[developerRouteWithLanguage222] = newPath222
95+
96+
const developerRouteWithNewFormat222 = developerRoute222
97+
.replace('/enterprise/2.22/', '/[email protected]/')
98+
const developerRouteWithNewFormatWithLanguage222 = `/en${developerRouteWithNewFormat222}`
99+
allRedirects[developerRouteWithNewFormat222] = newPath222
100+
allRedirects[developerRouteWithNewFormatWithLanguage222] = newPath222
72101
}
102+
// TODO ENDYANK
73103

74104
// given a developer route like `/enterprise/2.19/v3/activity`,
75105
// add a veriation like `/enterprise/2.19/user/v3/activity`;

tests/routing/developer-site-redirects.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { eachOfLimit } = require('async')
22
const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
33
const { get } = require('../helpers')
4+
const { getEnterpriseVersionNumber } = require('../../lib/patterns')
45
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
56
const restRedirectFixtures = require('../fixtures/rest-redirects')
67
const graphqlRedirectFixtures = require('../fixtures/graphql-redirects')
@@ -125,6 +126,29 @@ describe('developer redirects', () => {
125126
)
126127
})
127128

129+
// TODO temprarily ensure we redirect old links using the new enterprise format
130+
// for currently supported enterprise releases only
131+
// EXAMPLE: /en/[email protected]/v3/pulls/comments -> /en/[email protected]/rest/reference/pulls#comments
132+
// We can remove test after we update all the old `/v3` links to point to `/rest`
133+
test('temporary rest reference enterprise redirects', async () => {
134+
await eachOfLimit(
135+
restRedirectFixtures,
136+
MAX_CONCURRENT_REQUESTS,
137+
async (newPath, oldPath) => {
138+
const releaseNumber = oldPath.match(getEnterpriseVersionNumber)
139+
if (!releaseNumber) return
140+
if (!enterpriseServerReleases.supported.includes(releaseNumber[1])) return
141+
142+
oldPath = oldPath
143+
.replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/')
144+
.replace('/user/', '/')
145+
const res = await get(oldPath)
146+
expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301)
147+
expect(res.headers.location).toBe(newPath)
148+
}
149+
)
150+
})
151+
128152
// this fixtures file includes /v4 and /enterprise/v4 paths
129153
test('graphql reference redirects', async () => {
130154
await eachOfLimit(
@@ -140,5 +164,28 @@ describe('developer redirects', () => {
140164
}
141165
)
142166
})
167+
168+
// TODO temprarily ensure we redirect old links using the new enterprise format
169+
// for currently supported enterprise releases only
170+
// EXAMPLE: /en/[email protected]/v4/interface/actor -> /en/[email protected]/graphql/reference/interfaces#actor
171+
// We can remove test after we update all the old `/v4` links to point to `/graphql`
172+
test('temporary rest reference enterprise redirects', async () => {
173+
await eachOfLimit(
174+
graphqlRedirectFixtures,
175+
MAX_CONCURRENT_REQUESTS,
176+
async (newPath, oldPath) => {
177+
const releaseNumber = oldPath.match(getEnterpriseVersionNumber)
178+
if (!releaseNumber) return
179+
if (!enterpriseServerReleases.supported.includes(releaseNumber[1])) return
180+
181+
oldPath = oldPath
182+
.replace(/\/enterprise\/(\d.\d\d)\//, '/enterprise-server@$1/')
183+
.replace('/user/', '/')
184+
const res = await get(oldPath)
185+
expect(res.statusCode, `${oldPath} did not redirect to ${newPath}`).toBe(301)
186+
expect(res.headers.location).toBe(newPath)
187+
}
188+
)
189+
})
143190
})
144191
})

0 commit comments

Comments
 (0)