Skip to content

Commit e090ff7

Browse files
authored
Merge branch 'main' into broken-link-report-workflow-tweaks
2 parents 2d8b816 + 8f0093c commit e090ff7

250 files changed

Lines changed: 2341892 additions & 1859 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs')
4+
const core = require('@actions/core')
5+
const eventPayload = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'))
6+
7+
// This workflow-run script does the following:
8+
// 1. Gets an array of labels on a PR.
9+
// 2. Finds one with the relevant Algolia text; if none found, exits early.
10+
// 3. Gets the version substring from the label string.
11+
12+
const labelText = 'sync-english-index-for-'
13+
const labelsArray = eventPayload.pull_request.labels
14+
15+
// Exit early if no labels are on this PR
16+
if (!(labelsArray && labelsArray.length)) {
17+
process.exit(0)
18+
}
19+
20+
// Find the relevant label
21+
const algoliaLabel = labelsArray
22+
.map(label => label.name)
23+
.find(label => label.startsWith(labelText))
24+
25+
// Exit early if no relevant label is found
26+
if (!algoliaLabel) {
27+
process.exit(0)
28+
}
29+
30+
// Given: sync-english-index-for-enterprise-server@3.0
31+
// Returns: enterprise-server@3.0
32+
const versionToSync = algoliaLabel.split(labelText)[1]
33+
34+
// Store the version so we can access it later in the workflow
35+
core.setOutput('versionToSync', versionToSync)
36+
process.exit(0)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs')
4+
const path = require('path')
5+
const { execSync } = require('child_process')
6+
const semver = require('semver')
7+
8+
/*
9+
* This script performs two checks to prevent shipping development mode OpenAPI schemas:
10+
* - Ensures the `info.version` property is a semantic version.
11+
* In development mode, the `info.version` property is a string
12+
* containing the `github/github` branch name.
13+
* - Ensures the decorated schema matches the dereferenced schema.
14+
* The workflow that calls this script runs `script/rest/update-files.js`
15+
* with the `--decorate-only` switch then checks to see if files changed.
16+
*
17+
*/
18+
19+
// Check that the `info.version` property is a semantic version
20+
const dereferencedDir = path.join(process.cwd(), 'lib/rest/static/dereferenced')
21+
const schemas = fs.readdirSync(dereferencedDir)
22+
schemas.forEach(filename => {
23+
const schema = require(path.join(dereferencedDir, filename))
24+
if (!semver.valid(schema.info.version)) {
25+
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. 🛑`)
26+
process.exit(1)
27+
}
28+
})
29+
30+
// Check that the decorated schema matches the dereferenced schema
31+
const changedFiles = execSync('git diff --name-only HEAD').toString()
32+
33+
if(changedFiles !== '') {
34+
console.log(`These files were changed:\n${changedFiles}`)
35+
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'. 🛑`)
36+
process.exit(1)
37+
}
38+
39+
// All checks pass, ready to ship
40+
console.log('All good 👍')
41+
process.exit(0)

.github/allowed-actions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ module.exports = [
3131
'repo-sync/github-sync@3832fe8e2be32372e1b3970bbae8e7079edeec88',
3232
'repo-sync/pull-request@33777245b1aace1a58c87a29c90321aa7a74bd7d',
3333
'rtCamp/action-slack-notify@e17352feaf9aee300bf0ebc1dfbf467d80438815',
34-
'tjenkinson/gh-action-auto-merge-dependency-updates@cee2ac0'
34+
'tjenkinson/gh-action-auto-merge-dependency-updates@cee2ac0',
35+
'EndBug/add-and-commit@9358097a71ad9fb9e2f9624c6098c89193d83575'
3536
]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: OpenAPI generate decorated schema files
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened]
7+
8+
jobs:
9+
generate-decorated-files:
10+
if: github.event.pull_request.user.login == 'github-openapi-bot'
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository code
14+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
15+
16+
- name: Install dependencies
17+
run: npm ci
18+
19+
- name: Decorate the dereferenced OpenAPI schemas
20+
run: script/rest/update-files.js --decorate-only
21+
22+
- name: Check in the decorated files
23+
uses: EndBug/add-and-commit@9358097a71ad9fb9e2f9624c6098c89193d83575
24+
with:
25+
# The arguments for the `git add` command
26+
add: 'lib/rest/static/decorated'
27+
28+
# The message for the commit
29+
message: 'Add decorated OpenAPI schema files'
30+
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: OpenAPI dev mode check
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
jobs:
8+
check-schema-versions:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository code
12+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
13+
14+
- name: Install dependencies
15+
run: npm ci
16+
17+
# Differences between decorated and dereferenced files indicates a problem
18+
- name: Generate decorated files to check that there are no differences
19+
run: script/rest/update-files.js --decorate-only
20+
21+
- name: Check if deref/decorated schemas are dev mode and that they match
22+
run: .github/actions-scripts/openapi-schema-branch.js
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Algolia Sync Single English Index
2+
3+
on:
4+
pull_request:
5+
types:
6+
- labeled
7+
- unlabeled
8+
- opened
9+
- reopened
10+
- synchronize
11+
- ready_for_review
12+
- unlocked
13+
14+
# This workflow requires a label in the format `sync-english-index-for-<PLAN@RELEASE>`
15+
jobs:
16+
updateIndices:
17+
name: Update English index for single version based on a label's version
18+
if: github.repository == 'github/docs-internal'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: checkout
22+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
23+
- uses: actions/setup-node@56899e050abffc08c2b3b61f3ec6a79a9dc3223d
24+
with:
25+
node-version: 14.x
26+
- name: cache node modules
27+
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a
28+
with:
29+
path: ~/.npm
30+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
31+
restore-keys: |
32+
${{ runner.os }}-node-
33+
- name: npm ci
34+
run: npm ci
35+
- name: Get version from Algolia label if present; only continue if the label is found.
36+
id: getVersion
37+
run: $GITHUB_WORKSPACE/.github/actions-scripts/enterprise-algolia-label.js
38+
- if: ${{ steps.getVersion.outputs.versionToSync }}
39+
name: Sync English index for single version
40+
env:
41+
VERSION: ${{ steps.getVersion.outputs.versionToSync }}
42+
LANGUAGE: 'en'
43+
ALGOLIA_APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
44+
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
run: npm run sync-search

content/actions/guides/building-and-testing-java-with-gradle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ steps:
9191

9292
### Caching dependencies
9393

94-
You can cache your dependencies to speed up your workflow runs. After a successful run, your local Gradle package cache will be stored on GitHub Actions infrastructure. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote package repositories. For more information, see "[Caching dependencies to speed up workflows](/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows)" and the [`cache` action](https://github.com/marketplace/actions/cache).
94+
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache your dependencies to speed up your workflow runs. After a successful run, your local Gradle package cache will be stored on GitHub Actions infrastructure. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote package repositories. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>" and the [`cache` action](https://github.com/marketplace/actions/cache).
9595

9696
{% raw %}
9797
```yaml

content/actions/guides/building-and-testing-java-with-maven.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ steps:
9191

9292
### Caching dependencies
9393

94-
You can cache your dependencies to speed up your workflow runs. After a successful run, your local Maven repository will be stored on GitHub Actions infrastructure. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote Maven repositories. For more information, see "[Caching dependencies to speed up workflows](/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows)" and the [`cache` action](https://github.com/marketplace/actions/cache).
94+
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache your dependencies to speed up your workflow runs. After a successful run, your local Maven repository will be stored on GitHub Actions infrastructure. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote Maven repositories. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>" and the [`cache` action](https://github.com/marketplace/actions/cache).
9595

9696
{% raw %}
9797
```yaml

content/actions/guides/building-and-testing-nodejs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ If you don't specify a Node.js version, {% data variables.product.prodname_dotco
129129
130130
{% data variables.product.prodname_dotcom %}-hosted runners have npm and Yarn dependency managers installed. You can use npm and Yarn to install dependencies in your workflow before building and testing your code. The Windows and Linux {% data variables.product.prodname_dotcom %}-hosted runners also have Grunt, Gulp, and Bower installed.
131131
132-
You can also cache dependencies to speed up your workflow. For more information, see "[Caching dependencies to speed up your workflow](/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows)."
132+
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can also cache dependencies to speed up your workflow. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>."
133133
134134
#### Example using npm
135135
@@ -227,7 +227,7 @@ always-auth=true
227227

228228
#### Example caching dependencies
229229

230-
You can cache dependencies using a unique key, and restore the dependencies when you run future workflows using the `cache` action. For more information, see "[Caching dependencies to speed up workflows](/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows)" and the [`cache` action](https://github.com/marketplace/actions/cache).
230+
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache dependencies using a unique key, and restore the dependencies when you run future workflows using the `cache` action. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>" and the [`cache` action](https://github.com/marketplace/actions/cache).
231231

232232
{% raw %}
233233
```yaml
@@ -241,7 +241,7 @@ steps:
241241
uses: actions/cache@v2
242242
with:
243243
# npm cache files are stored in `~/.npm` on Linux/macOS
244-
path: ~/.npm
244+
path: ~/.npm
245245
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
246246
restore-keys: |
247247
${{ runner.OS }}-node-

content/actions/guides/building-and-testing-powershell.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ We recommend that you have a basic understanding of PowerShell and Pester. For m
3030

3131
### Adding a workflow for Pester
3232

33-
To automate your testing with PowerShell and Pester, you can add a workflow that runs every time a change is pushed to your repository. In the following example, `Test-Path` is used to check that a file called `resultsfile.log` is present.
33+
To automate your testing with PowerShell and Pester, you can add a workflow that runs every time a change is pushed to your repository. In the following example, `Test-Path` is used to check that a file called `resultsfile.log` is present.
3434

3535
This example workflow file must be added to your repository's `.github/workflows/` directory:
3636

@@ -57,7 +57,7 @@ jobs:
5757
{% endraw %}
5858
5959
* `shell: pwsh` - Configures the job to use PowerShell when running the `run` commands.
60-
* `run: Test-Path resultsfile.log` - Check whether a file called `resultsfile.log` is present in the repository's root directory.
60+
* `run: Test-Path resultsfile.log` - Check whether a file called `resultsfile.log` is present in the repository's root directory.
6161
* `Should -Be $true` - Uses Pester to define an expected result. If the result is unexpected, then {% data variables.product.prodname_actions %} flags this as a failed test. For example:
6262

6363
![Failed Pester test](/assets/images/help/repository/actions-failed-pester-test.png)
@@ -83,15 +83,15 @@ The table below describes the locations for various PowerShell modules in each {
8383
8484
### Installing dependencies
8585
86-
{% data variables.product.prodname_dotcom %}-hosted runners have PowerShell 7 and Pester installed. You can use `Install-Module` to install additional dependencies from the PowerShell Gallery before building and testing your code.
86+
{% data variables.product.prodname_dotcom %}-hosted runners have PowerShell 7 and Pester installed. You can use `Install-Module` to install additional dependencies from the PowerShell Gallery before building and testing your code.
8787
8888
{% note %}
8989
9090
**Note:** The pre-installed packages (such as Pester) used by {% data variables.product.prodname_dotcom %}-hosted runners are regularly updated, and can introduce significant changes. As a result, it is recommended that you always specify the required package versions by using `Install-Module` with `-MaximumVersion`.
9191
9292
{% endnote %}
9393
94-
You can also cache dependencies to speed up your workflow. For more information, see "[Caching dependencies to speed up your workflow](/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows)."
94+
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can also cache dependencies to speed up your workflow. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>."
9595
9696
For example, the following job installs the `SqlServer` and `PSScriptAnalyzer` modules:
9797
@@ -119,7 +119,7 @@ jobs:
119119

120120
#### Caching dependencies
121121

122-
You can cache PowerShell dependencies using a unique key, which allows you to restore the dependencies for future workflows with the [`cache`](https://github.com/marketplace/actions/cache) action. For more information, see "[Caching dependencies to speed up workflows](/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows)."
122+
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache PowerShell dependencies using a unique key, which allows you to restore the dependencies for future workflows with the [`cache`](https://github.com/marketplace/actions/cache) action. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>."
123123

124124
PowerShell caches its dependencies in different locations, depending on the runner's operating system. For example, the `path` location used in the following Ubuntu example will be different for a Windows operating system.
125125

0 commit comments

Comments
 (0)