mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
Add multi-module check to prow-presubmit-check
This commit is contained in:
13
Makefile
13
Makefile
@@ -6,6 +6,7 @@
|
|||||||
MYGOBIN := $(shell go env GOPATH)/bin
|
MYGOBIN := $(shell go env GOPATH)/bin
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
export PATH := $(MYGOBIN):$(PATH)
|
export PATH := $(MYGOBIN):$(PATH)
|
||||||
|
MODULES := "cmd/config" "api/" "kustomize/" "kyaml/"
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: verify-kustomize
|
all: verify-kustomize
|
||||||
@@ -24,6 +25,7 @@ verify-kustomize: \
|
|||||||
# https://github.com/kubernetes/test-infra/tree/master/config/jobs/kubernetes-sigs/kustomize
|
# https://github.com/kubernetes/test-infra/tree/master/config/jobs/kubernetes-sigs/kustomize
|
||||||
.PHONY: prow-presubmit-check
|
.PHONY: prow-presubmit-check
|
||||||
prow-presubmit-check: \
|
prow-presubmit-check: \
|
||||||
|
test-multi-module \
|
||||||
lint-kustomize \
|
lint-kustomize \
|
||||||
test-unit-kustomize-all \
|
test-unit-kustomize-all \
|
||||||
test-examples-kustomize-against-HEAD \
|
test-examples-kustomize-against-HEAD \
|
||||||
@@ -220,6 +222,17 @@ test-unit-cmd-all:
|
|||||||
test-go-mod:
|
test-go-mod:
|
||||||
./travis/check-go-mod.sh
|
./travis/check-go-mod.sh
|
||||||
|
|
||||||
|
# Environment variables are defined at
|
||||||
|
# https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md#job-environment-variables
|
||||||
|
.PHONY: test-multi-module
|
||||||
|
test-multi-module:
|
||||||
|
go install github.com/google/go-github/github
|
||||||
|
go run ./travis/module-span/multi-module-span.go \
|
||||||
|
-owner=$(REPO_OWNER) \
|
||||||
|
-repo=$(REPO_NAME) \
|
||||||
|
-pr=$(PR_NUM) \
|
||||||
|
$(MODULES)
|
||||||
|
|
||||||
.PHONY:
|
.PHONY:
|
||||||
test-examples-e2e-kustomize: $(MYGOBIN)/mdrip $(MYGOBIN)/kind
|
test-examples-e2e-kustomize: $(MYGOBIN)/mdrip $(MYGOBIN)/kind
|
||||||
( \
|
( \
|
||||||
|
|||||||
@@ -57,15 +57,30 @@ func main() {
|
|||||||
// ListAllPullRequestFiles retrieves as many files as possible for the
|
// ListAllPullRequestFiles retrieves as many files as possible for the
|
||||||
// target pull request.
|
// target pull request.
|
||||||
//
|
//
|
||||||
// NOTE: GitHub API limits ListFiles to a maximum of 3000 files. Very large
|
// Note: GitHub API limits ListFiles to a maximum of 3000 files. Very large
|
||||||
// changes which exceed this limit may pass this check even if they
|
// changes which exceed this limit may pass this check even if they
|
||||||
// do contain spanning changes.
|
// do contain spanning changes.
|
||||||
// see: https://developer.github.com/v3/pulls/#list-pull-requests-files
|
// see: https://developer.github.com/v3/pulls/#list-pull-requests-files
|
||||||
func ListAllPullRequestFiles(client *github.Client, owner *string, pullrequest *int, repo *string) ([]*github.CommitFile, error) {
|
func ListAllPullRequestFiles(client *github.Client, owner *string, pullrequest *int, repo *string) ([]*github.CommitFile, error) {
|
||||||
|
// foundFiles across all pages from github api
|
||||||
|
var foundFiles []*github.CommitFile
|
||||||
// GitHub returns the first 30 files by default, increase this value
|
// GitHub returns the first 30 files by default, increase this value
|
||||||
options := &github.ListOptions{PerPage: 3000}
|
// Note: Page 1 is the first page of results. Page 0 is an end of list mark.
|
||||||
files, _, err := client.PullRequests.ListFiles(context.Background(), *owner, *repo, *pullrequest, options)
|
// Github only returns (max) 100 results per page and PR's may exceed this
|
||||||
return files, err
|
// so loop until all pages have been enumerated.
|
||||||
|
options := &github.ListOptions{PerPage: 100, Page: 1}
|
||||||
|
for options.Page != 0 {
|
||||||
|
files, response, err := client.PullRequests.ListFiles(context.Background(), *owner, *repo, *pullrequest, options)
|
||||||
|
|
||||||
|
// If an error has occurred while querying api exit early, report error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
foundFiles = append(foundFiles, files...)
|
||||||
|
// setup next page to continue loop
|
||||||
|
options = &github.ListOptions{PerPage: 100, Page: response.NextPage}
|
||||||
|
}
|
||||||
|
return foundFiles, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountModifiedRestrictedDirectories Accepts a map of paths and the number of
|
// CountModifiedRestrictedDirectories Accepts a map of paths and the number of
|
||||||
|
|||||||
Reference in New Issue
Block a user