From 9aeeb4748aa991cc3f6d0e187ddf49fa7db70e08 Mon Sep 17 00:00:00 2001 From: Techno Freak Date: Sat, 16 Jul 2022 12:55:46 +0300 Subject: [PATCH] feat: add CI scripts and linters --- .github/workflows/actions.yaml | 32 +++++++++++++++++++++++ .github/workflows/release.yaml | 34 +++++++++++++++++++++++++ .golangci.yml | 46 ++++++++++++++++++++++++++++++++++ .goreleaser.yml | 27 ++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 .github/workflows/actions.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .golangci.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml new file mode 100644 index 0000000..e96c7e1 --- /dev/null +++ b/.github/workflows/actions.yaml @@ -0,0 +1,32 @@ +name: test +on: [push] +jobs: + go-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: actions/setup-go@v2 + with: + go-version: '^1.18.0' + - run: go version + - run: go mod download + - run: go build + go-vet: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: actions/setup-go@v2 + with: + go-version: '^1.18.0' + - run: go version + - run: go mod download + - run: go vet + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + args: --timeout 300s diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..0f57c30 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,34 @@ +name: goreleaser + +on: + push: + tags: + - '*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fetch all tags + run: git fetch --force --tags + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..11061cc --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,46 @@ +linters-settings: + gocritic: + disabled-checks: + - ifElseChain + gosec: + excludes: + - G402 + - G404 + revive: + rules: + - name: var-declaration + disabled: true + +linters: + enable-all: true + disable: + - prealloc + - lll + - dupl + - funlen + - wsl + - gomnd + - unparam + - goerr113 + - nestif + - errcheck + - golint + - scopelint + - maligned + - interfacer + - wrapcheck + - varnamelen + - tagliatelle + - exhaustivestruct + - gomoddirectives + - ireturn + - nlreturn + - cyclop + - errorlint + - noctx + - gocognit + - gochecknoglobals + - gosec + - exportloopref + - stylecheck + - exhaustruct diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..3742ecd --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,27 @@ +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:'