Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

ci: go mod tidy #1771

Merged
merged 4 commits into from
Sep 30, 2020
Merged
Changes from 3 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
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -42,6 +42,16 @@ jobs:
version: v1.30
args: --timeout 5m

tidy:
name: Tidy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: go mod tidy
run: |
make go-mod-tidy

build:
name: Go build
runs-on: ubuntu-latest
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ clean-osm:
@rm -rf bin/osm

.PHONY: go-checks
go-checks: go-lint go-fmt
go-checks: go-lint go-fmt go-mod-tidy

.PHONY: go-vet
go-vet:
@@ -67,6 +67,10 @@ go-lint:
go-fmt:
go fmt ./...

.PHONY: go-mod-tidy
go-mod-tidy:
./scripts/go-mod-tidy.sh

.PHONY: go-test
go-test:
./scripts/go-test.sh
7 changes: 7 additions & 0 deletions scripts/go-mod-tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

go mod tidy
if ! git diff --exit-code go.mod go.sum ; then
echo -e "\nPlease run 'go mod tidy' to clean up dependencies"
Copy link
Member

Choose a reason for hiding this comment

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

This script is already running go mod tidy, so is there a reason why it should be run again as echoed in L5?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This script is also used by the CI so this is the message to let users know how to pass this check.

exit 1
fi
10 changes: 10 additions & 0 deletions scripts/pre-push-hook
Original file line number Diff line number Diff line change
@@ -22,6 +22,16 @@ then
exit 1
fi

# run go mod tidy
make go-mod-tidy >commit_logs/go_mod.log 2>&1
if [ $? -ne 0 ]
then
echo "'go mod tidy': has detected potential issues in the project."
echo "Details:"
cat commit_logs/go_mod.log
exit 1
fi

# run go test
go test -v ./... >commit_logs/unit_tests.log 2>&1
if [ $? -ne 0 ]