Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo sync #568

Merged
merged 3 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/admin/enterprise-management/upgrade-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ versions:

### Recommendations

- Include as few upgrades as possible in your upgrade process. For example, instead of upgrading from {% data variables.product.prodname_enterprise %} {{ enterpriseVersions.supported[2] }} to {{ enterpriseVersions.supported[1] }} to {{ enterpriseVersions.latest }}, you could upgrade from {% data variables.product.prodname_enterprise %} {{ enterpriseVersions.supported[2] }} to {{ enterpriseVersions.latest }}.
- Include as few upgrades as possible in your upgrade process. For example, instead of upgrading from {% data variables.product.prodname_enterprise %} {{ enterpriseServerReleases.supported[2] }} to {{ enterpriseServerReleases.supported[1] }} to {{ enterpriseServerReleases.latest }}, you could upgrade from {% data variables.product.prodname_enterprise %} {{ enterpriseServerReleases.supported[2] }} to {{ enterpriseServerReleases.latest }}.
- If you’re several versions behind, upgrade {% data variables.product.product_location_enterprise %} as far forward as possible with each step of your upgrade process. Using the latest version possible on each upgrade allows you to take advantage of performance improvements and bug fixes. For example, you could upgrade from {% data variables.product.prodname_enterprise %} 2.7 to 2.8 to 2.10, but upgrading from {% data variables.product.prodname_enterprise %} 2.7 to 2.9 to 2.10 uses a later version in the second step.
- Use the latest patch release when upgrading. {% data reusables.enterprise_installation.enterprise-download-upgrade-pkg %}
- Use a staging instance to test the upgrade steps. For more information, see "[Setting up a staging instance](/enterprise/{{ currentVersion }}/admin/guides/installation/setting-up-a-staging-instance/)."
- When running multiple upgrades, wait at least 24 hours between feature upgrades to allow data migrations and backgrounded upgrade tasks to fully complete.

### Requirements

- You must upgrade from a feature release that's **at most** two releases behind. For example, to upgrade to {% data variables.product.prodname_enterprise %} {{ enterpriseVersions.latest }}, you must be on {% data variables.product.prodname_enterprise %} {{ enterpriseVersions.supported[1] }} or {{ enterpriseVersions.supported[2] }}.
- You must upgrade from a feature release that's **at most** two releases behind. For example, to upgrade to {% data variables.product.prodname_enterprise %} {{ enterpriseServerReleases.latest }}, you must be on {% data variables.product.prodname_enterprise %} {{ enterpriseServerReleases.supported[1] }} or {{ enterpriseServerReleases.supported[2] }}.
- {% data reusables.enterprise_installation.hotpatching-explanation %}
- A hotpatch may require downtime if the affected services (like kernel, MySQL, or Elasticsearch) require a VM reboot or a service restart. You'll be notified when a reboot or restart is required. You can complete the reboot or restart at a later time.
- Additional root storage must be available when upgrading through hotpatching, as it installs multiple versions of certain services until the upgrade is complete. Pre-flight checks will notify you if you don't have enough root disk storage.
Expand Down
4 changes: 2 additions & 2 deletions includes/error-404-deprecation-message.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if enterpriseVersions.deprecated contains currentVersion %}
{% assign deprecatedDate = enterpriseVersions.dates[currentVersion].deprecationDate %}
{% if enterpriseServerReleases.deprecated contains currentVersion %}
{% assign deprecatedDate = enterpriseServerReleases.dates[currentVersion].deprecationDate %}
<div class="deprecation-banner border rounded-1 mb-2 bg-yellow-light p-3 border-yellow f5">
<p>
<b>
Expand Down
2 changes: 1 addition & 1 deletion middleware/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ module.exports = async function contextualize (req, res, next) {
req.context.query = req.query
req.context.languages = languages
req.context.earlyAccessPaths = earlyAccessPaths
req.context.enterpriseVersions = enterpriseServerReleases
req.context.productNames = productNames
req.context.enterpriseServerReleases = enterpriseServerReleases
req.context.enterpriseServerVersions = Object.keys(allVersions).filter(version => version.startsWith('enterprise-server@'))
req.context.redirects = redirects
req.context.site = site[req.language].site
req.context.siteTree = siteTree
Expand Down
77 changes: 77 additions & 0 deletions script/new-versioning/update-not-fpt-conditionals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env node

const fs = require('fs')
const path = require('path')
const walk = require('walk-sync')
const frontmatter = require('@github-docs/frontmatter')
const contentPath = path.join(process.cwd(), 'content')
const dataPath = path.join(process.cwd(), 'data')

// [start-readme]
//
// Run this script to update these Liquid conditionals:
//
// {% if currentVersion != 'free-pro-team@latest' %}
//
// to:
//
// {% if enterpriseServerVersions contains currentVersion %}
//
// [end-readme]

// The new conditional to add
const newConditional = 'enterpriseServerVersions contains currentVersion'

// The old conditional to replace
const oldConditional = /currentVersion != ["']free-pro-team@latest["']/g

console.log('Working...\n')

const englishContentFiles = walkContent(contentPath)
const englishDataFiles = walkData(dataPath, englishContentFiles)

function walkContent (dirPath) {
return walk(dirPath, { includeBasePath: true, directories: false })
.filter(file => file.includes('/content/'))
.filter(file => file.endsWith('.md'))
.filter(file => !file.endsWith('README.md'))
}

function walkData (dirPath, contentFiles) {
return walk(dirPath, { includeBasePath: true, directories: false })
.filter(file => file.includes('/data/reusables') || file.includes('/data/variables'))
.filter(file => !file.endsWith('README.md'))
}

englishDataFiles
.forEach(file => {
const dataContent = fs.readFileSync(file, 'utf8')

// Update Liquid in data files
const newDataContent = updateLiquid(dataContent, file)

fs.writeFileSync(file, newDataContent)
})

englishContentFiles
.forEach(file => {
const { data, content } = frontmatter(fs.readFileSync(file, 'utf8'))

// Update Liquid in content files
const newContent = updateLiquid(content, file)

// Update Liquid in frontmatter props
Object.keys(data)
.filter(key => typeof data[key] === 'string')
.forEach(key => {
data[key] = updateLiquid(data[key], file)
})

fs.writeFileSync(file, frontmatter.stringify(newContent, data, { lineWidth: 10000 }))
})

function updateLiquid (content) {
return content.replace(oldConditional, newConditional)
}

console.log('Done!')
19 changes: 19 additions & 0 deletions tests/fixtures/page-versioned-for-all-enterprise-releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Page versioned for all Enterprise releases
versions:
free-pro-team: '*'
enterprise-server: '*'
---

{% if currentVersion == 'free-pro-team@latest' %}

This text should only render on non-Enterprise

{% endif %}


{% if enterpriseServerVersions contains currentVersion %}

This text should render on any actively supported version of Enterprise Server

{% endif %}
38 changes: 38 additions & 0 deletions tests/unit/page.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path')
const cheerio = require('cheerio')
const Page = require('../../lib/page')
const allVersionIds = Object.keys(require('../../lib/all-versions'))
const enterpriseServerReleases = require('../../lib/enterprise-server-releases')
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
// get the `free-pro-team` segment of `free-pro-team@latest`
Expand Down Expand Up @@ -121,6 +122,43 @@ describe('Page class', () => {
const $ = cheerio.load(rendered)
expect($('a[href="/capistrano"]').length).toBe(1)
})

// Most of our Liquid versioning tests are in https://github.com/docs/render-content,
// But they don't have access to our currently supported versions, which we're testing here.
// This test ensures that this works as expected: {% if enterpriseServerVersions contains currentVersion %}
test('renders the expected Enterprise Server versioned content', async () => {
const page = new Page({
relativePath: 'page-versioned-for-all-enterprise-releases.md',
basePath: path.join(__dirname, '../fixtures'),
languageCode: 'en'
})
// set version to the latest enteprise version
const context = {
currentVersion: `enterprise-server@${enterpriseServerReleases.latest}`,
currentLanguage: 'en',
enterpriseServerVersions: allVersionIds.filter(id => id.startsWith('enterprise-server@'))
}
let rendered = await page.render(context)
let $ = cheerio.load(rendered)
expect($.text()).toBe('This text should render on any actively supported version of Enterprise Server')
expect($.text()).not.toBe('This text should only render on non-Enterprise')

// change version to the oldest enterprise version, re-render, and test again;
// the results should be the same
context.currentVersion = `enterprise-server@${enterpriseServerReleases.oldestSupported}`
rendered = await page.render(context)
$ = cheerio.load(rendered)
expect($.text()).toBe('This text should render on any actively supported version of Enterprise Server')
expect($.text()).not.toBe('This text should only render on non-Enterprise')

// change version to non-enterprise, re-render, and test again;
// the results should be the opposite
context.currentVersion = nonEnterpriseDefaultVersion
rendered = await page.render(context)
$ = cheerio.load(rendered)
expect($.text()).not.toBe('This text should render on any actively supported version of Enterprise Server')
expect($.text()).toBe('This text should only render on non-Enterprise')
})
})

test('preserves `languageCode`', () => {
Expand Down