f836ea2ada
* trigger a workflow run for baseline
* attempt to improve caching with upfront action
* CYPRESS_INSTALL_BINARY: 0
* PUPPETEER_SKIP_DOWNLOAD: true
* use ubuntu-x64-large runners
* increase to 16 shards 🚀
* fix incorrect shard total
* ubuntu-x64 runners
* Revert "ubuntu-x64 runners"
This reverts commit 3411c7c5e1039263b17a3065cd7d45fa4c3c8f69.
* try caching node_modules
* fix flakey scopes test
* try just ubuntu-x64-large for yarn-install job
* run again, last one had a dodgy trace
* try different runners for yarn instlal
* Move node_modules cache steps to composite action, use ubuntu-x64 runners for everything
* fix duplicate runs-on
* specify shell for composite action
* fix some flaky tests
* update codeowners
* dedupe yarn.lock
* align yarn action, switch tests back to ubuntu-x64-large
* align yarn action cache keys
* fix required-frontend-unit-tests not checking repo out
* try without the node_modules magic
* actually skip the node_modules caching magic
* skip hardened mode
* skip downloading cypress
* comment
169 lines
5.6 KiB
YAML
169 lines
5.6 KiB
YAML
name: Frontend tests
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
- release-*.*.*
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
detect-changes:
|
|
name: Detect whether code changed
|
|
runs-on: ubuntu-x64-small
|
|
permissions:
|
|
contents: read
|
|
outputs:
|
|
changed: ${{ steps.detect-changes.outputs.frontend }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: true # required to get more history in the changed-files action
|
|
fetch-depth: 2
|
|
- name: Detect changes
|
|
id: detect-changes
|
|
uses: ./.github/actions/change-detection
|
|
with:
|
|
self: .github/workflows/pr-frontend-unit-tests.yml
|
|
|
|
frontend-unit-tests:
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
needs:
|
|
- detect-changes
|
|
# Run this workflow only for PRs from forks; if it gets merged into `main` or `release-*`,
|
|
# the `frontend-unit-tests-enterprise` workflow will run instead
|
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true && needs.detect-changes.outputs.changed == 'true'
|
|
runs-on: ubuntu-x64-large
|
|
name: "Unit tests (${{ matrix.shard }} / ${{ matrix.total }})"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
|
|
total: [16]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
- name: Yarn install
|
|
run: yarn install --immutable
|
|
env:
|
|
PUPPETEER_SKIP_DOWNLOAD: true
|
|
CYPRESS_INSTALL_BINARY: 0
|
|
- run: yarn run test:ci
|
|
env:
|
|
TEST_MAX_WORKERS: 4
|
|
TEST_SHARD: ${{ matrix.shard }}
|
|
TEST_SHARD_TOTAL: ${{ matrix.total }}
|
|
|
|
frontend-unit-tests-enterprise:
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
needs:
|
|
- detect-changes
|
|
# Run this workflow for non-PR events (like pushes to `main` or `release-*`) OR for internal PRs (PRs not from forks)
|
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false && needs.detect-changes.outputs.changed == 'true'
|
|
runs-on: ubuntu-x64-large
|
|
name: "Unit tests (${{ matrix.shard }} / ${{ matrix.total }})"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
|
|
total: [16]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Enterprise
|
|
uses: ./.github/actions/setup-enterprise
|
|
with:
|
|
github-app-name: 'grafana-ci-bot'
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
- name: Yarn install
|
|
run: yarn install --immutable
|
|
env:
|
|
# Switch from default hardened mode to faster mode for internal PRs
|
|
YARN_ENABLE_HARDENED_MODE: ${{ github.event.pull_request.head.repo.fork == false && '1' || '0' }}
|
|
PUPPETEER_SKIP_DOWNLOAD: true
|
|
CYPRESS_INSTALL_BINARY: 0
|
|
- run: yarn run test:ci
|
|
env:
|
|
TEST_MAX_WORKERS: 4
|
|
TEST_SHARD: ${{ matrix.shard }}
|
|
TEST_SHARD_TOTAL: ${{ matrix.total }}
|
|
|
|
frontend-decoupled-plugin-tests:
|
|
needs:
|
|
- detect-changes
|
|
if: needs.detect-changes.outputs.changed == 'true'
|
|
runs-on: ubuntu-x64-large
|
|
name: "Decoupled plugin tests"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
- name: Yarn install
|
|
run: yarn install --immutable
|
|
env:
|
|
# Switch from default hardened mode to faster mode for internal PRs
|
|
YARN_ENABLE_HARDENED_MODE: ${{ github.event.pull_request.head.repo.fork == false && '1' || '0' }}
|
|
PUPPETEER_SKIP_DOWNLOAD: true
|
|
CYPRESS_INSTALL_BINARY: 0
|
|
- run: yarn run plugin:test:ci
|
|
|
|
frontend-packages-unit-tests:
|
|
needs:
|
|
- detect-changes
|
|
if: needs.detect-changes.outputs.changed == 'true'
|
|
runs-on: ubuntu-x64-large
|
|
name: "Packages unit tests"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Node.js
|
|
uses: ./.github/actions/setup-node
|
|
- name: Yarn install
|
|
run: yarn install --immutable
|
|
env:
|
|
# Switch from default hardened mode to faster mode for internal PRs
|
|
YARN_ENABLE_HARDENED_MODE: ${{ github.event.pull_request.head.repo.fork == false && '1' || '0' }}
|
|
PUPPETEER_SKIP_DOWNLOAD: true
|
|
CYPRESS_INSTALL_BINARY: 0
|
|
- run: yarn run packages:test:ci
|
|
|
|
# This is the job that is actually required by rulesets.
|
|
# We need to require EITHER the OSS or the Enterprise job to pass.
|
|
# However, if one is skipped, GitHub won't flat-map the shards,
|
|
# so they won't be accepted by a ruleset.
|
|
required-frontend-unit-tests:
|
|
needs:
|
|
- frontend-unit-tests
|
|
- frontend-unit-tests-enterprise
|
|
- frontend-decoupled-plugin-tests
|
|
- frontend-packages-unit-tests
|
|
# always() is the best function here.
|
|
# success() || failure() will skip this function if any need is also skipped.
|
|
# That means conditional test suites will fail the entire requirement check.
|
|
if: always()
|
|
|
|
name: All frontend unit tests complete
|
|
runs-on: ubuntu-x64-small
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- name: Check test suites
|
|
uses: ./.github/actions/check-jobs
|
|
with:
|
|
needs: ${{ toJson(needs) }}
|
|
failure-message: "One or more unit test jobs have failed"
|
|
success-message: "All unit tests completed successfully" |