Skip to content

Commit

Permalink
fix: ensure it can run on all operating systems (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jul 16, 2022
1 parent ded32b9 commit b8a69d3
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 27 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/CI.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,25 @@
name: CI

on: [push, pull_request]

jobs:
style:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- name: Use LF line endings
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3

- name: Check formatting latest
uses: ./

- name: Check formatting specific version
uses: ./
with:
dprint-version: 0.30.3
41 changes: 37 additions & 4 deletions README.md
Expand Up @@ -12,9 +12,17 @@ jobs:
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: dprint/check@v2.0
- uses: dprint/check@v2.1
```

If you are using a matrix, most likely you will only want to run it only on Linux. For example:

```yml
- name: Check format
if: runner.os == 'Linux'
uses: dprint/check@v2.1
```

### Latest Version
Expand All @@ -26,7 +34,32 @@ By default, `dprint/check` uses the latest version of dprint.
To use a specific version, specify that with the `dprint-version` input:

```yml
- uses: dprint/check@v2.0
- uses: dprint/check@v2.1
with:
dprint-version: 0.17.0
dprint-version: 0.30.3
```

## Troubleshooting

### Windows line endings

When running on Windows, you may get a lot of messages like:

```
from D:\a\check\check\README.md:
| Text differed by line endings.
--
```

This is because unfortunately git is configured in GH actions to check out line endings as CRLF (`\r\n`).

You can fix this by only running the action on Linux as shown above (recommended), or to do the following before checking out the repo:

```yml
- name: Ensure LF line endings for Windows
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3
```
4 changes: 2 additions & 2 deletions action.yml
Expand Up @@ -3,7 +3,7 @@ description: 'Run `dprint check` on your source code'
author: 'thomaseizinger'
inputs:
dprint-version:
description: 'Specific dprint version to use (ex. 0.17.0)'
description: 'Specific dprint version to use (ex. 0.30.3)'
required: false
default: ''
runs:
Expand All @@ -16,7 +16,7 @@ runs:
echo "/home/runner/.dprint/bin" >> $GITHUB_PATH
- name: Check formatting
shell: bash
run: dprint check
run: ~/.dprint/bin/dprint check
branding:
icon: 'check-circle'
color: 'gray-dark'
5 changes: 2 additions & 3 deletions dprint.json
@@ -1,8 +1,7 @@
{
"incremental": true,
"includes": ["**/*.{md,json}"],
"plugins": [
"https://plugins.dprint.dev/json-0.13.0.wasm",
"https://plugins.dprint.dev/markdown-0.10.0.wasm"
"https://plugins.dprint.dev/json-0.15.3.wasm",
"https://plugins.dprint.dev/markdown-0.13.3.wasm"
]
}

0 comments on commit b8a69d3

Please sign in to comment.