Bläddra i källkod

Merge pull request #432 from mautrix/pre-commit-config

pre-commit: add config and add lint job to CI
Sumner Evans 3 år sedan
förälder
incheckning
61409ce2bc
3 ändrade filer med 44 tillägg och 0 borttagningar
  1. 29 0
      .github/workflows/go.yml
  2. 1 0
      .gitignore
  3. 14 0
      .pre-commit-config.yaml

+ 29 - 0
.github/workflows/go.yml

@@ -0,0 +1,29 @@
+name: Go
+
+on: [push, pull_request]
+
+jobs:
+  lint:
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        go-version: [1.17]
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Set up Go ${{ matrix.go-version }}
+        uses: actions/setup-go@v2
+        with:
+          go-version: ${{ matrix.go-version }}
+
+      - name: Install goimports
+        run: |
+          go install golang.org/x/tools/cmd/goimports@latest
+          export PATH="$HOME/go/bin:$PATH"
+
+      - name: Install pre-commit
+        run: pip install pre-commit
+
+      - name: Lint
+        run: pre-commit run -a

+ 1 - 0
.gitignore

@@ -1,6 +1,7 @@
 .idea
 
 *.yaml
+!.pre-commit-config.yaml
 !example-config.yaml
 
 *.session

+ 14 - 0
.pre-commit-config.yaml

@@ -0,0 +1,14 @@
+repos:
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v4.1.0
+    hooks:
+      - id: trailing-whitespace
+        exclude_types: [markdown]
+      - id: end-of-file-fixer
+      - id: check-yaml
+      - id: check-added-large-files
+
+  - repo: https://github.com/tekwizely/pre-commit-golang
+    rev: v1.0.0-beta.5
+    hooks:
+      - id: go-imports-repo