原因#
Debbl/eslint-config のテストを書いている間に問題が発生しました。
await Promise.all(
files.map(async (file) => {
let content = await fs.readFile(join(target, file), "utf-8");
const source = await fs.readFile(join(from, file), "utf-8");
if (content === source) {
content = "// 変更なし\n";
}
await expect.soft(content).toMatchFileSnapshot(join(output, file));
}),
);
GitHub アクションでは、複数のシステムでテストを実行しています。
strategy:
matrix:
node: [lts/*]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
しかし、Windows でのテスト実行時に常にエラーが発生し、testで入力と出力が一致しないと表示されます。テストの後、問題は Windows のデフォルトの git ダウンロード時にeol
がcrlf
に設定されていることがわかりました。
そのため、GitHub アクションでeol
をlf
に設定する方法を調べました actions/checkout#135。
最終的に、以下のコマンドを追加しました ci.yml。
Windows では、次のコマンドでlf
に設定できます。
git config --global core.autocrlf false
git config --global core.eol lf
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
.gitattributes
で設定する方法#
* text=auto eol=lf