From a5afcbbf3802a2e4466faf63d5627cd050f98b83 Mon Sep 17 00:00:00 2001 From: Annelisa Stephan Date: Thu, 1 Sep 2022 08:26:24 -0700 Subject: [PATCH 1/3] Update Git command to work with earlier versions --- .../adding-locally-hosted-code-to-github.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md b/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md index 30a25ec8ae..eb649b3f6c 100644 --- a/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md +++ b/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md @@ -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 From 90b754fe3c000ea0dda428ea9106c97a9eecde23 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 6 Sep 2022 19:05:22 +0200 Subject: [PATCH 2/3] Test JSON API without enabling dedicated search results page (#30542) --- .github/workflows/test.yml | 3 +++ middleware/redirects/handle-redirects.js | 10 +++++----- pages/search.tsx | 5 ++++- tests/helpers/conditional-runs.js | 4 ++++ tests/rendering/search.js | 3 ++- tests/routing/redirects.js | 4 +++- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b46f29bbda..0d6db808d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: diff --git a/middleware/redirects/handle-redirects.js b/middleware/redirects/handle-redirects.js index 3395554e6a..48eea18472 100644 --- a/middleware/redirects/handle-redirects.js +++ b/middleware/redirects/handle-redirects.js @@ -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 diff --git a/pages/search.tsx b/pages/search.tsx index fa6281d615..67703ae44b 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -26,7 +26,10 @@ export const getServerSideProps: GetServerSideProps = 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 } } diff --git a/tests/helpers/conditional-runs.js b/tests/helpers/conditional-runs.js index da762a1397..2e1951358b 100644 --- a/tests/helpers/conditional-runs.js +++ b/tests/helpers/conditional-runs.js @@ -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, } diff --git a/tests/rendering/search.js b/tests/rendering/search.js index eafe42ee75..c2b4899293 100644 --- a/tests/rendering/search.js +++ b/tests/rendering/search.js @@ -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 () => { diff --git a/tests/routing/redirects.js b/tests/routing/redirects.js index 47a5e12f60..cd4e4baa9a 100644 --- a/tests/routing/redirects.js +++ b/tests/routing/redirects.js @@ -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) From f07866da27a405391cbc72db36ea447731fd9f55 Mon Sep 17 00:00:00 2001 From: Matt Pollard Date: Tue, 6 Sep 2022 19:12:52 +0200 Subject: [PATCH 3/3] Correct script's filename in checklist for GitHub Enterprise Server releases' technical steps (#30522) --- .../enterprise-server-issue-templates/release-issue.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions-scripts/enterprise-server-issue-templates/release-issue.md b/.github/actions-scripts/enterprise-server-issue-templates/release-issue.md index 304d3dba00..906f803700 100644 --- a/.github/actions-scripts/enterprise-server-issue-templates/release-issue.md +++ b/.github/actions-scripts/enterprise-server-issue-templates/release-issue.md @@ -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: