Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add workflow for go module check #765

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/go-mod-check.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 9 additions & 1 deletion .github/workflows/on-master-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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' }}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darrenvechain Added license check and module check results to the slack message, might need configure in the slack bot once it's merged

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are setup now @libotony

}
12 changes: 8 additions & 4 deletions .github/workflows/on-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading