From e80893eb3d26cd962a1e9b19864cdd32bfe1140e Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 16 Dec 2020 16:46:54 +1100 Subject: [PATCH] bazelisk-build: specify targets as list Specify bazelisk_targets as a list, and join the targets as space-separated in the build command. This is used in the follow-on Ie0a165cc6ffc765c03457691901a1dd41ce99d5a. While we are here, remove the build-gerrit.sh script that isn't used any more, along with the step that installs it. Also, refactor the tasks to use include_role (this is also used in the follow on). Change-Id: I4f3908e75cbbb7673135a2717f9e51f099a4860e --- docker/gerrit/bazel/build-gerrit.sh | 18 ------------------ playbooks/zuul/gerrit/repos.yaml | 5 ----- playbooks/zuul/gerrit/run.yaml | 17 ++++++++--------- roles/bazelisk-build/README.rst | 8 +------- roles/bazelisk-build/defaults/main.yaml | 3 ++- roles/bazelisk-build/tasks/main.yaml | 2 +- 6 files changed, 12 insertions(+), 41 deletions(-) delete mode 100755 docker/gerrit/bazel/build-gerrit.sh diff --git a/docker/gerrit/bazel/build-gerrit.sh b/docker/gerrit/bazel/build-gerrit.sh deleted file mode 100755 index eb7049b173..0000000000 --- a/docker/gerrit/bazel/build-gerrit.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# Note this script doesn't seem to be used by the image builds. -# The system-config/roles/bazelisk-build role seems to be used instead. - -set +x - -for attempt in seq 1 3 ; do - bazel build plugins/javamelody:javamelody-deps_deploy.jar release \ - --define=ABSOLUTE_JAVABASE=/usr/lib/jvm/java-8-openjdk-amd64 \ - --javabase=@bazel_tools//tools/jdk:absolute_javabase \ - --host_javabase=@bazel_tools//tools/jdk:absolute_javabase \ - --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ - --java_toolchain=@bazel_tools//tools/jdk:toolchain_vanilla \ - $@ - result=$? -done -exit $result diff --git a/playbooks/zuul/gerrit/repos.yaml b/playbooks/zuul/gerrit/repos.yaml index 11ed8c5274..480f8f027b 100644 --- a/playbooks/zuul/gerrit/repos.yaml +++ b/playbooks/zuul/gerrit/repos.yaml @@ -69,8 +69,3 @@ force: yes src: javamelody/external_plugin_deps.bzl path: /home/zuul/src/gerrit.googlesource.com/gerrit/plugins/external_plugin_deps.bzl - - - name: Move build script into main gerrit source dir - command: "mv docker/gerrit/bazel/build-gerrit.sh /home/zuul/src/gerrit.googlesource.com/gerrit" - args: - chdir: /home/zuul/src/opendev.org/opendev/system-config diff --git a/playbooks/zuul/gerrit/run.yaml b/playbooks/zuul/gerrit/run.yaml index 921791f402..54e05745a2 100644 --- a/playbooks/zuul/gerrit/run.yaml +++ b/playbooks/zuul/gerrit/run.yaml @@ -6,21 +6,20 @@ # Disable the x/ redirection since we have x/ projects sed -i -e 's|"/x/\*"\,$|//"/x/*",|g' java/com/google/gerrit/httpd/raw/StaticModule.java -- hosts: all - roles: - - role: bazelisk-build - zuul_work_dir: /home/zuul/src/gerrit.googlesource.com/gerrit + - name: Run bazelisk build + include_role: + name: bazelisk-build + vars: + zuul_work_dir: /home/zuul/src/gerrit.googlesource.com/gerrit -- hosts: all - tasks: - name: Install OpenDev theme plugin copy: src: opendevtheme.html dest: /home/zuul/src/gerrit.googlesource.com/gerrit/opendevtheme.html -- hosts: all - roles: - - build-docker-image + - name: Build docker image + include_role: + name: build-docker-image - hosts: localhost roles: diff --git a/roles/bazelisk-build/README.rst b/roles/bazelisk-build/README.rst index cbc88ca2b7..196c5f2440 100644 --- a/roles/bazelisk-build/README.rst +++ b/roles/bazelisk-build/README.rst @@ -5,16 +5,10 @@ Runs bazelisk build with the specified targets. **Role Variables** .. zuul:rolevar:: bazelisk_targets - :default: "release" + :default: ["release"] The bazelisk targets to build. -.. zuul:rolevar:: bazelisk_test_targets - :default: "" - - The bazelisk targets to test. ``bazelisk test`` will only be run - if this value is not the empty string. - .. zuul:rolevar:: bazelisk_executable :default: bazelisk diff --git a/roles/bazelisk-build/defaults/main.yaml b/roles/bazelisk-build/defaults/main.yaml index 8260a2c2da..358d2b1447 100644 --- a/roles/bazelisk-build/defaults/main.yaml +++ b/roles/bazelisk-build/defaults/main.yaml @@ -1,3 +1,4 @@ -bazelisk_targets: release +bazelisk_targets: + - release bazelisk_executable: bazelisk zuul_work_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir}}" diff --git a/roles/bazelisk-build/tasks/main.yaml b/roles/bazelisk-build/tasks/main.yaml index 7fd911e868..2a6c7f9dc1 100644 --- a/roles/bazelisk-build/tasks/main.yaml +++ b/roles/bazelisk-build/tasks/main.yaml @@ -3,7 +3,7 @@ set -x java -fullversion {{ bazelisk_executable }} version - {{ bazelisk_executable }} build --spawn_strategy=standalone --genrule_strategy=standalone {{ bazelisk_targets }} + {{ bazelisk_executable }} build --spawn_strategy=standalone --genrule_strategy=standalone {{ bazelisk_targets|join(' ') }} if [[ -f bazel-bin/plugins/javamelody/javamelody-deps_deploy.jar ]] ; then # versions 2.14, 2.15, and 2.16 generate this file cp bazel-bin/plugins/javamelody/javamelody-deps_deploy.jar javamelody-deps_deploy.jar