【问题标题】:GitHub Actions: Prettier finds errors only on windows-latestGitHub Actions:Prettier 仅在 windows-latest 上发现错误
【发布时间】:2020-05-22 15:16:44
【问题描述】:

我目前正在将我们的 CI 管道从 CircleCI 转移到 GitHub Actions,但我遇到了 Prettier 的问题。我们使用 Prettier 在我们的项目中强制执行一致的代码风格,这是 CI 管道中的一个步骤。该管道在 Linux、MacOS 和 Windows 上运行。

我执行npx prettier --check "{src,test,examples}/**/*.ts" 来检查文件的格式问题。奇怪的是,此检查在 ubuntu-latest 和 macos-latest 上通过,但在 windows-latest 上失败。

您可以在此处查看 windows-latest 的示例输出:

Run npm run format:check

> h5p-nodejs-library@2.0.0 format:check D:\a\H5P-Nodejs-library\H5P-Nodejs-library
> npx prettier --check "{src,test,examples}/**/*.ts"

Checking formatting...
test\TemporaryFileManager.test.ts
[... nearly all our files...]
Code style issues found in the above file(s). Forgot to run Prettier?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! h5p-nodejs-library@2.0.0 format:check: `npx prettier --check "{src,test,examples}/**/*.ts"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the h5p-nodejs-library@2.0.0 format:check script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\npm\cache\_logs\2020-05-22T14_42_05_193Z-debug.log
##[error]Process completed with exit code 1.

(完整日志请参见https://github.com/Lumieducation/H5P-Nodejs-library/runs/699946934?check_suite_focus=true

Prettier 在 Windows 上的行为是否有所不同?我的主要开发机器运行 Windows 10,并通过了更漂亮的检查...有没有人知道检查失败的原因?

【问题讨论】:

    标签: continuous-integration github-actions prettier


    【解决方案1】:

    我找到了问题的原因:这是 Git 在 Windows Server 上检查行尾的方式。答案可以在:https://github.com/prettier/prettier/issues/7825.

    解决方案:将 * text=auto eol=lf 添加到 repo 的 .gitattributes 文件中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多