Skip to content

Commit

Permalink
GH Actions: don't convert line endings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jrfnl committed Nov 13, 2024
1 parent 64cec98 commit 5a30700
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
name: "QuickTest: PHP ${{ matrix.php }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"

steps:
- name: Prepare git to leave line endings alone
run: git config --global core.autocrlf input

- name: Checkout code
uses: actions/checkout@v4

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ jobs:
continue-on-error: ${{ matrix.php == '8.5' }}

steps:
- name: Prepare git to leave line endings alone
run: git config --global core.autocrlf input

- name: Checkout code
uses: actions/checkout@v4

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

steps:
- name: Prepare git to leave line endings alone
run: git config --global core.autocrlf input

- name: Checkout code
uses: actions/checkout@v4

Expand Down

0 comments on commit 5a30700

Please sign in to comment.