From 8a58d74deca5c7c8ced0c5feb63b2a01ab4ff344 Mon Sep 17 00:00:00 2001 From: cubicroot Date: Sun, 4 Aug 2024 09:54:25 +0200 Subject: [PATCH] add generate and tidy jobs --- .github/workflows/golang_quality.yaml | 32 +++++++++++++++++++++++++-- README.md | 14 ++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/workflows/golang_quality.yaml b/.github/workflows/golang_quality.yaml index f78113b..7cde40c 100644 --- a/.github/workflows/golang_quality.yaml +++ b/.github/workflows/golang_quality.yaml @@ -8,8 +8,8 @@ on: jobs: golangci: - name: lint runs-on: ubuntu-latest + if: "!startsWith(github.ref, 'refs/tags/')" steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -19,4 +19,32 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: v1.59 - working-directory: "${{ inputs.workdir }}" \ No newline at end of file + working-directory: "${{ inputs.workdir }}" + go_tidy: + runs-on: ubuntu-latest + if: "!startsWith(github.ref, 'refs/tags/')" + container: + image: cubicrootxyz/golang-ci:v1.22.5-3 + options: --user root + steps: + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Run go mod tidy + run: (cd ${{ inputs.workdir }} && go mod tidy) + - name: Run git diff + run: git diff --exit-code + go_generate: + runs-on: ubuntu-latest + if: "!startsWith(github.ref, 'refs/tags/')" + container: + image: cubicrootxyz/golang-ci:v1.22.5-3 + options: --user root + steps: + - uses: actions/checkout@v4 + - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Install mockgen + run: go install github.com/golang/mock/mockgen@v1.6.0 + - name: Run go generate + run: go generate ${{ inputs.workdir }}... + - name: Run git diff + run: git diff --exit-code \ No newline at end of file diff --git a/README.md b/README.md index c03c6dd..0543a2a 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,17 @@ jobs: dockerhub_user: ${{ secrets.DOCKERHUB_USERNAME }} dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} ``` + +## Golang + +### Code Quality + +To ensure code quality use the provided `golang_quality` workflow. It runs multiple analysis tools. + +```yaml +jobs: + golang_quality: + uses: ./.github/workflows/golang_quality.yaml + with: + workdir: "golang/application/subfolder" +``` \ No newline at end of file