Repository navigation
175 lines (152 loc) · 6.49 KB
/
Copy pathtest.yml
File metadata and controls
175 lines (152 loc) · 6.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Test
# Runs required test suites before merge. src/tests/SUITES.md explains coverage and merge risk.
on:
workflow_dispatch:
merge_group:
pull_request:
permissions:
contents: read
pull-requests: read
# Cancel older test runs for the same ref so newer commits get the runner.
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
env:
# ELASTICSEARCH_URL enables Vitest suites that send real search queries.
ELASTICSEARCH_URL: http://localhost:9200/
jobs:
test:
name: ${{ matrix.name }}
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
# Add new matrix suites to branch protection required checks too.
name:
# Lists every src directory. Commented-out entries have no suite-specific tests.
# - app
- archives
- article-api
- assets
- audit-logs
- automated-pipelines
# - codeql-cli # Enable when the broken scratch test is removed.
# - codeql-queries
- color-schemes
- content-linter
# - content-pipelines
- content-render
- data-directory
# - deployments
# - dev-toc
- early-access
# - eslint-rules
- events
- fixtures
- frame
- ghes-releases
- github-apps
- graphql
- journeys
- landings
- languages
- links
- observability
# - pages
- products
- redirects
- release-notes
- rest
- search
- secret-scanning
- shielding
# - tests
# - tools
# - types
- versions
- webhooks
- workflows
# The languages suite only runs on docs-internal.
isPrivateRepo:
- ${{ github.repository == 'github/docs-internal' }}
exclude:
- name: languages
isPrivateRepo: false
env:
# These suites make no HTTP requests, so they skip the Next.js build and test server.
# A suite that adds an HTTP test fails with a connection error until it's removed from this list.
START_VITEST_SERVER: ${{ contains(fromJSON('["color-schemes", "content-linter", "data-directory", "ghes-releases", "journeys", "links", "observability", "products", "workflows"]'), matrix.name) && 'false' || 'true' }}
steps:
# Repeat each if on its step so skipped work still leaves the required check present.
- name: Check out repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
# Fetch 2 commits so tj-actions/changed-files can diff without extra API calls
fetch-depth: 2
# Start Elasticsearch early so the pull and boot overlap with setup and build.
- uses: ./.github/actions/setup-elasticsearch
if: ${{ matrix.name == 'search' || matrix.name == 'languages' }}
with:
mode: start
- uses: ./.github/actions/node-npm-setup
- uses: ./.github/actions/get-docs-early-access
if: ${{ github.repository == 'github/docs-internal' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
- name: Check the test fixture data (if applicable)
if: ${{ matrix.name == 'fixtures' }}
run: npm run copy-fixture-data -- --check
- name: Check the test fixture content (if applicable)
if: ${{ matrix.name == 'fixtures' }}
env:
ROOT: src/fixtures/fixtures
run: |
# A failure means fixture content has stale internal links the dry run can update.
npm run update-internal-links -- --dry-run --check --strict \
src/fixtures/fixtures/content \
--exclude src/fixtures/fixtures/content/get-started/foo/typo-autotitling.md \
--exclude src/fixtures/fixtures/content/get-started/foo/anchor-autotitling.md
npm run update-internal-links -- --dry-run --check --strict \
src/fixtures/fixtures/data
- name: Clone all translations
if: ${{ matrix.name == 'languages' }}
uses: ./.github/actions/clone-translations
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
- name: Gather files changed
if: ${{ matrix.name == 'content-linter' }}
id: changed_files
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
- name: Write changed files to diff file
if: ${{ matrix.name == 'content-linter' }}
run: echo "${{ steps.changed_files.outputs.all_modified_files }}" > get_diff_files.txt
- uses: ./.github/actions/cache-nextjs
if: ${{ env.START_VITEST_SERVER != 'false' }}
- name: Run build script
if: ${{ env.START_VITEST_SERVER != 'false' }}
run: npm run build
- uses: ./.github/actions/warmup-remotejson-cache
# Only routing tests cover archived enterprise server URLs.
if: ${{ matrix.name == 'redirects' }}
- uses: ./.github/actions/setup-elasticsearch
if: ${{ matrix.name == 'search' || matrix.name == 'languages' }}
with:
mode: wait
- name: Index fixtures into the local Elasticsearch
# Run indexing only for suites that query the local Elasticsearch service.
if: ${{ matrix.name == 'search' || matrix.name == 'languages' }}
run: npm run index-test-fixtures
- name: Run tests
env:
DIFF_FILE: get_diff_files.txt
CHANGELOG_CACHE_FILE_PATH: src/fixtures/fixtures/changelog-feed.json
# NODE_ENV=test forces English-only tests; the languages suite needs every language.
ENABLED_LANGUAGES: ${{ matrix.name == 'languages' && 'all' || '' }}
ROOT: ${{ (matrix.name == 'fixtures' || matrix.name == 'article-api' || matrix.name == 'landings' ) && 'src/fixtures/fixtures' || '' }}
TRANSLATIONS_FIXTURE_ROOT: ${{ (matrix.name == 'fixtures' || matrix.name == 'article-api') && 'src/fixtures/fixtures/translations' || '' }}
# RUNNER_DEBUG enables timing and path logs when Actions reruns jobs with debug logging.
RUNNER_DEBUG: ${{ runner.debug }}
VITEST_FLAGS: ${{ matrix.name == 'article-api' && '--no-file-parallelism --maxWorkers=1' || '' }}
run: npm test -- $VITEST_FLAGS src/${{ matrix.name }}/tests/