biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
15.43k stars 480 forks source link

🐛 biome ci in pipeline doesn't apply biome.json #3357

Closed jochenrui closed 3 months ago

jochenrui commented 4 months ago

Environment information

CLI:
  Version:                      1.8.3
  Color support:                false

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           unset
  JS_RUNTIME_NAME:              unset
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Workspace:
  Open Documents:               0

What happened?

  1. setup biome on new branch
  2. create biome config to check only changed files
    {
    "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
    "organizeImports": {
    "enabled": true
    },
    "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
    },
    "vcs": {
    "enabled": true,
    "clientKind": "git",
    "defaultBranch": "main"
    },
    "files": {
    "ignore": [".angular", ".firebase", "node_modules", "www"],
    "include": ["**/src/**/*.ts", "**/src/**/*.html", "**/src/**/*.scss"]
    },
    "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "ignore": [],
    "attributePosition": "auto",
    "indentStyle": "space",
    "indentWidth": 2,
    "lineWidth": 80,
    "lineEnding": "lf"
    },
    "javascript": {
    "formatter": {
      "arrowParentheses": "always",
      "bracketSameLine": false,
      "bracketSpacing": true,
      "jsxQuoteStyle": "double",
      "quoteProperties": "asNeeded",
      "semicolons": "always",
      "trailingCommas": "all"
    }
    },
    "json": {
    "formatter": {
      "trailingCommas": "none"
    }
    }
    }
  3. add obvious error to a file that's scanned
  4. test running the command locally npx biome ci . --changed --no-errors-on-unmatched
  5. works as intended and finds the obvious error (and ignores the rest because only changed files should be scanned)
  6. run in github actions
  7. github actions says no files scanned
    Run biome ci . --changed --no-errors-on-unmatched
    biome ci . --changed --no-errors-on-unmatched
    shell: /usr/bin/bash -e {0}
    Checked 0 files in [3](https://github.com/XXXXX/xxxxx/actions/runs/########/job/nnnnnnn#step:4:3)7µs. No fixes applied.

gh action file:

name: Code quality

on:
  push:
  pull_request:

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup Biome
        uses: biomejs/setup-biome@v2
        with:
          version: latest
          working-dir: ./some-subdir-for-frontend
      - name: Run Biome
        working-directory: ./some-subdir-for-frontend
        run: |
          biome ci . --changed --no-errors-on-unmatched

Expected result

Biome should scan the frontend subdir of the project and check only the changed files (1 file with a planted error)

Code of Conduct

lednhatkhanh commented 4 months ago

I'm facing the exact same issue

lednhatkhanh commented 4 months ago

@jochenrui I think I figured out the problem, just change defaultBranch to origin/main and add fetch-depth: 0 to checkout action and it will work.

jochenrui commented 3 months ago

thanks! I'll try it out. Sorry for the late response