Lint Code Base #93924
Workflow file for this run
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 Code Base | |
| on: | |
| push: | |
| workflow_dispatch: | |
| inputs: | |
| mode: | |
| description: "Lint mode" | |
| required: true | |
| default: heavy | |
| type: choice | |
| options: | |
| - light | |
| - heavy | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| name: Lint Code Base | |
| runs-on: ubuntu-latest | |
| env: | |
| PNPM_VERSION: "10.17.0" # must match playbook-config.js | |
| steps: | |
| # ------------------------------------------ | |
| # Free disk space | |
| # ------------------------------------------ | |
| - name: Free Disk Space (Ubuntu) | |
| uses: jlumbroso/free-disk-space@v1.3.1 | |
| with: | |
| tool-cache: true | |
| android: false | |
| dotnet: false | |
| haskell: false | |
| large-packages: false | |
| docker-images: false | |
| swap-storage: true | |
| # ------------------------------------------ | |
| # Checkout | |
| # ------------------------------------------ | |
| - name: Checkout latest code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # ------------------------------------------ | |
| # Derive NX_BASE / NX_HEAD | |
| # ------------------------------------------ | |
| - name: Derive SHAs for Nx affected | |
| uses: nrwl/nx-set-shas@v4 | |
| with: | |
| main-branch-name: master | |
| - name: Debug SHAs | |
| run: | | |
| echo "NX_BASE=$NX_BASE" | |
| echo "NX_HEAD=$NX_HEAD" | |
| # ------------------------------------------ | |
| # Node | |
| # ------------------------------------------ | |
| - name: Use Node.js 22.x | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| # ------------------------------------------ | |
| # pnpm binary cache (tool only) | |
| # ------------------------------------------ | |
| - name: Restore pnpm binary | |
| uses: actions/cache@v4 | |
| with: | |
| path: target/pnpm | |
| key: ${{ runner.os }}-pnpm-binary-${{ env.PNPM_VERSION }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-binary- | |
| # ------------------------------------------ | |
| # Yarn cache (tarballs only, standard path) | |
| # ------------------------------------------ | |
| - name: Restore Yarn cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/yarn | |
| key: ${{ runner.os }}-yarn-cache-node22-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn-cache-node22- | |
| - name: Ensure yarn cache folder exists | |
| run: mkdir -p ~/.cache/yarn | |
| # ------------------------------------------ | |
| # Nx local cache | |
| # ------------------------------------------ | |
| - name: Restore Nx cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .nx | |
| key: ${{ runner.os }}-nx-cache-node22-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nx-cache-node22- | |
| ${{ runner.os }}-nx-cache- | |
| # ------------------------------------------ | |
| # Install deps (always deterministic) | |
| # ------------------------------------------ | |
| - name: Install dependencies | |
| env: | |
| YARN_CACHE_FOLDER: ~/.cache/yarn | |
| run: yarn ci:install | |
| # ------------------------------------------ | |
| # RUN LINT (heavy by default) | |
| # ------------------------------------------ | |
| - name: Run lint (light/heavy) | |
| env: | |
| MODE: ${{ github.event.inputs.mode || 'heavy' }} | |
| run: | | |
| set -euo pipefail | |
| BRANCH=$(git branch --show-current) | |
| echo "Current branch is $BRANCH" | |
| echo "Selected MODE=$MODE" | |
| if [[ "$BRANCH" == "master" ]]; then | |
| echo "Current branch is master and no unit test to run, exit ..." | |
| exit 0 | |
| fi | |
| if [[ "$MODE" == "light" ]]; then | |
| echo "LIGHT mode: lint last commit only (HEAD~1..HEAD)" | |
| yarn lint --concurrency=1 \ | |
| --runner nx \ | |
| --base="HEAD~1" \ | |
| --head="HEAD" | |
| else | |
| echo "HEAVY mode: lint full diff (NX_BASE..NX_HEAD)" | |
| echo "NX_BASE=$NX_BASE" | |
| echo "NX_HEAD=$NX_HEAD" | |
| yarn lint --concurrency=1 \ | |
| --runner nx \ | |
| --base="$NX_BASE" \ | |
| --head="$NX_HEAD" | |
| fi |