From 2ff2fb9a9f02065cf22b9678a611c7cc9d15aef4 Mon Sep 17 00:00:00 2001 From: Josh Komoroske Date: Tue, 2 Sep 2025 16:01:21 -0400 Subject: [PATCH] ci: lint and test all modules --- .github/workflows/build.yaml | 46 ++++++++++++++++++++++++++++ .github/workflows/golangci-lint.yaml | 28 +++++++++++++++++ .golangci.yaml | 2 ++ 3 files changed, 76 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5abb144..795df65 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,6 +7,52 @@ on: - "master" jobs: + modules: + name: modules + runs-on: ubuntu-latest + + permissions: + contents: read + + outputs: + paths: ${{ steps.find-modules.outputs.paths }} + + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - id: find-modules + shell: sh + run: echo "paths=$(find . -name go.mod | xargs dirname | jq -cnR '[inputs]')" >> $GITHUB_OUTPUT + + test: + name: test + runs-on: ubuntu-latest + needs: modules + + permissions: + contents: read + + strategy: + fail-fast: false + matrix: + paths: ${{ fromJSON(needs.modules.outputs.paths) }} + + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - shell: sh + run: |- + cd ${{ matrix.paths }} + go test -v ./... + build: name: build runs-on: ubuntu-latest diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index bb7b0b3..8c1494b 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -7,13 +7,40 @@ on: - "master" jobs: + modules: + name: modules + runs-on: ubuntu-latest + + permissions: + contents: read + + outputs: + paths: ${{ steps.find-modules.outputs.paths }} + + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - id: find-modules + shell: sh + run: echo "paths=$(find . -name go.mod | xargs dirname | jq -cnR '[inputs]')" >> $GITHUB_OUTPUT + lint: name: golangci-lint runs-on: ubuntu-latest + needs: modules permissions: contents: read + strategy: + fail-fast: false + matrix: + paths: ${{ fromJSON(needs.modules.outputs.paths) }} + steps: - uses: actions/checkout@v5 @@ -25,3 +52,4 @@ jobs: with: # https://github.com/golangci/golangci-lint/releases/tag/v2.4.0 version: v2.4.0 + working-directory: ${{ matrix.paths }} diff --git a/.golangci.yaml b/.golangci.yaml index b3d1da6..3b96f15 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -23,7 +23,9 @@ linters: - exhaustruct - forbidigo - gochecknoglobals + - gosec - noinlineerr + - varnamelen - wrapcheck # Linters that are deprecated.