From 3608cd8e4ebd60af0e9431e1d33df6f4044b0d0d Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Thu, 6 Apr 2023 17:52:40 -0700 Subject: [PATCH] style: Add formatting rules and action --- .editorconfig | 2 ++ .github/workflows/format.yml | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .github/workflows/format.yml diff --git a/.editorconfig b/.editorconfig index e6a12b2..0efa990 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,6 +6,8 @@ root = true # Unix-style newlines with a newline ending every file [*] end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true insert_final_newline = true # Matches multiple files with brace expansion notation diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..67e9384 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,25 @@ +name: "Check EditorConfig Format" +on: + push: + branches: + - "*" + pull_request: + branches: + - "*" +jobs: + lint: + runs-on: "ubuntu-22.04" + steps: + - name: "Get Changed Files" + id: "files" + uses: "masesgroup/retrieve-changed-files@v2" + with: + format: "json" + - name: Check out code. + uses: actions/checkout@v2 + - name: "Check EditorConfig Lint" + run: | + sudo apt install -y jq golang + go install 'github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest' + readarray -t changed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')" + ~/go/bin/editorconfig-checker ${changed_files[@]}