Skip to content

Commit

Permalink
Merge branch 'main' into patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
lecoursen authored Jul 16, 2021
2 parents b544c9f + 7887d02 commit e57a072
Show file tree
Hide file tree
Showing 415 changed files with 29,951 additions and 25,343 deletions.
39 changes: 15 additions & 24 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,40 @@ module.exports = {
browser: true,
commonjs: true,
es2020: true,
node: true
node: true,
},
parser: '@babel/eslint-parser',
extends: [
'eslint:recommended',
'standard',
'prettier'
],
extends: ['eslint:recommended', 'standard', 'prettier'],
parserOptions: {
ecmaVersion: 11
ecmaVersion: 11,
requireConfigFile: 'false',
babelOptions: { configFile: './.babelrc' },
},
rules: {
'import/no-extraneous-dependencies': ['error'],
'import/no-extraneous-dependencies': ['error', { packageDir: '.' }],
'node/global-require': ['error'],
'import/no-dynamic-require': ['error']
'import/no-dynamic-require': ['error'],
},
overrides: [
{
files: [
'**/tests/**/*.js'
],
files: ['**/tests/**/*.js'],
env: {
jest: true
}
jest: true,
},
},
{
files: [
'**/*.tsx', '**/*.ts'
],
plugins: [
'@typescript-eslint',
'jsx-a11y'
],
files: ['**/*.tsx', '**/*.ts'],
plugins: ['@typescript-eslint', 'jsx-a11y'],
extends: ['plugin:jsx-a11y/recommended'],
parser: '@typescript-eslint/parser',
rules: {
'camelcase': 'off',
camelcase: 'off',
'no-unused-vars': 'off',
'no-undef': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'jsx-a11y/no-onchange': 'off',
}
},
},
]
],
}
39 changes: 22 additions & 17 deletions .github/actions-scripts/check-for-enterprise-issues-by-label.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
#!/usr/bin/env node

const github = require('@actions/github')
const core = require('@actions/core')
import { getOctokit } from '@actions/github'
import { setOutput } from '@actions/core'

async function run () {
async function run() {
const token = process.env.GITHUB_TOKEN
const octokit = github.getOctokit(token)
const octokit = getOctokit(token)
const query = encodeURIComponent('is:open repo:github/docs-internal is:issue')

const deprecationIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20deprecation"`)
const releaseIssues = await octokit.request(`GET /search/issues?q=${query}+label:"enterprise%20release"`)

const deprecationIssues = await octokit.request(
`GET /search/issues?q=${query}+label:"enterprise%20deprecation"`
)
const releaseIssues = await octokit.request(
`GET /search/issues?q=${query}+label:"enterprise%20release"`
)
const isDeprecationIssue = deprecationIssues.data.items.length === 0 ? 'false' : 'true'
const isReleaseIssue = releaseIssues.data.items.length === 0 ? 'false' : 'true'
core.setOutput('deprecationIssue', isDeprecationIssue)
core.setOutput('releaseIssue', isReleaseIssue)
setOutput('deprecationIssue', isDeprecationIssue)
setOutput('releaseIssue', isReleaseIssue)
return `Set outputs deprecationIssue: ${isDeprecationIssue}, releaseIssue: ${isReleaseIssue}`
}

run()
.then(
(response) => { console.log(`Finished running: ${response}`) },
(error) => {
console.log(`#ERROR# ${error}`)
process.exit(1)
}
)
run().then(
(response) => {
console.log(`Finished running: ${response}`)
},
(error) => {
console.log(`#ERROR# ${error}`)
process.exit(1)
}
)
88 changes: 50 additions & 38 deletions .github/actions-scripts/create-enterprise-issue.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env node

const fs = require('fs')
const path = require('path')
const github = require('@actions/github')
const enterpriseDates = require('../../lib/enterprise-dates')
const { latest, oldestSupported } = require('../../lib/enterprise-server-releases')
import fs from 'fs'
import path from 'path'
import { getOctokit } from '@actions/github'
import enterpriseDates from '../../lib/enterprise-dates.js'
import { latest, oldestSupported } from '../../lib/enterprise-server-releases.js'

const acceptedMilestones = ['release', 'deprecation']
const teamsToCC = '/cc @github/docs-content @github/docs-engineering'

Expand All @@ -19,45 +20,46 @@ const numberOfdaysBeforeDeprecationToOpenIssue = 15
// number of days.
//
// When a milestone is within the specified number of days, a new issue is
// created using the templates in
// .github/actions-scripts/enterprise-server-issue-templates.
// created using the templates in
// .github/actions-scripts/enterprise-server-issue-templates.
//
// Release issues are then added to the docs content squad board for triage.
// Deprecations issues are owned by docs engineering and are added to the
// Deprecations issues are owned by docs engineering and are added to the
// docs engineering squad board automatically when the engineering label is added.
//
// [end-readme]

run()

async function run () {


async function run() {
const milestone = process.argv[2]
if (!acceptedMilestones.includes(milestone)) {
console.log('Please specify either \'release\' or \'deprecation\'\n')
console.log("Please specify either 'release' or 'deprecation'\n")
console.log('Example: script/open-enterprise-issue.js release')
process.exit(1)
}

// Milestone-dependent values.
const numberOfdaysBeforeMilestoneToOpenIssue = milestone === 'release'
? numberOfdaysBeforeReleaseToOpenIssue
: numberOfdaysBeforeDeprecationToOpenIssue
const numberOfdaysBeforeMilestoneToOpenIssue =
milestone === 'release'
? numberOfdaysBeforeReleaseToOpenIssue
: numberOfdaysBeforeDeprecationToOpenIssue

const versionNumber = milestone === 'release'
? getNextVersionNumber()
: oldestSupported
const versionNumber = milestone === 'release' ? getNextVersionNumber() : oldestSupported

if (!versionNumber) {
console.log(`Could not find the next version number after ${latest} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`)
console.log(
`Could not find the next version number after ${latest} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`
)
process.exit(0)
}

const datesForVersion = enterpriseDates[versionNumber]

if (!datesForVersion) {
console.log(`Could not find ${versionNumber} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`)
console.log(
`Could not find ${versionNumber} in enterprise-dates.json. Try running script/udpate-enterprise-dates.js, then rerun this script.`
)
process.exit(0)
}

Expand All @@ -66,11 +68,19 @@ async function run () {

// If the milestone is more than the specific days away, exit now.
if (daysUntilMilestone > numberOfdaysBeforeMilestoneToOpenIssue) {
console.log(`The ${versionNumber} ${milestone} is not until ${nextMilestoneDate}! An issue will be opened when it is ${numberOfdaysBeforeMilestoneToOpenIssue} days away.`)
console.log(
`The ${versionNumber} ${milestone} is not until ${nextMilestoneDate}! An issue will be opened when it is ${numberOfdaysBeforeMilestoneToOpenIssue} days away.`
)
process.exit(0)
}

const milestoneSteps = fs.readFileSync(path.join(process.cwd(), `.github/actions-scripts/enterprise-server-issue-templates/${milestone}-issue.md`), 'utf8')
const milestoneSteps = fs.readFileSync(
path.join(
process.cwd(),
`.github/actions-scripts/enterprise-server-issue-templates/${milestone}-issue.md`
),
'utf8'
)
const issueLabels = [`enterprise ${milestone}`, `engineering`]
const issueTitle = `[${nextMilestoneDate}] Enterprise Server ${versionNumber} ${milestone} (technical steps)`

Expand All @@ -81,68 +91,70 @@ async function run () {
const token = process.env.GITHUB_TOKEN

// Create the milestone issue
const octokit = github.getOctokit(token)
const octokit = getOctokit(token)
try {
issue = await octokit.request('POST /repos/{owner}/{repo}/issues', {
owner: 'github',
repo: 'docs-internal',
title: issueTitle,
body: issueBody,
labels: issueLabels
labels: issueLabels,
})
if (issue.status === 201) {
// Write the values to disk for use in the workflow.
console.log(`Issue #${issue.data.number} for the ${versionNumber} ${milestone} was opened: ${issue.data.html_url}`)
console.log(
`Issue #${issue.data.number} for the ${versionNumber} ${milestone} was opened: ${issue.data.html_url}`
)
}
} catch (error) {
console.error(`#ERROR# ${error}`)
console.log(`πŸ›‘ There was an error creating the issue.`)
process.exit(1)
}

// Add the release issue to the 'Needs triage' column on the
// Add the release issue to the 'Needs triage' column on the
// docs content squad project board:
// https://github.com/orgs/github/projects/1773#column-12198119
// Deprecation issues are owned by docs engineering only and will
// be triaged by adding the engineering label to the issue.
if (milestone === 'release') {
try {
const addCard = await octokit.request('POST /projects/columns/{column_id}/cards', {
column_id: 12198119,
column_id: 12198119,
content_id: issue.data.id,
content_type: 'Issue',
mediaType: {
previews: [
'inertia'
]
}
previews: ['inertia'],
},
})

if (addCard.status === 201) {
// Write the values to disk for use in the workflow.
console.log(`The issue #${issue.data.number} was added to https://github.com/orgs/github/projects/1773#column-12198119.`)
}
} catch(error) {
console.log(
`The issue #${issue.data.number} was added to https://github.com/orgs/github/projects/1773#column-12198119.`
)
}
} catch (error) {
console.error(`#ERROR# ${error}`)
console.log(`πŸ›‘ There was an error adding the issue to the project board.`)
process.exit(1)
}
}
}

function getNextVersionNumber () {
function getNextVersionNumber() {
const indexOfLatest = Object.keys(enterpriseDates).indexOf(latest)
const indexOfNext = indexOfLatest + 1
return Object.keys(enterpriseDates)[indexOfNext]
}

function calculateDaysUntilMilestone (nextMilestoneDate) {
function calculateDaysUntilMilestone(nextMilestoneDate) {
const today = new Date().toISOString().slice(0, 10)
const differenceInMilliseconds = getTime(nextMilestoneDate) - getTime(today)
// Return the difference in days
return Math.floor((differenceInMilliseconds) / (1000 * 60 * 60 * 24))
return Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24))
}

function getTime (date) {
function getTime(date) {
return new Date(date).getTime()
}
13 changes: 7 additions & 6 deletions .github/actions-scripts/enterprise-algolia-label.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node

const fs = require('fs')
const core = require('@actions/core')
import fs from 'fs'
import { setOutput } from '@actions/core'

const eventPayload = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'))

// This workflow-run script does the following:
Expand All @@ -19,8 +20,8 @@ if (!(labelsArray && labelsArray.length)) {

// Find the relevant label
const algoliaLabel = labelsArray
.map(label => label.name)
.find(label => label.startsWith(labelText))
.map((label) => label.name)
.find((label) => label.startsWith(labelText))

// Exit early if no relevant label is found
if (!algoliaLabel) {
Expand All @@ -32,5 +33,5 @@ if (!algoliaLabel) {
const versionToSync = algoliaLabel.split(labelText)[1]

// Store the version so we can access it later in the workflow
core.setOutput('versionToSync', versionToSync)
process.exit(0)
setOutput('versionToSync', versionToSync)
process.exit(0)
41 changes: 23 additions & 18 deletions .github/actions-scripts/openapi-schema-branch.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
#!/usr/bin/env node

const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
const semver = require('semver')
import fs from 'fs'
import path from 'path'
import { execSync } from 'child_process'
import semver from 'semver'

/*
* This script performs two checks to prevent shipping development mode OpenAPI schemas:
* - Ensures the `info.version` property is a semantic version.
* In development mode, the `info.version` property is a string
* containing the `github/github` branch name.
* - Ensures the decorated schema matches the dereferenced schema.
* The workflow that calls this script runs `script/rest/update-files.js`
* with the `--decorate-only` switch then checks to see if files changed.
*
*/
* - Ensures the `info.version` property is a semantic version.
* In development mode, the `info.version` property is a string
* containing the `github/github` branch name.
* - Ensures the decorated schema matches the dereferenced schema.
* The workflow that calls this script runs `script/rest/update-files.js`
* with the `--decorate-only` switch then checks to see if files changed.
*
*/

// Check that the `info.version` property is a semantic version
const dereferencedDir = path.join(process.cwd(), 'lib/rest/static/dereferenced')
const schemas = fs.readdirSync(dereferencedDir)
schemas.forEach(filename => {
const schema = require(path.join(dereferencedDir, filename))

schemas.forEach((filename) => {
const schema = JSON.parse(fs.readFileSync(path.join(dereferencedDir, filename)))
if (!semver.valid(schema.info.version)) {
console.log(`🚧⚠️ Your branch contains a development mode OpenAPI schema: ${schema.info.version}. This check is a reminder to not 🚒 OpenAPI files in development mode. πŸ›‘`)
console.log(
`🚧⚠️ Your branch contains a development mode OpenAPI schema: ${schema.info.version}. This check is a reminder to not 🚒 OpenAPI files in development mode. πŸ›‘`
)
process.exit(1)
}
})

// Check that the decorated schema matches the dereferenced schema
const changedFiles = execSync('git diff --name-only HEAD').toString()

if(changedFiles !== '') {
if (changedFiles !== '') {
console.log(`These files were changed:\n${changedFiles}`)
console.log(`🚧⚠️ Your decorated and dereferenced schema files don't match. Ensure you're using decorated and dereferenced schemas from the automatically created pull requests by the 'github-openapi-bot' user. For more information, see 'script/rest/README.md'. πŸ›‘`)
process.exit(1)
console.log(
`🚧⚠️ Your decorated and dereferenced schema files don't match. Ensure you're using decorated and dereferenced schemas from the automatically created pull requests by the 'github-openapi-bot' user. For more information, see 'script/rest/README.md'. πŸ›‘`
)
process.exit(1)
}

// All checks pass, ready to ship
Expand Down
Loading

0 comments on commit e57a072

Please sign in to comment.