Skip to content

Commit 5a30700

Browse files
committedNov 13, 2024
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 64cec98 commit 5a30700

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
 

‎.github/workflows/quicktest.yml

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
name: "QuickTest: PHP ${{ matrix.php }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
3535

3636
steps:
37+
- name: Prepare git to leave line endings alone
38+
run: git config --global core.autocrlf input
39+
3740
- name: Checkout code
3841
uses: actions/checkout@v4
3942

‎.github/workflows/test.yml

+6
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ jobs:
112112
continue-on-error: ${{ matrix.php == '8.5' }}
113113

114114
steps:
115+
- name: Prepare git to leave line endings alone
116+
run: git config --global core.autocrlf input
117+
115118
- name: Checkout code
116119
uses: actions/checkout@v4
117120

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

197200
steps:
201+
- name: Prepare git to leave line endings alone
202+
run: git config --global core.autocrlf input
203+
198204
- name: Checkout code
199205
uses: actions/checkout@v4
200206

0 commit comments

Comments
 (0)
Failed to load comments.