From d4152e8a5fa18374636cc71b8af28d2b2a17b742 Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 30 May 2024 15:57:40 +0800 Subject: [PATCH 1/2] add workflow for go module check --- .github/workflows/go-mod-check.yaml | 30 +++++++++++++++++++++++++ .github/workflows/on-master-commit.yaml | 10 ++++++++- .github/workflows/on-pull-request.yaml | 12 ++++++---- 3 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/go-mod-check.yaml diff --git a/.github/workflows/go-mod-check.yaml b/.github/workflows/go-mod-check.yaml new file mode 100644 index 000000000..67e88ea27 --- /dev/null +++ b/.github/workflows/go-mod-check.yaml @@ -0,0 +1,30 @@ +name: Go module check + +on: + # Should only be used by other workflows + workflow_call: + +permissions: + contents: read + +jobs: + go-mod-check: + name: ensure go mod is tidy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.22' + cache: false + + - name: go mod tidy + run: | + go mod tidy + + - name: check go module + run: | + if ! git diff --exit-code --quiet; then + echo "Go module is not tidy, please run 'go mod tidy' and commit the changes" + exit 1 + fi diff --git a/.github/workflows/on-master-commit.yaml b/.github/workflows/on-master-commit.yaml index 80fc19de2..3c7671ab4 100644 --- a/.github/workflows/on-master-commit.yaml +++ b/.github/workflows/on-master-commit.yaml @@ -20,6 +20,10 @@ jobs: name: Lint uses: ./.github/workflows/lint-go.yaml + module-check: + name: Go Module Check + uses: ./.github/workflows/go-mod-check.yaml + run-e2e-tests: name: E2E Tests uses: ./.github/workflows/test-e2e.yaml @@ -64,10 +68,12 @@ jobs: needs: - publish-docker-image - generate-tags + - license-check - lint + - module-check - run-unit-tests - run-e2e-tests - if: always() && (needs.publish-docker-image.result != 'success' || needs.run-unit-tests.result != 'success' || needs.lint.result != 'success' || needs.run-e2e-tests.result != 'success' || needs.license-check.result != 'success') + if: always() && (needs.publish-docker-image.result != 'success' || needs.run-unit-tests.result != 'success' || needs.lint.result != 'success' || needs.run-e2e-tests.result != 'success' || needs.license-check.result != 'success' || needs.module-check.result != 'success') runs-on: ubuntu-latest steps: - name: Checkout code @@ -95,4 +101,6 @@ jobs: "repository": "${{ github.repository }}", "commit-author": "${{ github.event.head_commit.author.name }}", "lint-status": "${{ needs.lint.result != 'success' && ':alert: Failure' || ':white_check_mark: Success' }}" + "license-check": "${{ needs.license-check.result != 'success' && ':alert: Failure' || ':white_check_mark: Success' }}" + "module-check": "${{ needs.module-check.result != 'success' && ':alert: Failure' || ':white_check_mark: Success' }}" } diff --git a/.github/workflows/on-pull-request.yaml b/.github/workflows/on-pull-request.yaml index 79dc2a5f4..57cee70ee 100644 --- a/.github/workflows/on-pull-request.yaml +++ b/.github/workflows/on-pull-request.yaml @@ -20,14 +20,18 @@ jobs: name: License Check uses: ./.github/workflows/license-check.yaml - run-e2e-tests: - name: E2E Tests - uses: ./.github/workflows/test-e2e.yaml - lint: name: Lint uses: ./.github/workflows/lint-go.yaml + module-check: + name: Go Module Check + uses: ./.github/workflows/go-mod-check.yaml + + run-e2e-tests: + name: E2E Tests + uses: ./.github/workflows/test-e2e.yaml + # This doesn't publish the image, it just tests the publishing workflow (build the image / tags / labels) test-docker-publish: name: Test Docker Publish From bbdee756da22e2186b52019adab160e45b92c499 Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 30 May 2024 15:59:49 +0800 Subject: [PATCH 2/2] tidy go module --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 59cd1bc5b..51afb43eb 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( github.com/pkg/errors v0.8.0 github.com/pmezard/go-difflib v1.0.0 github.com/prometheus/client_golang v1.18.0 + github.com/prometheus/client_model v0.5.0 github.com/prometheus/common v0.45.0 github.com/qianbin/directcache v0.9.7 github.com/stretchr/testify v1.8.4 @@ -53,7 +54,6 @@ require ( github.com/mattn/go-colorable v0.0.9 // indirect github.com/mattn/go-runewidth v0.0.4 // indirect github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect - github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rjeczalik/notify v0.9.3 // indirect golang.org/x/net v0.23.0 // indirect