Lint Frontend #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint Frontend | |
| 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 }} | |
| prettier: ${{ steps.detect-changes.outputs.frontend == 'true' || steps.detect-changes.outputs.docs == 'true' }} | |
| 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/frontend-lint.yml | |
| lint-frontend-prettier: | |
| needs: detect-changes | |
| permissions: | |
| contents: read | |
| id-token: write | |
| # 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 && needs.detect-changes.outputs.prettier == 'true' | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| 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 prettier:check | |
| - run: yarn run lint | |
| lint-frontend-prettier-enterprise: | |
| needs: detect-changes | |
| 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) | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false && needs.detect-changes.outputs.prettier == 'true' | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| 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 prettier:check | |
| - run: yarn run lint | |
| lint-frontend-typecheck: | |
| needs: detect-changes | |
| permissions: | |
| contents: read | |
| id-token: write | |
| # 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 && needs.detect-changes.outputs.changed == 'true' | |
| name: Typecheck | |
| runs-on: ubuntu-latest | |
| 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 typecheck | |
| lint-frontend-typecheck-enterprise: | |
| needs: detect-changes | |
| 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) | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false && needs.detect-changes.outputs.changed == 'true' | |
| name: Typecheck | |
| runs-on: ubuntu-latest | |
| 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 typecheck | |
| lint-frontend-betterer: | |
| needs: detect-changes | |
| permissions: | |
| contents: read | |
| id-token: write | |
| if: needs.detect-changes.outputs.changed == 'true' | |
| name: Betterer | |
| runs-on: ubuntu-latest | |
| 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 betterer:ci |