Skip to content

Commit a97698f

Browse files
authored
Merge pull request #16773 from github/skip-early-access-tests
Run Early Access tests conditionally in CI
2 parents 48f0317 + 5b82f5e commit a97698f

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

middleware/contextualizers/early-access-links.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1+
const { uniq } = require('lodash')
2+
13
module.exports = function earlyAccessContext (req, res, next) {
24
if (process.env.NODE_ENV === 'production') {
35
return next(404)
46
}
57

68
// Get a list of all hidden pages per version
7-
const earlyAccessPageLinks = req.context.pages
9+
const earlyAccessPageLinks = uniq(Object.values(req.context.pages)
810
.filter(page => page.hidden)
911
// Do not include early access landing page
1012
.filter(page => page.relativePath !== 'early-access/index.md')
1113
// Create Markdown links
1214
.map(page => {
1315
return page.permalinks.map(permalink => `- [${permalink.title}](${permalink.href})`)
1416
})
15-
.flat()
17+
.flat())
1618
// Get links for the current version
1719
.filter(link => link.includes(req.context.currentVersion))
1820
.sort()

tests/helpers/conditional-runs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const runningActionsOnInternalRepo = process.env.GITHUB_ACTIONS === 'true' && process.env.GITHUB_REPOSITORY === 'github/docs-internal'
2+
3+
const testViaActionsOnly = runningActionsOnInternalRepo ? test : test.skip
4+
const describeViaActionsOnly = runningActionsOnInternalRepo ? describe : describe.skip
5+
6+
module.exports = {
7+
testViaActionsOnly,
8+
describeViaActionsOnly
9+
}

tests/rendering/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const lodash = require('lodash')
22
const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
33
const { get, getDOM, head } = require('../helpers/supertest')
4+
const { describeViaActionsOnly } = require('../helpers/conditional-runs')
45
const path = require('path')
56
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
67
const { loadPages } = require('../../lib/pages')
@@ -356,7 +357,7 @@ describe('server', () => {
356357
})
357358
})
358359

359-
describe.skip('Early Access articles', () => {
360+
describeViaActionsOnly('Early Access articles', () => {
360361
let hiddenPageHrefs, hiddenPages
361362

362363
beforeAll(async (done) => {

tests/unit/early-access.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
const fs = require('fs').promises
22
const path = require('path')
3-
4-
const { GITHUB_ACTIONS, GITHUB_REPOSITORY } = process.env
5-
const runningActionsOnInternalRepo = GITHUB_ACTIONS === 'true' && GITHUB_REPOSITORY === 'github/docs-internal'
6-
const testViaActionsOnly = runningActionsOnInternalRepo ? test : test.skip
3+
const { testViaActionsOnly } = require('../helpers/conditional-runs')
74

85
describe('cloning early-access', () => {
96
testViaActionsOnly('the content directory exists', async () => {

0 commit comments

Comments
 (0)