Repository: knative/pkg
Pull request #1860 (2020-10-27 23:26:57)

Add a list of known-heavy things, check a few places.
Goal is to stop the bleeding by adding checks to a bunch of key libraries 😅 

knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/1860#" title="Author self-approved">mattmoor</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fpkg).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative/pkg/blob/master/OWNERS)~~ [mattmoor]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/1860#" title="Author self-approved">mattmoor</a>*, *<a href="https://github.com/knative/pkg/pull/1860#pullrequestreview-518224857" title="LGTM">tcnghia</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fpkg).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative/pkg/blob/master/OWNERS)~~ [mattmoor,tcnghia]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
codecov[bot]: # [Codecov](https://codecov.io/gh/knative/pkg/pull/1860?src=pr&el=h1) Report
> Merging [#1860](https://codecov.io/gh/knative/pkg/pull/1860?src=pr&el=desc) into [master](https://codecov.io/gh/knative/pkg/commit/4ce8016d707c468b446db9fe5058753afccbf4bd?el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `50.00%`.

[![Impacted file tree graph](https://codecov.io/gh/knative/pkg/pull/1860/graphs/tree.svg?width=650&height=150&src=pr&token=rlqpDnfxbO)](https://codecov.io/gh/knative/pkg/pull/1860?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1860      +/-   ##
==========================================
- Coverage   68.15%   68.14%   -0.02%     
==========================================
  Files         222      223       +1     
  Lines        9429     9457      +28     
==========================================
+ Hits         6426     6444      +18     
- Misses       2683     2690       +7     
- Partials      320      323       +3     
```


| [Impacted Files](https://codecov.io/gh/knative/pkg/pull/1860?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [logging/config.go](https://codecov.io/gh/knative/pkg/pull/1860/diff?src=pr&el=tree#diff-bG9nZ2luZy9jb25maWcuZ28=) | `87.50% <ø> (+3.50%)` | :arrow_up: |
| [tracing/config/tracing.go](https://codecov.io/gh/knative/pkg/pull/1860/diff?src=pr&el=tree#diff-dHJhY2luZy9jb25maWcvdHJhY2luZy5nbw==) | `75.00% <ø> (+4.68%)` | :arrow_up: |
| [depcheck/depcheck.go](https://codecov.io/gh/knative/pkg/pull/1860/diff?src=pr&el=tree#diff-ZGVwY2hlY2svZGVwY2hlY2suZ28=) | `50.00% <50.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/knative/pkg/pull/1860?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/knative/pkg/pull/1860?src=pr&el=footer). Last update [826303c...24692d4](https://codecov.io/gh/knative/pkg/pull/1860?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/depcheck/heavy.go b/depcheck/heavy.go
new file mode 100644
index 000000000..de5e81178
--- /dev/null
+++ b/depcheck/heavy.go
@@ -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",
+	}
+)


Test patch:
diff --git a/apis/depcheck_test.go b/apis/depcheck_test.go
new file mode 100644
index 000000000..d2430f89c
--- /dev/null
+++ b/apis/depcheck_test.go
@@ -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,
+	})
+}
diff --git a/logging/depcheck_test.go b/logging/depcheck_test.go
new file mode 100644
index 000000000..e0d3a8dd4
--- /dev/null
+++ b/logging/depcheck_test.go
@@ -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,
+	})
+}
diff --git a/network/depcheck_test.go b/network/depcheck_test.go
new file mode 100644
index 000000000..285de24b3
--- /dev/null
+++ b/network/depcheck_test.go
@@ -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,
+	})
+}