Skip to content

Commit dacd766

Browse files
authored
Merge pull request #12101 from github/repo-sync
repo sync
2 parents de07e3c + 51109a1 commit dacd766

7 files changed

Lines changed: 78 additions & 6 deletions

File tree

.github/allowed-actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default [
1818
'dawidd6/action-download-artifact@af92a8455a59214b7b932932f2662fdefbd78126', // v2.15.0
1919
'docker://chinthakagodawita/autoupdate-action:v1',
2020
'dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58',
21+
'trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b', // v1.2.4
2122
'github/codeql-action/analyze@v1',
2223
'github/codeql-action/init@v1',
2324
'juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8',

.github/workflows/check-broken-links-github-github.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ jobs:
5959
#
6060
# https://docs.github.com/actions/reference/context-and-expression-syntax-for-github-actions#job-status-check-functions
6161

62-
- if: ${{ failure() }}
62+
- if: ${{ failure() && env.FREEZE != 'true' }}
6363
name: Get title for issue
6464
id: check
6565
run: echo "::set-output name=title::$(head -1 broken_github_github_links.md)"
66-
- if: ${{ failure() }}
66+
- if: ${{ failure() && env.FREEZE != 'true'}}
6767
name: Create issue from file
6868
id: github-github-broken-link-report
6969
uses: peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e

.github/workflows/enterprise-dates.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
branch: enterprise-server-dates-update
6969
delete-branch: true
7070

71-
- if: ${{ failure() }}
71+
- if: ${{ failure() && env.FREEZE != 'true' }}
7272
name: Delete remote branch (if previous steps failed)
7373
uses: dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911
7474
with:
@@ -84,7 +84,7 @@ jobs:
8484

8585
- name: Send Slack notification if workflow fails
8686
uses: someimportantcompany/github-actions-slack-message@f8d28715e7b8a4717047d23f48c39827cacad340
87-
if: failure()
87+
if: ${{ failure() && env.FREEZE != 'true' }}
8888
with:
8989
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
9090
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

.github/workflows/remove-unused-assets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
project: Core docs work for the current week
5959
project-column: Should do
6060
branch: remove-unused-assets
61-
- if: ${{ failure() }}
61+
- if: ${{ failure() && env.FREEZE != 'true' }}
6262
name: Delete remote branch (if previous steps failed)
6363
uses: dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911
6464
with:

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ jobs:
4646
# Enables cloning the Early Access repo later with the relevant PAT
4747
persist-credentials: 'false'
4848

49+
- name: Gather files changed
50+
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
51+
id: get_diff_files
52+
with:
53+
# So that `steps.get_diff_files.outputs.files` becomes
54+
# a string like `foo.js path/bar.md`
55+
output: ' '
56+
57+
- name: Insight into changed files
58+
run: |
59+
echo ${{ steps.get_diff_files.outputs.files }}
60+
4961
- name: Setup node
5062
uses: actions/setup-node@270253e841af726300e85d718a5f606959b2903c
5163
with:
@@ -67,4 +79,6 @@ jobs:
6779
run: npm run build
6880

6981
- name: Run tests
82+
env:
83+
DIFF_FILES: ${{ steps.get_diff_files.outputs.files }}
7084
run: npm run test tests/${{ matrix.test-group }}/

.github/workflows/update-graphql-files.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
number: ${{ steps.create-pull-request.outputs.pull-request-number }}
7676
- name: Send Slack notification if workflow fails
7777
uses: someimportantcompany/github-actions-slack-message@f8d28715e7b8a4717047d23f48c39827cacad340
78-
if: failure()
78+
if: ${{ failure() && env.FREEZE != 'true' }}
7979
with:
8080
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
8181
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}

tests/linting/lint-files.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,63 @@ function getContent(content) {
356356
return null
357357
}
358358

359+
// Filter out entries from an array like this:
360+
//
361+
// [
362+
// [relativePath, absolutePath],
363+
// ...
364+
// so it's only the files mentioned in the DIFF_FILES environment
365+
// variable, but only if it's set and present.
366+
367+
// Setting an environment varible called `DIFF_FILES` is optional.
368+
// But if and only if it's set, we will respect it.
369+
// And if it set, turn it into a cleaned up Set so it's made available
370+
// every time we use it.
371+
if (process.env.DIFF_FILES) {
372+
// Parse and turn that environment variable string into a set.
373+
// It's faster to do this once and then re-use over and over in the
374+
// .filter() later on.
375+
const only = new Set(
376+
// If the environment variable encodes all the names
377+
// with quotation marks, strip them.
378+
// E.g. Turn `"foo" "bar"` into ['foo', 'bar']
379+
// Note, this assumes no possible file contains a space.
380+
process.env.DIFF_FILES.split(/\s+/g).map((name) => {
381+
if (/^['"]/.test(name) && /['"]$/.test(name)) {
382+
return name.slice(1, -1)
383+
}
384+
return name
385+
})
386+
)
387+
const filterFiles = (tuples) =>
388+
tuples.filter(
389+
([relativePath, absolutePath]) => only.has(relativePath) || only.has(absolutePath)
390+
)
391+
mdToLint = filterFiles(mdToLint)
392+
ymlToLint = filterFiles(ymlToLint)
393+
ghesReleaseNotesToLint = filterFiles(ghesReleaseNotesToLint)
394+
ghaeReleaseNotesToLint = filterFiles(ghaeReleaseNotesToLint)
395+
learningTracksToLint = filterFiles(learningTracksToLint)
396+
featureVersionsToLint = filterFiles(featureVersionsToLint)
397+
}
398+
399+
if (
400+
mdToLint.length +
401+
ymlToLint.length +
402+
ghesReleaseNotesToLint.length +
403+
ghaeReleaseNotesToLint.length +
404+
learningTracksToLint.length +
405+
featureVersionsToLint.length <
406+
1
407+
) {
408+
// With this in place, at least one `test()` is called and you don't
409+
// get the `Your test suite must contain at least one test.` error
410+
// from `jest`.
411+
describe('deliberately do nothing', () => {
412+
test('void', () => {})
413+
})
414+
}
415+
359416
describe('lint markdown content', () => {
360417
if (mdToLint.length < 1) return
361418
describe.each(mdToLint)('%s', (markdownRelPath, markdownAbsPath) => {

0 commit comments

Comments
 (0)