Add a list of known-heavy things, check a few places. (#1860)

This commit is contained in:
Matt Moore 2020-10-27 16:38:34 -07:00 committed by GitHub
parent 826303ca06
commit b8a7aae928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 122 additions and 0 deletions

34
apis/depcheck_test.go Normal file
View File

@ -0,0 +1,34 @@
/*
Copyright 2020 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package apis_test
import (
"testing"
"knative.dev/pkg/depcheck"
)
func TestNoDeps(t *testing.T) {
depcheck.AssertNoDependency(t, map[string][]string{
"knative.dev/pkg/apis": depcheck.KnownHeavyDependencies,
"knative.dev/pkg/apis/duck": depcheck.KnownHeavyDependencies,
"knative.dev/pkg/apis/duck/ducktypes": depcheck.KnownHeavyDependencies,
"knative.dev/pkg/apis/duck/v1alpha1": depcheck.KnownHeavyDependencies,
"knative.dev/pkg/apis/duck/v1beta1": depcheck.KnownHeavyDependencies,
"knative.dev/pkg/apis/duck/v1": depcheck.KnownHeavyDependencies,
})
}

28
depcheck/heavy.go Normal file
View File

@ -0,0 +1,28 @@
/*
Copyright 2020 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package depcheck
var (
KnownHeavyDependencies = []string{
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
// As of 2020/10/27 this adds about 13MB to overall binary size.
"k8s.io/client-go/kubernetes",
// As of 2020/10/27 this adds about 7MB to overall binary size.
"contrib.go.opencensus.io/exporter/stackdriver",
}
)

29
logging/depcheck_test.go Normal file
View File

@ -0,0 +1,29 @@
/*
Copyright 2020 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package logging_test
import (
"testing"
"knative.dev/pkg/depcheck"
)
func TestNoDeps(t *testing.T) {
depcheck.AssertNoDependency(t, map[string][]string{
"knative.dev/pkg/logging": depcheck.KnownHeavyDependencies,
})
}

31
network/depcheck_test.go Normal file
View File

@ -0,0 +1,31 @@
/*
Copyright 2020 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package network_test
import (
"testing"
"knative.dev/pkg/depcheck"
)
func TestNoDeps(t *testing.T) {
depcheck.AssertNoDependency(t, map[string][]string{
"knative.dev/pkg/network": depcheck.KnownHeavyDependencies,
"knative.dev/pkg/network/handlers": depcheck.KnownHeavyDependencies,
"knative.dev/pkg/network/prober": depcheck.KnownHeavyDependencies,
})
}