Skip to content

Commit

Permalink
Address comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
wanlin31 committed May 19, 2023
1 parent c46cf9e commit 2041a95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ This builds `cxx` and `go` images contain workers built from the specific
commit/branch we wish to test.

You may also specify the repo where the source code is pulled from by specifying
the repo, the following command would pull the source code from a forked repo
to build `cxx` and `go` images.
the repo. The following command pulls the source code from forked repos
`${USER}/grpc` and `${USER}/grpc-go` to build cxx and go images

```shell
bin/prepare_prebuilt_workers \
-l cxx:<user-name>/grpc:master \
-l go:<user-name>/grpc-go:master \
-l cxx:${USER}/grpc:master \
-l go:${USER}/grpc-go:master \
-p "${image_registry}" \
-t "${tag}" \
-r containers/pre_built_workers
Expand Down
11 changes: 6 additions & 5 deletions tools/cmd/prepare_prebuilt_workers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ func main() {
for _, pair := range languagesSelected {
split := strings.Split(pair, ":")

if len(split) < 2 || split[len(split)-1] == "" {
log.Fatalf("Input error in language and gitref selection, please follow the format as language:repository:gitref, for example: c++:grpc/grpc/<commit-sha>")
// C++:master will be split to 2 items, c++:grpc/grpc:master will be
// split to 3 items.
if (len(split) != 2 && len(split) != 3) || split[len(split)-1] == "" {
log.Fatalf("Input error in language and gitref selection. Please follow the format language:gitref or language:repository:gitref, for example c++:master or c++:grpc/grpc:master")
}
var spec LanguageSpec
lang := split[0]
Expand Down Expand Up @@ -148,12 +150,11 @@ func main() {
image := fmt.Sprintf("%s/%s:%s", test.preBuiltImagePrefix, lang, test.testTag)
dockerfileLocation := fmt.Sprintf("%s/%s/", test.dockerfileRoot, lang)

// build image
// Build image
log.Printf("building %s image\n", lang)
buildCommandTimeoutSeconds := 30 * 60 // 30 mins should be enough for all languages
buildDockerImage := exec.Command("timeout", fmt.Sprintf("%ds", buildCommandTimeoutSeconds), "docker", "build", dockerfileLocation, "-t", image, "--build-arg", fmt.Sprintf("GITREF=%s", spec.Gitref), "--build-arg", fmt.Sprintf("BREAK_CACHE=%s", uniqueCacheBreaker))
if spec.Repo != "" {
//cmd = fmt.Sprintf("docker build %s -t %s --build-arg REPOSITORY=%s --build-arg GITREF=%s --build-arg BREAK_CACHE=VAR", dockerfileLocation, image, spec.Repo, spec.Gitref)
buildDockerImage.Args = append(buildDockerImage.Args, "--build-arg", fmt.Sprintf("REPOSITORY=%s", spec.Repo))
}
log.Printf("Running command: %s", strings.Join(buildDockerImage.Args, " "))
Expand All @@ -168,7 +169,7 @@ func main() {
log.Printf("Succeeded building %s image: %s\n", lang, image)

if !test.buildOnly {
// push image
// Push image
log.Printf("pushing %s image\n", lang)
pushDockerImage := exec.Command("docker", "push", image)
pushOutput, err := pushDockerImage.CombinedOutput()
Expand Down

0 comments on commit 2041a95

Please sign in to comment.