Test workflow: use plain matrix, creative exclude for languages (#42882)
Co-authored-by: Hector Alfaro <hectorsector@github.com>
This commit is contained in:
111
.github/workflows/test.yml
vendored
111
.github/workflows/test.yml
vendored
@@ -24,58 +24,10 @@ env:
|
||||
ELASTICSEARCH_URL: http://localhost:9200/
|
||||
|
||||
jobs:
|
||||
figureOutMatrix:
|
||||
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.result }}
|
||||
steps:
|
||||
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
|
||||
id: set-matrix
|
||||
with:
|
||||
script: |
|
||||
// We only want to run the 'languages' suite when we know
|
||||
// we're on the private docs-internal repo because only that
|
||||
// one has ability to clone the remote (private) languages
|
||||
// repos.
|
||||
// You can run multiple paths per suite as space-separated in `path`.
|
||||
// Note that *if you add* to this, remember to also add that
|
||||
// to the **required checks** in the branch protection rules.
|
||||
return [
|
||||
{ name: 'assets', path: 'src/assets/tests', },
|
||||
// { name: 'audit-logs', path: 'src/assets/audit-logs', },
|
||||
{ name: 'automated-pipelines', path: 'src/automated-pipelines/tests', },
|
||||
{ name: 'color-schemes', path: 'src/color-schemes/tests', },
|
||||
{ name: 'content', path: 'tests/content', },
|
||||
{ name: 'content-linter', path: 'src/content-linter/tests', },
|
||||
{ name: 'content-render', path: 'src/content-render/tests', },
|
||||
{ name: 'events', path: 'src/events/tests', },
|
||||
{ name: 'ghes-releases', path: 'src/ghes-releases/tests', },
|
||||
{ name: 'github-apps', path: 'src/github-apps/tests', },
|
||||
{ name: 'graphql', path: 'src/graphql/tests', },
|
||||
{ name: 'landings', path: 'src/landings/tests', },
|
||||
{ name: 'learning-track', path: 'src/learning-track/tests', },
|
||||
{ name: 'observability', path: 'src/observability/tests' },
|
||||
{ name: 'pageinfo', path: 'src/pageinfo/tests', },
|
||||
{ name: 'redirects', path: 'src/redirects/tests', },
|
||||
{ name: 'release-notes', path: 'src/release-notes/tests', },
|
||||
{ name: 'rendering', path: 'tests/rendering', },
|
||||
{ name: 'rendering-fixtures', path: 'tests/rendering-fixtures', },
|
||||
{ name: 'rest', path: 'src/rest/tests', },
|
||||
{ name: 'routing', path: 'tests/routing', },
|
||||
{ name: 'search', path: 'src/search/tests', },
|
||||
{ name: 'secret-scanning', path: 'src/secret-scanning/tests',},
|
||||
{ name: 'shielding', path: 'src/shielding/tests', },
|
||||
context.payload.repository.full_name === 'github/docs-internal' &&
|
||||
{ name: 'languages', path: 'src/languages/tests', },
|
||||
{ name: 'unit', path: 'tests/unit', },
|
||||
// { name: 'tools', path: 'src/tools/tests', }
|
||||
{ name: 'webhooks', path: 'src/webhooks/tests', },
|
||||
].filter(Boolean)
|
||||
|
||||
test:
|
||||
name: ${{ matrix.name }}
|
||||
needs: figureOutMatrix
|
||||
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
|
||||
|
||||
# Run on ubuntu-20.04-xl if the private repo or ubuntu-latest if the public repo
|
||||
# See pull # 17442 in the private repo for context
|
||||
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
|
||||
@@ -83,7 +35,56 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJSON(needs.figureOutMatrix.outputs.matrix) }}
|
||||
# Note that *if you add* to this, remember to also add that
|
||||
# to the **required checks** in the branch protection rules.
|
||||
name:
|
||||
# tests/ directory
|
||||
- content
|
||||
- rendering
|
||||
- rendering-fixtures
|
||||
- routing
|
||||
- unit
|
||||
|
||||
# src/ directory
|
||||
- archives
|
||||
- assets
|
||||
# - audit-logs
|
||||
- automated-pipelines
|
||||
# - codeql-cli
|
||||
- color-schemes
|
||||
- content-linter
|
||||
- content-render
|
||||
- early-access
|
||||
- events
|
||||
# - frame
|
||||
- ghes-releases
|
||||
- github-apps
|
||||
- graphql
|
||||
- landings
|
||||
- languages
|
||||
- learning-track
|
||||
# - links
|
||||
- observability
|
||||
# - open-source
|
||||
- pageinfo
|
||||
# - pages
|
||||
- redirects
|
||||
- release-notes
|
||||
- rest
|
||||
- search
|
||||
- secret-scanning
|
||||
- shielding
|
||||
# - tools
|
||||
- versions
|
||||
- webhooks
|
||||
|
||||
# The languages suite only runs on docs-internal
|
||||
isPrivateRepo:
|
||||
- ${{ github.repository == 'github/docs-internal' }}
|
||||
exclude:
|
||||
- name: languages
|
||||
isPrivateRepo: false
|
||||
|
||||
steps:
|
||||
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
|
||||
# Even if if doesn't do anything
|
||||
@@ -185,4 +186,10 @@ jobs:
|
||||
ENABLED_LANGUAGES: ${{ matrix.name == 'languages' && 'all' || '' }}
|
||||
ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo' || matrix.name == 'landings' ) && 'tests/fixtures' || '' }}
|
||||
TRANSLATIONS_FIXTURE_ROOT: ${{ (matrix.name == 'rendering-fixtures' || matrix.name == 'pageinfo') && 'tests/fixtures/translations' || '' }}
|
||||
run: npm test -- ${{ matrix.path }}/
|
||||
run: |
|
||||
if [ -d "tests/${{ matrix.name }}/" ]
|
||||
then
|
||||
npm test -- tests/${{ matrix.name }}/
|
||||
else
|
||||
npm test -- src/${{ matrix.name }}/tests/
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user