From e6d44e6d521e5feb5cff79d6f8c31d4a86a026e3 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 16 Jul 2022 16:46:58 -0400 Subject: [PATCH 1/4] fix: ensure it can run on all operating systems --- .github/workflows/CI.yml | 7 +++++-- README.md | 16 ++++++++++++---- action.yml | 4 ++-- dprint.json | 5 ++--- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4875842..01aa8c8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,7 +4,10 @@ on: [push, pull_request] jobs: style: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] steps: - name: Checkout sources uses: actions/checkout@v2 @@ -15,4 +18,4 @@ jobs: - name: Check formatting specific version uses: ./ with: - dprint-version: 0.17.0 + dprint-version: 0.30.3 diff --git a/README.md b/README.md index 1e93ae6..9f0d4ce 100644 --- a/README.md +++ b/README.md @@ -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 on one of them: + +```yml +- name: Check format + if: contains(matrix.os, 'ubuntu') + uses: dprint/check@v2.1 ``` ### Latest Version @@ -26,7 +34,7 @@ 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 ``` diff --git a/action.yml b/action.yml index 40b109b..5c60587 100644 --- a/action.yml +++ b/action.yml @@ -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: @@ -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' diff --git a/dprint.json b/dprint.json index ff0abee..55191fa 100644 --- a/dprint.json +++ b/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" ] } From fb3c4f989cd22fb498ce97263fc2bab7e7298f34 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 16 Jul 2022 16:50:50 -0400 Subject: [PATCH 2/4] See if upgrading fixes it before doing git config --- .github/workflows/CI.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 01aa8c8..8deb7e9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -9,8 +9,7 @@ jobs: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] steps: - - name: Checkout sources - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Check formatting latest uses: ./ From 5df4a89df2d52ffb51cd49f6019b2f3e9d2b099f Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 16 Jul 2022 16:57:07 -0400 Subject: [PATCH 3/4] Fix for windows probably. --- .github/workflows/{CI.yml => ci.yml} | 5 +++++ README.md | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) rename .github/workflows/{CI.yml => ci.yml} (72%) diff --git a/.github/workflows/CI.yml b/.github/workflows/ci.yml similarity index 72% rename from .github/workflows/CI.yml rename to .github/workflows/ci.yml index 8deb7e9..ede899f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,11 @@ jobs: 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 diff --git a/README.md b/README.md index 9f0d4ce..98b48ec 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,28 @@ To use a specific version, specify that with the `dprint-version` input: with: 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 +``` From ffbba8eb3b1836c6b7842e5f5d8b0b97272f45ce Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 16 Jul 2022 17:00:06 -0400 Subject: [PATCH 4/4] Better instructions --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 98b48ec..02f7de7 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ jobs: - uses: dprint/check@v2.1 ``` -If you are using a matrix, most likely you will only want to run it on one of them: +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: contains(matrix.os, 'ubuntu') + if: runner.os == 'Linux' uses: dprint/check@v2.1 ```