原因#
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 = "// unchanged\n";
}
await expect.soft(content).toMatchFileSnapshot(join(output, file));
}),
);
github action では複数のシステムでテストを行っています
strategy:
matrix:
node: [lts/*]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
しかし、Windows でのテストでは常にエラーが発生し、testで入力と出力が一致しないと表示されました。テストの後、Git のデフォルトの eol
が crlf
であることがわかりました。
そのため、GitHub Action で 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