@@ -18,7 +18,7 @@ If you aren't comfortable going through the steps alone, sync up with a docs eng
|
||||
```
|
||||
script/update-enterprise-dates.js
|
||||
```
|
||||
- [ ] Create REST files based on previous version. Copy the latest GHES version of the dereferenced file from `lib/rest/static/dereferenced` to a new file in the same directory for the new GHES release. Ex, `cp lib/rest/static/dereferenced/ghes-3.4.deref.json lib/rest/static/dereferenced/ghes-3.5.deref.json`. Then run `script/rest/updated-files.js --decorate-only` and check in the resulting files.
|
||||
- [ ] Create REST files based on previous version. Copy the latest GHES version of the dereferenced file from `lib/rest/static/dereferenced` to a new file in the same directory for the new GHES release. Ex, `cp lib/rest/static/dereferenced/ghes-3.4.deref.json lib/rest/static/dereferenced/ghes-3.5.deref.json`. Then run `script/rest/update-files.js --decorate-only` and check in the resulting files.
|
||||
|
||||
- [ ] Create GraphQL files based on previous version:
|
||||
|
||||
|
||||
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@@ -23,6 +23,9 @@ env:
|
||||
# Setting this will activate the jest tests that depend on actually
|
||||
# sending real search queries to Elasticsearch
|
||||
ELASTICSEARCH_URL: http://localhost:9200/
|
||||
# Hopefully the name is clear enough. By enabling this, we're testing
|
||||
# the future code.
|
||||
ENABLE_SEARCH_RESULTS_PAGE: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
||||
@@ -66,10 +66,10 @@ If you have existing source code or repositories stored locally on your computer
|
||||
$ git init -b main
|
||||
```
|
||||
|
||||
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git branch -m`.
|
||||
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git symbolic-ref HEAD refs/heads/main`.
|
||||
|
||||
``` shell
|
||||
$ git init && git branch -m main
|
||||
$ git init && git symbolic-ref HEAD refs/heads/main
|
||||
```
|
||||
5. Add the files in your new local repository. This stages them for the first commit.
|
||||
|
||||
@@ -113,10 +113,10 @@ If you have existing source code or repositories stored locally on your computer
|
||||
$ git init -b main
|
||||
```
|
||||
|
||||
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git branch -m`.
|
||||
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git symbolic-ref HEAD refs/heads/main`.
|
||||
|
||||
``` shell
|
||||
$ git init && git branch -m main
|
||||
$ git init && git symbolic-ref HEAD refs/heads/main
|
||||
```
|
||||
5. Add the files in your new local repository. This stages them for the first commit.
|
||||
```shell
|
||||
@@ -159,10 +159,10 @@ If you have existing source code or repositories stored locally on your computer
|
||||
$ git init -b main
|
||||
```
|
||||
|
||||
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git branch -m`.
|
||||
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git symbolic-ref HEAD refs/heads/main`.
|
||||
|
||||
``` shell
|
||||
$ git init && git branch -m main
|
||||
$ git init && git symbolic-ref HEAD refs/heads/main
|
||||
```
|
||||
5. Add the files in your new local repository. This stages them for the first commit.
|
||||
```shell
|
||||
|
||||
@@ -39,11 +39,11 @@ export default function handleRedirects(req, res, next) {
|
||||
let redirect = req.path
|
||||
let queryParams = req._parsedUrl.query
|
||||
|
||||
// If process.env.ELASTICSEARCH_URL isn't set, you can't go to the
|
||||
// If process.env.ENABLE_SEARCH_RESULTS_PAGE isn't set, you can't go to the
|
||||
// dedicated search results page.
|
||||
// If that's the case, use the "old redirect" where all it does is
|
||||
// "correcting" the old query string 'q' to 'query'.
|
||||
if (!process.env.ELASTICSEARCH_URL && 'q' in req.query && !('query' in req.query)) {
|
||||
if (!process.env.ENABLE_SEARCH_RESULTS_PAGE && 'q' in req.query && !('query' in req.query)) {
|
||||
// update old-style query params (#9467)
|
||||
const newQueryParams = new URLSearchParams(queryParams)
|
||||
newQueryParams.set('query', newQueryParams.get('q'))
|
||||
@@ -51,19 +51,19 @@ export default function handleRedirects(req, res, next) {
|
||||
return res.redirect(301, `${req.path}?${newQueryParams.toString()}`)
|
||||
}
|
||||
|
||||
// If process.env.ELASTICSEARCH_URL is set, the dedicated search
|
||||
// If process.env.ENABLE_SEARCH_RESULTS_PAGE is set, the dedicated search
|
||||
// result page is ready. If that's the case, we can redirect to
|
||||
// `/$locale/search?query=...` from `/foo/bar?query=...` or from
|
||||
// (the old style) `/foo/bar/?q=...`
|
||||
if (
|
||||
process.env.ELASTICSEARCH_URL &&
|
||||
process.env.ENABLE_SEARCH_RESULTS_PAGE &&
|
||||
('q' in req.query ||
|
||||
('query' in req.query &&
|
||||
!(req.path.endsWith('/search') || req.path.startsWith('/api/search'))))
|
||||
) {
|
||||
// If you had the old legacy format of /some/uri?q=stuff
|
||||
// it needs to redirect to /en/search?query=stuff or
|
||||
// /some/uri?query=stuff depending on if ELASTICSEARCH_URL has been
|
||||
// /some/uri?query=stuff depending on if ENABLE_SEARCH_RESULTS_PAGE has been
|
||||
// set up.
|
||||
// If you have the new format of /some/uri?query=stuff it too needs
|
||||
// to redirect to /en/search?query=stuff
|
||||
|
||||
@@ -26,7 +26,10 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
|
||||
// So if that's the case, which might be true in production (Aug 2022)
|
||||
// or on an engineers local development, we basically pretend the
|
||||
// page doesn't exist.
|
||||
if (!process.env.ELASTICSEARCH_URL) {
|
||||
// By depending conditionally on these two environment variables we're
|
||||
// able to carefully launch the dedicated search results page
|
||||
// separately from the JSON API endpoint.
|
||||
if (!process.env.ELASTICSEARCH_URL || !process.env.ENABLE_SEARCH_RESULTS_PAGE) {
|
||||
return { notFound: true }
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,13 @@ const runningActionsOnInternalRepo =
|
||||
export const testViaActionsOnly = runningActionsOnInternalRepo ? test : test.skip
|
||||
export const describeViaActionsOnly = runningActionsOnInternalRepo ? describe : describe.skip
|
||||
export const describeIfElasticsearchURL = process.env.ELASTICSEARCH_URL ? describe : describe.skip
|
||||
export const describeIfDedicatedSearchResultsPage = process.env.ENABLE_SEARCH_RESULTS_PAGE
|
||||
? describe
|
||||
: describe.skip
|
||||
|
||||
export default {
|
||||
testViaActionsOnly,
|
||||
describeViaActionsOnly,
|
||||
describeIfElasticsearchURL,
|
||||
describeIfDedicatedSearchResultsPage,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { expect, jest } from '@jest/globals'
|
||||
|
||||
import { getDOM } from '../helpers/e2etest.js'
|
||||
import { describeIfDedicatedSearchResultsPage } from '../helpers/conditional-runs.js'
|
||||
|
||||
describe('search results page', () => {
|
||||
describeIfDedicatedSearchResultsPage('search results page', () => {
|
||||
jest.setTimeout(5 * 60 * 1000)
|
||||
|
||||
test('says something if no query is provided', async () => {
|
||||
|
||||
@@ -16,7 +16,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
// dedicated search results page works.
|
||||
// In a near future, we won't be needing this and assume it's always
|
||||
// true.
|
||||
const USE_DEDICATED_SEARCH_RESULTS_PAGE = Boolean(process.env.ELASTICSEARCH_URL)
|
||||
const USE_DEDICATED_SEARCH_RESULTS_PAGE = Boolean(
|
||||
JSON.parse(process.env.ENABLE_SEARCH_RESULTS_PAGE || 'false')
|
||||
)
|
||||
|
||||
describe('redirects', () => {
|
||||
jest.setTimeout(5 * 60 * 1000)
|
||||
|
||||
Reference in New Issue
Block a user