Skip to content

Commit 17ec681

Browse files
heiskrhectorsector
andauthored
Test workflow: use plain matrix, creative exclude for languages (#42882)
Co-authored-by: Hector Alfaro <hectorsector@github.com>
1 parent f09a15a commit 17ec681

File tree

1 file changed

+59
-52
lines changed

1 file changed

+59
-52
lines changed

.github/workflows/test.yml

Lines changed: 59 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,66 +24,67 @@ env:
2424
ELASTICSEARCH_URL: http://localhost:9200/
2525

2626
jobs:
27-
figureOutMatrix:
28-
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
29-
runs-on: ubuntu-latest
30-
outputs:
31-
matrix: ${{ steps.set-matrix.outputs.result }}
32-
steps:
33-
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
34-
id: set-matrix
35-
with:
36-
script: |
37-
// We only want to run the 'languages' suite when we know
38-
// we're on the private docs-internal repo because only that
39-
// one has ability to clone the remote (private) languages
40-
// repos.
41-
// You can run multiple paths per suite as space-separated in `path`.
42-
// Note that *if you add* to this, remember to also add that
43-
// to the **required checks** in the branch protection rules.
44-
return [
45-
{ name: 'assets', path: 'src/assets/tests', },
46-
// { name: 'audit-logs', path: 'src/assets/audit-logs', },
47-
{ name: 'automated-pipelines', path: 'src/automated-pipelines/tests', },
48-
{ name: 'color-schemes', path: 'src/color-schemes/tests', },
49-
{ name: 'content', path: 'tests/content', },
50-
{ name: 'content-linter', path: 'src/content-linter/tests', },
51-
{ name: 'content-render', path: 'src/content-render/tests', },
52-
{ name: 'events', path: 'src/events/tests', },
53-
{ name: 'ghes-releases', path: 'src/ghes-releases/tests', },
54-
{ name: 'github-apps', path: 'src/github-apps/tests', },
55-
{ name: 'graphql', path: 'src/graphql/tests', },
56-
{ name: 'landings', path: 'src/landings/tests', },
57-
{ name: 'learning-track', path: 'src/learning-track/tests', },
58-
{ name: 'observability', path: 'src/observability/tests' },
59-
{ name: 'pageinfo', path: 'src/pageinfo/tests', },
60-
{ name: 'redirects', path: 'src/redirects/tests', },
61-
{ name: 'release-notes', path: 'src/release-notes/tests', },
62-
{ name: 'rendering', path: 'tests/rendering', },
63-
{ name: 'rendering-fixtures', path: 'tests/rendering-fixtures', },
64-
{ name: 'rest', path: 'src/rest/tests', },
65-
{ name: 'routing', path: 'tests/routing', },
66-
{ name: 'search', path: 'src/search/tests', },
67-
{ name: 'secret-scanning', path: 'src/secret-scanning/tests',},
68-
{ name: 'shielding', path: 'src/shielding/tests', },
69-
context.payload.repository.full_name === 'github/docs-internal' &&
70-
{ name: 'languages', path: 'src/languages/tests', },
71-
{ name: 'unit', path: 'tests/unit', },
72-
// { name: 'tools', path: 'src/tools/tests', }
73-
{ name: 'webhooks', path: 'src/webhooks/tests', },
74-
].filter(Boolean)
75-
7627
test:
7728
name: ${{ matrix.name }}
78-
needs: figureOutMatrix
29+
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
30+
7931
# Run on ubuntu-20.04-xl if the private repo or ubuntu-latest if the public repo
8032
# See pull # 17442 in the private repo for context
8133
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
8234
timeout-minutes: 60
8335
strategy:
8436
fail-fast: false
8537
matrix:
86-
include: ${{ fromJSON(needs.figureOutMatrix.outputs.matrix) }}
38+
# Note that *if you add* to this, remember to also add that
39+
# to the **required checks** in the branch protection rules.
40+
name:
41+
# tests/ directory
42+
- content
43+
- rendering
44+
- rendering-fixtures
45+
- routing
46+
- unit
47+
48+
# src/ directory
49+
- archives
50+
- assets
51+
# - audit-logs
52+
- automated-pipelines
53+
# - codeql-cli
54+
- color-schemes
55+
- content-linter
56+
- content-render
57+
- early-access
58+
- events
59+
# - frame
60+
- ghes-releases
61+
- github-apps
62+
- graphql
63+
- landings
64+
- languages
65+
- learning-track
66+
# - links
67+
- observability
68+
# - open-source
69+
- pageinfo
70+
# - pages
71+
- redirects
72+
- release-notes
73+
- rest
74+
- search
75+
- secret-scanning
76+
- shielding
77+
# - tools
78+
- versions
79+
- webhooks
80+
81+
# The languages suite only runs on docs-internal
82+
isPrivateRepo:
83+
- ${{ github.repository == 'github/docs-internal' }}
84+
exclude:
85+
- name: languages
86+
isPrivateRepo: false
87+
8788
steps:
8889
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
8990
# Even if if doesn't do anything
@@ -185,4 +186,10 @@ jobs:
185186
ENABLED_LANGUAGES: ${{ matrix.name == 'languages' && 'all' || '' }}
186187
ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo' || matrix.name == 'landings' ) && 'tests/fixtures' || '' }}
187188
TRANSLATIONS_FIXTURE_ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo') && 'tests/fixtures/translations' || '' }}
188-
run: npm test -- ${{ matrix.path }}/
189+
run: |
190+
if [ -d "tests/${{ matrix.name }}/" ]
191+
then
192+
npm test -- tests/${{ matrix.name }}/
193+
else
194+
npm test -- src/${{ matrix.name }}/tests/
195+
fi

0 commit comments

Comments
 (0)