From ee93dbd2bd58ed8247a75e82e7d4e1306d56f3d4 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 25 Apr 2025 09:22:02 +0100 Subject: [PATCH] Chore: Run fronted unit tests + linting/typecheck against enterprise (#104479) * run unit tests + linting/typecheck against enterprise * update permissions * kick CI * keep job names the same --- .github/workflows/frontend-lint.yml | 47 ++++++++++++++++++++ .github/workflows/pr-frontend-unit-tests.yml | 34 ++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/.github/workflows/frontend-lint.yml b/.github/workflows/frontend-lint.yml index cad4294407b..148838465fa 100644 --- a/.github/workflows/frontend-lint.yml +++ b/.github/workflows/frontend-lint.yml @@ -6,6 +6,10 @@ on: - main - release-*.*.* +permissions: + contents: read + id-token: write + jobs: lint-frontend-verify-i18n: name: Verify i18n @@ -30,6 +34,24 @@ jobs: exit 1 fi lint-frontend-prettier: + # Run this workflow only for PRs from forks; if it gets merged into `main` or `release-*`, + # the `lint-frontend-prettier-enterprise` workflow will run instead + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - 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 prettier:check + - run: yarn run lint + lint-frontend-prettier-enterprise: + # 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 name: Lint runs-on: ubuntu-latest steps: @@ -39,10 +61,17 @@ jobs: 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 prettier:check - run: yarn run lint lint-frontend-typecheck: + # Run this workflow only for PRs from forks; if it gets merged into `main` or `release-*`, + # the `lint-frontend-typecheck-enterprise` workflow will run instead + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true name: Typecheck runs-on: ubuntu-latest steps: @@ -54,6 +83,24 @@ jobs: cache-dependency-path: 'yarn.lock' - run: yarn install --immutable --check-cache - run: yarn run typecheck + lint-frontend-typecheck-enterprise: + # 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 + name: Typecheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - 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 typecheck lint-frontend-betterer: name: Betterer runs-on: ubuntu-latest diff --git a/.github/workflows/pr-frontend-unit-tests.yml b/.github/workflows/pr-frontend-unit-tests.yml index f3c61032d52..beced0ac371 100644 --- a/.github/workflows/pr-frontend-unit-tests.yml +++ b/.github/workflows/pr-frontend-unit-tests.yml @@ -6,8 +6,38 @@ on: - main - release-*.*.* +permissions: + contents: read + id-token: write + jobs: frontend-unit-tests: + # 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 + 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 + - 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: + # 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 runs-on: ubuntu-latest-8-cores name: "Unit tests (${{ matrix.chunk }} / 8)" strategy: @@ -21,6 +51,10 @@ jobs: 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: