Skip to content

Conversation

@cgwalters
Copy link
Contributor

We're going to use it in most of our repos, so stop copying it manually.

(At some point we may publish it, but this is a useful
intermediate step)

We're going to use it in most of our repos, so stop copying
it manually.

(At some point we may publish it, but this is a useful
 intermediate step)

Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters cgwalters enabled auto-merge (squash) November 4, 2025 19:55
@gemini-code-assist
Copy link

Summary of Changes

Hello @cgwalters, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to avoid manual copying of the bootc-ubuntu-setup action across multiple repositories by centralizing it. The action configures the runner environment, manages disk space, and provides virtualization support.

Highlights

  • Action Synchronization: This pull request introduces a new GitHub action, bootc-ubuntu-setup, to centralize and standardize the setup process for Ubuntu-based runners across multiple repositories.
  • Runner Environment Configuration: The action performs several key tasks, including freeing up disk space by removing unwanted packages and directories, updating podman and installing just, enabling unprivileged /dev/kvm access, setting the architecture variable, and setting up Rust caching.
  • Libvirt and Virtualization Support: The action conditionally installs libvirt and the virtualization stack if requested via the libvirt input, which also installs bcvk and configures file descriptor limits.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new reusable GitHub action, bootc-ubuntu-setup, to standardize the setup of Ubuntu runners. This is a great initiative for centralizing CI logic. My review has identified a critical issue in the disk cleanup logic where a background task is unintentionally run synchronously, an inefficiency in package removal, and several medium-severity suggestions to improve the action's maintainability, flexibility, and security. Please see the detailed comments below.

Comment on lines +34 to +36
for x in ${unwanted_pkgs[@]}; do
/bin/time -f '%E %C' sudo apt-get remove -y $x
done

Choose a reason for hiding this comment

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

high

Calling apt-get remove inside a for loop is inefficient because it starts a new process for each package. You can significantly speed up this step by passing all packages to a single apt-get remove command. I also recommend adding the --purge flag to also remove configuration files, which will free up more disk space.

        /bin/time -f '%E %C' sudo apt-get remove --purge -y "${unwanted_pkgs[@]}"

Comment on lines +43 to +44
IDV=$(. /usr/lib/os-release && echo ${ID}-${VERSION_ID})
test "${IDV}" = "ubuntu-24.04"

Choose a reason for hiding this comment

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

medium

The action hardcodes a check for ubuntu-24.04 and will fail if run on any other version. This limits the action's reusability and will require manual updates for future Ubuntu releases. Consider making this more flexible, for instance by supporting a range of versions, or at least clearly documenting this strict version requirement in the action's main description.

shell: bash
run: |
set -xeuo pipefail
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules

Choose a reason for hiding this comment

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

medium

The udev rule sets permissions for /dev/kvm to 0666, making it world-writable. While this is a convenient approach for CI environments and is the default on some distributions like Fedora, it is less secure than the default on Debian/Ubuntu. The more secure alternative would be to use MODE="0660" and add the runner user to the kvm group. While the current implementation may be an acceptable trade-off for CI, it's important to be aware of this security consideration.

shell: bash
run: |
set -xeuo pipefail
export BCVK_VERSION=0.5.3

Choose a reason for hiding this comment

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

medium

The BCVK_VERSION is hardcoded, which makes updating it cumbersome as it requires modifying the action's source. To improve flexibility and maintainability, this should be exposed as an input parameter with a default value.

You can add this to the inputs section of the action:

  bcvk-version:
    description: 'Version of bcvk to install'
    required: false
    default: '0.5.3'

Then, you can use the input value in this step.

        export BCVK_VERSION=${{ inputs.bcvk-version }}

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new GitHub Actions composite action for setting up Bootc development environments on Ubuntu runners. The action provides a standardized and optimized setup for bootc-dev organization projects.

  • Creates a reusable composite action for Ubuntu runner setup with disk cleanup, package updates, and virtualization support
  • Implements background cleanup operations for disk space management on GitHub runners
  • Adds optional libvirt/virtualization stack installation with bcvk tool setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

done
# Apt removals in foreground, as we can't parallelize these
for x in ${unwanted_pkgs[@]}; do
/bin/time -f '%E %C' sudo apt-get remove -y $x
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The variable $x should be quoted to prevent word splitting and glob expansion. Change to \"$x\" to handle package names with special characters safely.

Suggested change
/bin/time -f '%E %C' sudo apt-get remove -y $x
/bin/time -f '%E %C' sudo apt-get remove -y "$x"

Copilot uses AI. Check for mistakes.
# Something in the stack is overriding this, but we want session right now for bcvk
echo LIBVIRT_DEFAULT_URI=qemu:///session >> $GITHUB_ENV
td=$(mktemp -d)
cd $td
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The variable $td should be quoted to prevent word splitting issues if the path contains spaces. Change to cd \"$td\".

Suggested change
cd $td
cd "$td"

Copilot uses AI. Check for mistakes.
IDV=$(. /usr/lib/os-release && echo ${ID}-${VERSION_ID})
test "${IDV}" = "ubuntu-24.04"
# plucky is the next release
echo 'deb http://azure.archive.ubuntu.com/ubuntu plucky universe main' | sudo tee /etc/apt/sources.list.d/plucky.list
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The APT repository URL uses HTTP instead of HTTPS, which makes the connection susceptible to man-in-the-middle attacks. Consider using https://azure.archive.ubuntu.com/ubuntu instead.

Suggested change
echo 'deb http://azure.archive.ubuntu.com/ubuntu plucky universe main' | sudo tee /etc/apt/sources.list.d/plucky.list
echo 'deb https://azure.archive.ubuntu.com/ubuntu plucky universe main' | sudo tee /etc/apt/sources.list.d/plucky.list

Copilot uses AI. Check for mistakes.
cd $td
# Install bcvk
target=bcvk-$(arch)-unknown-linux-gnu
/bin/time -f '%E %C' curl -LO https://github.com/bootc-dev/bcvk/releases/download/v${BCVK_VERSION}/${target}.tar.gz
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Downloading and installing binaries without checksum verification poses a security risk. Consider adding checksum validation after downloading the tarball to ensure integrity and authenticity of the bcvk binary.

Suggested change
/bin/time -f '%E %C' curl -LO https://github.com/bootc-dev/bcvk/releases/download/v${BCVK_VERSION}/${target}.tar.gz
/bin/time -f '%E %C' curl -LO https://github.com/bootc-dev/bcvk/releases/download/v${BCVK_VERSION}/${target}.tar.gz
/bin/time -f '%E %C' curl -LO https://github.com/bootc-dev/bcvk/releases/download/v${BCVK_VERSION}/${target}.tar.gz.sha256
sha256sum -c ${target}.tar.gz.sha256

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, fetching the digest over the same TLS connection as the main binary doesn't add anything. We'd have to hardcode the digest here instead or use asymmetric crypto keys.

- name: Set architecture variable
id: set_arch
shell: bash
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The step sets an id but the architecture value is only exported to GITHUB_ENV, not as an output. Either remove the unused id: set_arch or add a step output using $GITHUB_OUTPUT if the value needs to be referenced by other steps.

Suggested change
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
run: |
echo "ARCH=$(arch)" >> $GITHUB_ENV
echo "ARCH=$(arch)" >> $GITHUB_OUTPUT

Copilot uses AI. Check for mistakes.
@cgwalters
Copy link
Contributor Author

Yeah, various things to improve here, but should come secondary to the sync of the existing file.

@cgwalters cgwalters requested a review from henrywang November 5, 2025 14:31
@cgwalters cgwalters merged commit 5e3335e into bootc-dev:main Nov 5, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants