Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Commit

Permalink
Change Github Action to Check PRs Without Commiting Changes (#1439)
Browse files Browse the repository at this point in the history
* Use go run instead of installing goimports with go get

This prevents goimports related dependencies from being added to go.mod

* Change format job to check for diffs without commiting changes

* go fmt
  • Loading branch information
ian-mi committed Jul 14, 2020
1 parent d37af7b commit e76376b
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 30 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/check-and-update.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check PR
on: pull_request
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.1
- uses: actions/setup-go@v2.1.0
with:
go-version: 1.14.4
- name: gofmt
run: |
DIFFS=$(find -name '*.go' -type f \! -name '*.pb.go' -exec gofmt -s -l {} \+ -o \( -path './vendor' -o -path './third_party' \) -prune)
if [[ -n $DIFFS ]]; then
echo ::error::Diffs reported by gofmt
echo ::group::Files with diffs
echo $DIFFS
echo ::endgroup::
exit 1
fi
- name: goimports
run: |
DIFFS=$(find -name '*.go' \! -name wire_gen.go \! -name '*.pb.go' -exec go run golang.org/x/tools/cmd/goimports -l {} \+ -o \( -path ./vendor -o -path ./third_party \) -prune)
if [[ -n $DIFFS ]]; then
echo ::error::Diffs reported by goimports
echo ::group::Files with diffs
echo $DIFFS
echo ::endgroup::
exit 1
fi
1 change: 0 additions & 1 deletion pkg/apis/duck/validations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ func TestCheckImmutableClusterNameAnnotation(t *testing.T) {
}
}


func TestValidateCredential(t *testing.T) {
testCases := []struct {
name string
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/events/v1/cloudstoragesource_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,3 @@ func (ss *CloudStorageSourceSpec) SetDefaults(ctx context.Context) {
ss.EventTypes = allEventTypes
}
}


1 change: 0 additions & 1 deletion pkg/apis/events/v1/cloudstoragesource_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ func TestCloudStorageSource_SetDefaults(t *testing.T) {
})
}
}

1 change: 0 additions & 1 deletion pkg/apis/events/v1/cloudstoragesource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,3 @@ func (*CloudStorageSource) GetConditionSet() apis.ConditionSet {
func (s *CloudStorageSource) GetStatus() *duckv1.Status {
return &s.Status.Status
}

2 changes: 1 addition & 1 deletion pkg/apis/events/v1/cloudstoragesource_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/knative-gcp/pkg/apis/duck/v1"
v1 "github.com/google/knative-gcp/pkg/apis/duck/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/pkg/apis"
)
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/events/v1/cloudstoragesource_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ func (current *CloudStorageSource) CheckImmutableFields(ctx context.Context, ori
}
return nil
}

1 change: 0 additions & 1 deletion pkg/apis/events/v1/implements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ func TestTypesImplements(t *testing.T) {
}
}
}

0 comments on commit e76376b

Please sign in to comment.