Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure it can run on all operating systems #7

Merged
merged 4 commits into from Jul 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -4,7 +4,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 @@ -17,7 +17,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"
]
}