biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.

Home Page:https://biomejs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ“ biome ci always produce errors in GHA but not locally

motss opened this issue Β· comments

Environment information

CLI:
  Version:                      1.8.0
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v22.1.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "pnpm/9.2.0"

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

Formatter:
  Format with errors:           false
  Indent style:                 Space
  Indent width:                 2
  Line ending:                  Lf
  Line width:                   80
  Attribute position:           Multiline
  Ignore:                       []
  Include:                      []

JavaScript Formatter:
  Enabled:                      true
  JSX quote style:              Double
  Quote properties:             AsNeeded
  Trailing commas:              Es5
  Semicolons:                   Always
  Arrow parentheses:            Always
  Bracket spacing:              true
  Bracket same line:            true
  Quote style:                  Single
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  Lf
  Line width:                   unset
  Attribute position:           Multiline

JSON Formatter:
  Enabled:                      true
  Indent style:                 unset
  Indent width:                 unset
  Line ending:                  unset
  Line width:                   unset
  Trailing Commas:              None

CSS Formatter:
  Enabled:                      true
  Indent style:                 Tab
  Indent width:                 0
  Line ending:                  Lf
  Line width:                   LineWidth(80)
  Quote style:                  Double

Workspace:
  Open Documents:               0

Configuration

{
  "$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
  "formatter": {
    "attributePosition": "multiline",
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "space",
    "indentWidth": 2,
    "lineEnding": "lf",
    "lineWidth": 80
  },
  "css": {
    "formatter": {
      "enabled": true,
      "quoteStyle": "double"
    },
    "linter": {
      "enabled": true
    },
    "parser": {
      "cssModules": true
    }
  },
  "javascript": {
    "formatter": {
      "arrowParentheses": "always",
      "attributePosition": "multiline",
      "bracketSameLine": true,
      "bracketSpacing": true,
      "enabled": true,
      "jsxQuoteStyle": "double",
      "lineEnding": "lf",
      "quoteProperties": "asNeeded",
      "quoteStyle": "single",
      "semicolons": "always",
      "trailingCommas": "es5"
    }
  },
  "json": {
    "formatter": {
      "enabled": true,
      "trailingCommas": "none"
    },
    "linter": {
      "enabled": true
    },
    "parser": {
      "allowComments": false,
      "allowTrailingCommas": false
    }
  },
  "vcs": {
    "clientKind": "git",
    "defaultBranch": "main",
    "enabled": true,
    "root": ".",
    "useIgnoreFile": true
  },
  "organizeImports": {
    "enabled": false
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true,
      "a11y": {
        "all": true
      },
      "complexity": {
        "all": true,
        "noStaticOnlyClass": "off",
        "noUselessSwitchCase": "off",
        "noExcessiveCognitiveComplexity": "off"
      },
      "correctness": {
        "all": true
      },
      "nursery": {
        "all": true,
        "noConsole": "off",
        "useImportRestrictions": "off"
      },
      "performance": {
        "all": true
      },
      "security": {
        "all": true
      },
      "style": {
        "all": true,
        "useNamingConvention": {
          "level": "error",
          "options": {
            "strictCase": false
          }
        }
      },
      "suspicious": {
        "all": true,
        "useAwait": "off"
      }
    }
  },
  "overrides": [
    {
      "include": [
        "commitlint.config.*js",
        "eslint.config.*js",
        "nano-staged.*js",
        "vite.config.ts",
        "vitest.workspace.ts"
      ],
      "linter": {
        "enabled": true,
        "rules": {
          "style": {
            "noDefaultExport": "off"
          }
        }
      }
    },
    {
      "include": ["eslint.config.*js"],
      "linter": {
        "enabled": true,
        "rules": {
          "nursery": {
            "noUndeclaredDependencies": "off"
          }
        }
      }
    },
    {
      "include": ["src/**/*.test.ts*"],
      "linter": {
        "rules": {
          "nursery": {
            /**
             * fixme: remove the override when [#3133] gets resolved.
             *
             * [#3133]: https://github.com/biomejs/biome/issues/3133
             */
            "useDateNow": "off"
          }
        }
      }
    }
  ]
}

Actual result

Running biome ci in GHA will always produce errors even when the formatter logs Checked 2 files in 1572Β΅s. No fixes needed.. However, running biome ci locally does not see any errors.

> biome ci
 format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  βœ– File content differs from formatting output
  
     3  3 β”‚     "version": "0.0.1",
     4  4 β”‚     "description": "Broken biome ci",
     5    β”‚ - Β·Β·"keywords":Β·[
     6    β”‚ - Β·Β·Β·Β·"biome",
     7    β”‚ - Β·Β·Β·Β·"ci",
     8    β”‚ - Β·Β·Β·Β·"biome-ci",
     9    β”‚ - Β·Β·Β·Β·"broken-biome-ci"
    10    β”‚ - Β·Β·],
        5 β”‚ + Β·Β·"keywords":Β·["biome",Β·"ci",Β·"biome-ci",Β·"broken-biome-ci"],
    11  6 β”‚     "homepage": "https://github.com/motss/broken-biome-ci",
    12  7 β”‚     "bugs": {
    Β·Β·Β·Β·Β· β”‚ 
    35 [30](https://github.com/ipohjs/broken-biome-ci/actions/runs/9438349120/job/25995224343#step:9:31) β”‚     "module": "./index.js",
    36 [31](https://github.com/ipohjs/broken-biome-ci/actions/runs/9438349120/job/25995224343#step:9:32) β”‚     "types": "./index.js",
    37    β”‚ - Β·Β·"files":Β·[
    38    β”‚ - Β·Β·Β·Β·"./index.d.ts",
    39    β”‚ - Β·Β·Β·Β·"./index.js"
    40    β”‚ - Β·Β·],
    41    β”‚ - Β·Β·"workspaces":Β·[
    42    β”‚ - Β·Β·Β·Β·"./packages/*"
    43    β”‚ - Β·Β·],
       [32](https://github.com/ipohjs/broken-biome-ci/actions/runs/9438349120/job/25995224343#step:9:33) β”‚ + Β·Β·"files":Β·["./index.d.ts",Β·"./index.js"],
       [33](https://github.com/ipohjs/broken-biome-ci/actions/runs/9438349120/job/25995224343#step:9:34) β”‚ + Β·Β·"workspaces":Β·["./packages/*"],
    44 [34](https://github.com/ipohjs/broken-biome-ci/actions/runs/9438349120/job/25995224343#step:9:35) β”‚     "scripts": {
    45 [35](https://github.com/ipohjs/broken-biome-ci/actions/runs/9438349120/job/25995224343#step:9:36) β”‚       "biome.ci": "biome ci",
  

ci ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  βœ– Some errors were emitted while running checks.
  

Checked 2 files in 1572Β΅s. No fixes needed.
Found 1 error.
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

Expected result

Running biome ci locally and in GHA should always produce identical and consistent result.

> biome ci

Checked 2 files in 969Β΅s. No fixes needed.

Playground link

Instead of providing a playground which does not support JSON formatting, you should clone this public repo I created to reproduce the error.

  1. Github repo with reduced test case - link
  2. GHA showing the error message when running biome ci - link

Related issues

  1. #3087
  2. #2856

Code of Conduct

  • I agree to follow Biome's Code of Conduct

I don't think this is a bug of Biome.

In your workflow there's a command pnpm pkg delete scripts.postinstall which will format the package.json file in a way that each of the array entry is put into a separated line. And Biome later will in turn put them into a single line according to the lineWidth option.

You can add an override entry for the package.json file to set the lineWidth to 1 so the behavior of the Biome formatter aligns with the pnpm pkg ... command. Or you can ignore the file.