diff --git a/.zuul.yaml b/.zuul.yaml index 330919209c..0d126535aa 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -200,6 +200,7 @@ description: Build a gerrit image. parent: system-config-build-image pre-run: playbooks/zuul/gerrit/repos.yaml + run: playbooks/zuul/gerrit/run.yaml required-projects: &gerrit_projects_2_15 - name: gerrit.googlesource.com/gerrit override-checkout: stable-2.15 @@ -239,6 +240,7 @@ description: Build and upload a gerrit image. parent: system-config-upload-image pre-run: playbooks/zuul/gerrit/repos.yaml + run: playbooks/zuul/gerrit/run.yaml required-projects: *gerrit_projects_2_15 vars: *gerrit_vars_2_15 files: *gerrit_files_2_15 @@ -256,6 +258,7 @@ description: Build a gerrit image. parent: system-config-build-image pre-run: playbooks/zuul/gerrit/repos.yaml + run: playbooks/zuul/gerrit/run.yaml required-projects: &gerrit_projects_2_16 - name: gerrit.googlesource.com/gerrit override-checkout: stable-2.16 @@ -299,6 +302,7 @@ description: Build and upload a gerrit image. parent: system-config-upload-image pre-run: playbooks/zuul/gerrit/repos.yaml + run: playbooks/zuul/gerrit/run.yaml required-projects: *gerrit_projects_2_16 vars: *gerrit_vars_2_16 files: *gerrit_files_2_16 @@ -316,6 +320,7 @@ description: Build a gerrit image. parent: system-config-build-image pre-run: playbooks/zuul/gerrit/repos.yaml + run: playbooks/zuul/gerrit/run.yaml required-projects: &gerrit_projects_3_0 - name: gerrit.googlesource.com/gerrit override-checkout: stable-3.0 @@ -371,6 +376,7 @@ description: Build and upload a gerrit image. parent: system-config-upload-image pre-run: playbooks/zuul/gerrit/repos.yaml + run: playbooks/zuul/gerrit/run.yaml required-projects: *gerrit_projects_3_0 vars: *gerrit_vars_3_0 files: *gerrit_files_3_0 @@ -392,7 +398,8 @@ parent: system-config-build-image pre-run: - playbooks/zuul/gerrit/repos.yaml - - playbooks/zuul/gerrit/jgit.yaml + - playbooks/zuul/gerrit/submodules.yaml + run: playbooks/zuul/gerrit/run.yaml required-projects: &gerrit_projects_master - opendev/system-config - gerrit.googlesource.com/jgit @@ -412,6 +419,7 @@ - gerrit.googlesource.com/plugins/reviewnotes - gerrit.googlesource.com/plugins/singleusergroup - gerrit.googlesource.com/plugins/webhooks + - gerrit.googlesource.com/polymer-bridges vars: &gerrit_vars_master zuul_work_dir: src/opendev.org/opendev/system-config docker_images: @@ -447,7 +455,8 @@ parent: system-config-upload-image pre-run: - playbooks/zuul/gerrit/repos.yaml - - playbooks/zuul/gerrit/jgit.yaml + - playbooks/zuul/gerrit/submodules.yaml + run: playbooks/zuul/gerrit/run.yaml required-projects: *gerrit_projects_master vars: *gerrit_vars_master files: *gerrit_files_master diff --git a/docker/gerrit/bazel/Dockerfile b/docker/gerrit/bazel/Dockerfile index c0f7b51f99..e7bfb78961 100644 --- a/docker/gerrit/bazel/Dockerfile +++ b/docker/gerrit/bazel/Dockerfile @@ -13,14 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM docker.io/opendevorg/bazel as builder - -USER builder -COPY . /usr/src - -ARG BAZEL_OPTS -RUN cd /usr/src && bash build-gerrit.sh - FROM docker.io/opendevorg/gerrit-base -COPY --from=builder /usr/src/bazel-bin/release.war /var/gerrit/bin/gerrit.war +COPY release.war /var/gerrit/bin/gerrit.war diff --git a/playbooks/zuul/gerrit/jgit.yaml b/playbooks/zuul/gerrit/jgit.yaml deleted file mode 100644 index 30726b33a8..0000000000 --- a/playbooks/zuul/gerrit/jgit.yaml +++ /dev/null @@ -1,7 +0,0 @@ -- hosts: all - tasks: - - - name: Checkout jgit submodule - command: "git submodule update --init modules/jgit" - args: - chdir: /home/zuul/src/gerrit.googlesource.com/gerrit diff --git a/playbooks/zuul/gerrit/repos.yaml b/playbooks/zuul/gerrit/repos.yaml index ba5d1fbae3..5dd4a53faf 100644 --- a/playbooks/zuul/gerrit/repos.yaml +++ b/playbooks/zuul/gerrit/repos.yaml @@ -1,5 +1,18 @@ - hosts: all + roles: + - ensure-java + - role: install-nodejs + node_version: 10 + - ensure-bazelisk tasks: + - name: Install essential build packages + become: true + package: + name: + - build-essential + - zip + - unzip + state: present - name: Move plugin repos into gerrit tree command: "mv -f {{ item }} ../gerrit/plugins" diff --git a/playbooks/zuul/gerrit/run.yaml b/playbooks/zuul/gerrit/run.yaml new file mode 100644 index 0000000000..59eabcf726 --- /dev/null +++ b/playbooks/zuul/gerrit/run.yaml @@ -0,0 +1,9 @@ +- hosts: all + roles: + - role: bazelisk-build + zuul_work_dir: /home/zuul/src/gerrit.googlesource.com/gerrit + - build-docker-image + +- hosts: localhost + roles: + - pause-buildset-registry diff --git a/playbooks/zuul/gerrit/submodules.yaml b/playbooks/zuul/gerrit/submodules.yaml new file mode 100644 index 0000000000..6ca4cfaafb --- /dev/null +++ b/playbooks/zuul/gerrit/submodules.yaml @@ -0,0 +1,10 @@ +- hosts: all + tasks: + + - name: Checkout submodules + shell: "[ -d {{ item }} ] && git submodule update --init {{ item }}" + args: + chdir: /home/zuul/src/gerrit.googlesource.com/gerrit + loop: + - modules/jgit + - polymer-bridges diff --git a/roles/bazelisk-build/README.rst b/roles/bazelisk-build/README.rst new file mode 100644 index 0000000000..7c141329d8 --- /dev/null +++ b/roles/bazelisk-build/README.rst @@ -0,0 +1,26 @@ +Run bazelisk build + +Runs bazelisk build with the specified targets. + +**Role Variables** + +.. zuul:rolevar:: bazelisk_targets + :default: "" + + 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 + + The path to the bazelisk executable. + +.. zuul:rolevar:: zuul_work_dir + :default: {{ ansible_user_dir }}/{{ zuul.project.src_dir}} + + The working directory in which to run bazelisk. diff --git a/roles/bazelisk-build/defaults/main.yaml b/roles/bazelisk-build/defaults/main.yaml new file mode 100644 index 0000000000..8260a2c2da --- /dev/null +++ b/roles/bazelisk-build/defaults/main.yaml @@ -0,0 +1,3 @@ +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 new file mode 100644 index 0000000000..42215e3b37 --- /dev/null +++ b/roles/bazelisk-build/tasks/main.yaml @@ -0,0 +1,10 @@ +- name: Run bazelisk build + shell: | + java -fullversion + {{ bazelisk_executable }} version + {{ bazelisk_executable }} build --spawn_strategy=standalone --genrule_strategy=standalone {{ bazelisk_targets }} + # release.war is a symlink. We want an actual file so that docker copy works right. + cp bazel-bin/release.war release.war + args: + executable: /bin/bash + chdir: "{{ zuul_work_dir }}"