Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/cloudbuild/dockerfiles/checkers.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ RUN pip3 install mdformat==0.7.19 \
mdformat-frontmatter==2.0.8 \
mdformat-footnote==0.1.1

RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-linux-${ARCH}" && \
RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.28.1/bazelisk-linux-${ARCH}" && \
chmod +x /usr/bin/bazelisk && \
ln -s /usr/bin/bazelisk /usr/bin/bazel
Comment on lines +57 to 59

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The bazelisk version is hardcoded and duplicated across five different Dockerfiles: checkers.Dockerfile, fedora-latest-bazel.Dockerfile, fedora-msan.Dockerfile, ubuntu-22.04.Dockerfile, and ubuntu-24.04.Dockerfile. This makes future version updates tedious and error-prone.

To improve maintainability and adhere to the project's style guide regarding code duplication, consider defining the version using a build argument at the top of each Dockerfile.

For example:

# At the top of the Dockerfile
ARG BAZELISK_VERSION=v1.28.1

...

# In the RUN command
RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-${ARCH}" && \
    chmod +x /usr/bin/bazelisk && \
    ln -s /usr/bin/bazelisk /usr/bin/bazel

This would make future updates much easier. While this refactoring is larger than the current change, it would be a valuable improvement.

References
  1. The repository style guide prefers to factor out duplicated code if it appears 3 or more times in non-test files. The bazelisk version is duplicated across 5 Dockerfiles. (link)

2 changes: 1 addition & 1 deletion ci/cloudbuild/dockerfiles/fedora-latest-bazel.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ RUN /var/tmp/ci/install-cloud-sdk.sh
ENV CLOUD_SDK_LOCATION=/usr/local/google-cloud-sdk
ENV PATH=${CLOUD_SDK_LOCATION}/bin:${PATH}

RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-linux-${ARCH}" && \
RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.28.1/bazelisk-linux-${ARCH}" && \
chmod +x /usr/bin/bazelisk && \
ln -s /usr/bin/bazelisk /usr/bin/bazel

Expand Down
2 changes: 1 addition & 1 deletion ci/cloudbuild/dockerfiles/fedora-msan.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ RUN /var/tmp/ci/install-cloud-sdk.sh
ENV CLOUD_SDK_LOCATION=/usr/local/google-cloud-sdk
ENV PATH=${CLOUD_SDK_LOCATION}/bin:${PATH}

RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-linux-${ARCH}" && \
RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.28.1/bazelisk-linux-${ARCH}" && \
chmod +x /usr/bin/bazelisk && \
ln -s /usr/bin/bazelisk /usr/bin/bazel
2 changes: 1 addition & 1 deletion ci/cloudbuild/dockerfiles/ubuntu-22.04.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ RUN /var/tmp/ci/install-cloud-sdk.sh
ENV CLOUD_SDK_LOCATION=/usr/local/google-cloud-sdk
ENV PATH=${CLOUD_SDK_LOCATION}/bin:${PATH}

RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-linux-${ARCH}" && \
RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.28.1/bazelisk-linux-${ARCH}" && \
chmod +x /usr/bin/bazelisk && \
ln -s /usr/bin/bazelisk /usr/bin/bazel
2 changes: 1 addition & 1 deletion ci/cloudbuild/dockerfiles/ubuntu-24.04.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ RUN /var/tmp/ci/install-cloud-sdk.sh
ENV CLOUD_SDK_LOCATION=/usr/local/google-cloud-sdk
ENV PATH=${CLOUD_SDK_LOCATION}/bin:${PATH}

RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-linux-${ARCH}" && \
RUN curl -o /usr/bin/bazelisk -sSL "https://github.com/bazelbuild/bazelisk/releases/download/v1.28.1/bazelisk-linux-${ARCH}" && \
chmod +x /usr/bin/bazelisk && \
ln -s /usr/bin/bazelisk /usr/bin/bazel