From bbbd487064d53a998babafd40ecab00f8571dae6 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 11 Oct 2023 21:03:07 +0300 Subject: [PATCH] CI: add more stict checking --- .editorconfig | 28 ++++++++++++++++++ .github/dependabot.yml | 11 +++++++ .github/workflows/editorconfig.yml | 47 ++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/editorconfig.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5f4be94 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,28 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = tab +indent_size = 4 +insert_final_newline = true +tab_width = 4 +trim_trailing_whitespace = true + +[*.md] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = false + +[*.{nix,yml,yaml}] +indent_style = space +indent_size = 2 +tab_width = 2 + +[*.{diff,patch}] +end_of_line = unset +insert_final_newline = unset +trim_trailing_whitespace = unset + +[*.lock] +indent_size = unset diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..162fed0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 15 + reviewers: + - NotAShelf + assignees: + - NotAShelf diff --git a/.github/workflows/editorconfig.yml b/.github/workflows/editorconfig.yml new file mode 100644 index 0000000..5b05f8b --- /dev/null +++ b/.github/workflows/editorconfig.yml @@ -0,0 +1,47 @@ +name: "Check validity of .editorconfig" + +permissions: read-all + +on: + pull_request: + +jobs: + check-editorconfig: + runs-on: ubuntu-latest + if: "!contains(github.event.pull_request.title, '[skip treewide]')" + steps: + - name: Get list of changed files from PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh api \ + repos/NixOS/nixpkgs/pulls/${{github.event.number}}/files --paginate \ + | jq '.[] | select(.status != "removed") | .filename' \ + > "$HOME/changed_files" + + - name: Print list of changed files + run: | + cat "$HOME/changed_files" + + - name: Checkout + uses: actions/checkout@v4 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + + - name: Install Nix + uses: cachix/install-nix-action@v23 + with: + # nixpkgs commit is pinned so that it doesn't break + # editorconfig-checker 2.4.0 + nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/c473cc8714710179df205b153f4e9fa007107ff9.tar.gz + + - name: Checking EditorConfig + run: | + cat "$HOME/changed_files" | nix-shell -p editorconfig-checker --run 'xargs -r editorconfig-checker -disable-indent-size' + + - if: ${{ failure() }} + shell: bash + run: | + echo "::error:: Current formatting does not fit convention provided by .editorconfig located in the project root." + echo "Please make sure your editor properly integrates editorconfig. See https://editorconfig.org/#download for more." + exit 1