Skip to content

Commit 512647f

Browse files
committed
GH Actions: don't convert line endings
By default the `actions/checkout` runner uses the default git settings for line ending normalization, which is `true`. For Windows, this means that `lf` line endings in files get converted to `crlf` on checkout. In the case of PHPCS, this is problematic as this means that the integration test, which runs PHPCS over the code in PHPCS itself, would fail on hundreds of `End of line character is invalid; expected "\n" but found "\r\n"` CS errors. Now, this line ending normalization can be undone via some config in `.gitattributes`, but that could negatively impact contributors who may prefer to have the line ending conversion when working on files in their local editors. So instead of that, this commit just turns it off in CI alone. The `core.autocrlf input` setting should leave the line-endings "as-is" when it gets checked out. Refs: * https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whitespace * actions/checkout#135 * actions/checkout#226
1 parent 1fcf37f commit 512647f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.github/workflows/quicktest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ jobs:
4444
name: "QuickTest: PHP ${{ matrix.php }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
4545

4646
steps:
47+
- name: Prepare git to leave line endings alone
48+
run: git config --global core.autocrlf input
49+
4750
- name: Checkout code
4851
uses: actions/checkout@v4
4952

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ jobs:
118118
continue-on-error: ${{ matrix.php == '8.5' }}
119119

120120
steps:
121+
- name: Prepare git to leave line endings alone
122+
run: git config --global core.autocrlf input
123+
121124
- name: Checkout code
122125
uses: actions/checkout@v4
123126

@@ -229,6 +232,9 @@ jobs:
229232
name: "Coverage: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
230233

231234
steps:
235+
- name: Prepare git to leave line endings alone
236+
run: git config --global core.autocrlf input
237+
232238
- name: Checkout code
233239
uses: actions/checkout@v4
234240

0 commit comments

Comments
 (0)