Skip to content

Commit

Permalink
Bazel build/test instructions are replaced with make rules
Browse files Browse the repository at this point in the history
  • Loading branch information
chaodaiG committed Apr 20, 2022
1 parent c1fdc1a commit 96489f4
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 51 deletions.
10 changes: 2 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,13 @@ If you're not sure where to contribute or what any of these mean, please see

### Build and Test

We use [`bazel`][bazel] to build, test and deploy code in this repo. In most
We use make rules to build, test and deploy code in this repo. In most
cases you can get by just fine with:

```
bazel build //path/to/thing/in/repo/...
bazel test //path/to/thing/in/repo/...
make test
```

If you modify Go code, run `./hack/update-bazel.sh` to keep `BUILD.bazel` files
up to date

### Dependency Management

Please see [/docs/dep.md]
Expand Down Expand Up @@ -148,5 +144,3 @@ has test coverage in a variety of environments. For more info please see

[kubernetes/kubernetes]: https://github.com/kubernetes/kubernetes
[kuberenetes/enhancements/keps/sig-testing]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-testing

[bazel]: https://www.bazel.io/
21 changes: 2 additions & 19 deletions docs/dep.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,24 @@
# kubernetes/test-infra dependency management

test-infra uses [go modules] for Go dependency management.
Usage requires [bazel].

## Usage

Run [`hack/update-deps.sh`] whenever vendored dependencies change.
This takes a minute to complete, and
longer the more uncached repos golang needs to download.

Run [`make update-go-deps`] whenever vendored dependencies change.

### Updating dependencies

New dependencies causes golang to recompute the minor version used for each major version of each dependency. And
golang automatically removes dependencies that nothing imports any more.

Manually increasing the version of dependencies can be done in one of three ways:
* `bazel run //:update-patch # -- example.com/foo example.com/bar`
- update everything (or just foo and bar) to the latest patch release
- aka `vX.Y.latest`
* `bazel run //:update-minor # -- cloud.google.com/go/storage`
- update everything (or just storage) to the latest minor release
- aka `vX.latest.latest`
* Manually editing `go.mod`.

Always run `hack/update-deps.sh` after changing `go.mod` by any of these methods (or adding new imports).

See golang's [go.mod] and [dependency upgrade] docs for more details.

### Tips

Use `bazel run //:go -- whatever` rather than `go whatever` from your `$PATH` to ensure the correct version of golang is selected.
Use `hack/make-rules/go-run/arbitrary.sh whatever` rather than `go whatever` from your `$PATH` to ensure the correct version of golang is selected.

Note that using this path does not otherwise require golang to be installed on your workstation.

[bazel]: https://bazel.build/
[dependency upgrade]: https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies
[go.mod]: https://github.com/golang/go/wiki/Modules#gomod
[go modules]: https://github.com/golang/go/wiki/Modules
[`hack/update-deps.sh`]: /hack/update-deps.sh
2 changes: 1 addition & 1 deletion docs/playbooks/prow.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ to the last checked in deployment version.
If prow is at least somewhat healthy, filing and merging PR from this will
result in the rolled back version being deployed.

If not, you may need to manually run `bazel run //config/prow/cluster:production.apply`.
If not, you may need to manually run `make -C config/prow deploy-all`.


## Known Issues
Expand Down
6 changes: 3 additions & 3 deletions experiment/image-bumper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ merge them together.
## Usage

```
bazel run //experiment/image-bumper -- [options] files...
go run ./experiment/image-bumper [options] files...
```

### Options
Expand All @@ -26,14 +26,14 @@ bazel run //experiment/image-bumper -- [options] files...
### Examples

```
bazel run //experiment/image-bumper -- --image-regex gcr.io/k8s-testimages/ config/**.yaml
go run ./experiment/image-bumper --image-regex gcr.io/k8s-testimages/ config/**.yaml
```

Updates every image referencing the `k8s-testimages` project in the config directory (assuming
your shell understands `**`, e.g. fish, or bash with `globstar` enabled)

```
bazel run //experiment/image-bumper -- --image-regex gcr.io/k8s-prow/ prow/**.yaml
go run ./experiment/image-bumper --image-regex gcr.io/k8s-prow/ prow/**.yaml
```

Updates prow references to the latest versions.
2 changes: 1 addition & 1 deletion gcsweb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ the `--oauth-token-file` flag.
You can build a docker image of it by running the following command:

```
bazel run //gcsweb/cmd/gcsweb:image
go run ./gcsweb/cmd/gcsweb
```
8 changes: 0 additions & 8 deletions gencred/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@

### Script

Run using Bazel:

```console
$ bazel run //gencred -- <options>
```

Run using Golang:

```console
$ go run k8s.io/test-infra/gencred <options>
```
Expand Down
7 changes: 5 additions & 2 deletions maintenance/migratestatus/migrate-many.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
set -o errexit
set -o xtrace

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd -P)"
cd "${REPO_ROOT}"

migrate() {
if [[ -z "${2}" ]]; then
exit 1
fi
bazel-bin/maintenance/migratestatus/migratestatus \
"${REPO_ROOT}/_bin/migratestatus" \
--dry-run=false --alsologtostderr \
--org=kubernetes \
--repo=kubernetes \
Expand All @@ -30,7 +33,7 @@ migrate() {
--dest="${2}"
}

bazel build //maintenance/migratestatus || exit 1
./hack/make-rules/go-run/arbitrary.sh build -o "${REPO_ROOT}/_bin/migratestatus" ./maintenance/migratestatus || exit 1

#migrate "Bazel test" pull-test-infra-bazel
#migrate "Gubernator tests" pull-test-infra-gubernator
Expand Down
2 changes: 1 addition & 1 deletion prow/cmd/sub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func main() {
CookieFilePath: flagOptions.cookiefilePath,
CacheSize: flagOptions.inRepoConfigCacheSize,
Agent: configAgent,
GithubOptions: flagOptions.github,
GitHubOptions: flagOptions.github,
DryRun: flagOptions.dryRun,
}

Expand Down
2 changes: 1 addition & 1 deletion prow/git/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
// Package types stores types used by all git clients
package types

// PullRequestMergeType enumerates the types of merges used by Prow for either Github or Gerrit API
// PullRequestMergeType enumerates the types of merges used by Prow for either GitHub or Gerrit API
type PullRequestMergeType string

// Possible types of merges for the GitHub merge API
Expand Down
10 changes: 5 additions & 5 deletions prow/pubsub/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type InRepoConfigCacheGetter struct {
CacheSize int
Agent *config.Agent
mu sync.Mutex
GithubOptions flagutil.GitHubOptions
GitHubOptions flagutil.GitHubOptions
DryRun bool

CacheMap map[string]*config.InRepoConfigCache
Expand All @@ -82,8 +82,8 @@ func (irc *InRepoConfigCacheGetter) getCache(cloneURI, host string) (*config.InR

var key string
// We are using github with IRC
if irc.GithubOptions.Host != "" && (irc.GithubOptions.TokenPath != "" || irc.GithubOptions.AppPrivateKeyPath != "") {
key = irc.GithubOptions.Host
if irc.GitHubOptions.Host != "" && (irc.GitHubOptions.TokenPath != "" || irc.GitHubOptions.AppPrivateKeyPath != "") {
key = irc.GitHubOptions.Host
// We are using Gerrit with IRC
} else if irc.CookieFilePath != "" {
key = cloneURI
Expand All @@ -99,8 +99,8 @@ func (irc *InRepoConfigCacheGetter) getCache(cloneURI, host string) (*config.InR
var gitClientFactory git.ClientFactory
var cache *config.InRepoConfigCache
var err error
if irc.GithubOptions.TokenPath != "" || irc.GithubOptions.AppPrivateKeyPath != "" {
gitClient, err := irc.GithubOptions.GitClient(irc.DryRun)
if irc.GitHubOptions.TokenPath != "" || irc.GitHubOptions.AppPrivateKeyPath != "" {
gitClient, err := irc.GitHubOptions.GitClient(irc.DryRun)
if err != nil {
return nil, fmt.Errorf("Error getting git client: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion prow/pubsub/subscriber/subscriber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func TestHandleMessage(t *testing.T) {
CookieFilePath: "examplePath",
CacheSize: 100,
Agent: ca,
GithubOptions: flagutil.GitHubOptions{},
GitHubOptions: flagutil.GitHubOptions{},
DryRun: true,
},
}
Expand Down
2 changes: 1 addition & 1 deletion triage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ See [Main Output](#main-output). This is only a subset of the main output.

## Updating JS dependencies for the web page

See: `package.json` + `bazel run @yarn//:yarn install`
See: `package.json` + `./hack/build/ensure-node_modules.sh`

## Deployment
Triage runs as static HTML hosted in GCS that is updated as part of a [Prow Periodic](https://github.com/kubernetes/test-infra/blob/master/config/jobs/kubernetes/test-infra/test-infra-periodics.yaml#L27).
Expand Down

0 comments on commit 96489f4

Please sign in to comment.