From 2be499f668e8d6b0f11f75d91c71b8a50822a322 Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Wed, 17 Aug 2022 07:52:23 +0200 Subject: [PATCH] chore: add checks --- .github/workflows/checks.yml | 65 ++++++++++++++++++++++++++++++++ .github/workflows/goreleaser.yml | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/checks.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..dec1b2c --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,65 @@ +# This workflow runs all dockerfiles in this repo +name: checks + +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ v2 ] + pull_request: + branches: [ v2 ] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + GO_VERSION: 1.19 + GOLANGCI_LINT_VERSION: v1.48 + +jobs: + matrix: + name: matrix + runs-on: ubuntu-latest + outputs: + gomod: ${{ steps.gomod.outputs.matrix }} + steps: + - uses: actions/checkout@v3 + - id: gomod + run: | + matrix=$(find . -type f -name "go.mod" -print0 | xargs -0 -n1 dirname | sort --unique | jq -R -s -c 'split("\n")[:-1]') + echo "${matrix}" + echo "::set-output name=matrix::${matrix}" + lint: + name: lint + needs: matrix + runs-on: ubuntu-latest + strategy: + matrix: + gomod: ${{ fromJson(needs.matrix.outputs.gomod) }} + env: + GOFLAGS: -mod=readonly + GOPROXY: https://proxy.golang.org + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + - uses: golangci/golangci-lint-action@v3.2.0 + with: + version: ${{ env.GOLANGCI_LINT_VERSION }} + working-directory: ${{ matrix.gomod }} + test: + name: test + needs: matrix + runs-on: ubuntu-latest + strategy: + matrix: + gomod: ${{ fromJson(needs.matrix.outputs.gomod) }} + env: + GOFLAGS: -mod=readonly + GOPROXY: https://proxy.golang.org + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + - run: go test -v ./... + diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index a0046e6..44cb545 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.19 - name: Unshallow run: git fetch --prune --unshallow