* test(frontend): ignore azuremonitor tests in root jest config * test(loki): increase waitfor in monacofieldwrapper test * feat(plugin-configs): introduce jest config * feat(azuremonitor): add jest config and test scripts * ci(pr-frontend-unit-tests): introduce separate decoupled plugin test job * ci(pr-frontend-unit-tests): run decoupled-plugin tests regardless of fork * Wip * test(decoupled-plugins): decouple tests in all plugins except loki and mssql * test(frontend): ignore decoupled plugins that run their own tests * test(stackdriver): update snapshot due to reactinlinesvg mock difference * chore(yarn): update lock file * chore(plugin-configs): remove create-plugin comments * ci(frontend-unit-tests): make them run on pr or merge to main * chore(decoupled-plugins): add plugin:test:ci command for locally running all tests * ci(frontend-unit-tests): run test:ci instead of calling nx directly * chore(decoupled-plugins): fix jest-dom types for loki and testdata
137 lines
4.3 KiB
YAML
137 lines
4.3 KiB
YAML
name: Frontend tests
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
- release-*.*.*
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
detect-changes:
|
|
name: Detect whether code changed
|
|
runs-on: ubuntu-latest
|
|
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
|
|
# 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
|
|
needs: detect-changes
|
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true && needs.detect-changes.outputs.changed == 'true'
|
|
runs-on: ubuntu-latest-8-cores
|
|
name: "Unit tests (${{ matrix.chunk }} / 8)"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
chunk: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: 'yarn'
|
|
cache-dependency-path: 'yarn.lock'
|
|
- run: yarn install --immutable --check-cache
|
|
- run: yarn run test:ci
|
|
env:
|
|
TEST_MAX_WORKERS: 2
|
|
TEST_SHARD: ${{ matrix.chunk }}
|
|
TEST_SHARD_TOTAL: 8
|
|
|
|
frontend-unit-tests-enterprise:
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
# Run this workflow for non-PR events (like pushes to `main` or `release-*`) OR for internal PRs (PRs not from forks)
|
|
needs: detect-changes
|
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false && needs.detect-changes.outputs.changed == 'true'
|
|
runs-on: ubuntu-latest-8-cores
|
|
name: "Unit tests (${{ matrix.chunk }} / 8)"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
chunk: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: 'yarn'
|
|
cache-dependency-path: 'yarn.lock'
|
|
- name: Setup Enterprise
|
|
uses: ./.github/actions/setup-enterprise
|
|
with:
|
|
github-app-name: 'grafana-ci-bot'
|
|
- run: yarn install --immutable --check-cache
|
|
- run: yarn run test:ci
|
|
env:
|
|
TEST_MAX_WORKERS: 2
|
|
TEST_SHARD: ${{ matrix.chunk }}
|
|
TEST_SHARD_TOTAL: 8
|
|
|
|
frontend-decoupled-plugin-tests:
|
|
needs: detect-changes
|
|
if: needs.detect-changes.outputs.changed == 'true'
|
|
runs-on: ubuntu-latest-8-cores
|
|
name: "Decoupled plugin tests"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: 'yarn'
|
|
cache-dependency-path: 'yarn.lock'
|
|
- run: yarn install --immutable --check-cache
|
|
- run: yarn run plugin: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
|
|
# 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-latest
|
|
steps:
|
|
- name: Check test suites
|
|
env:
|
|
NEEDS: ${{ toJson(needs) }}
|
|
run: |
|
|
FAILURES="$(echo "$NEEDS" | jq 'with_entries(select(.value.result == "failure")) | map_values(.result)')"
|
|
echo "$FAILURES"
|
|
if [ "$(echo "$FAILURES" | jq '. | length')" != "0" ]; then
|
|
exit 1
|
|
fi
|
|
echo "All OK!"
|