Skip to content

Add a script for running through some basic repository setup#189

Merged
ShadowCurse merged 6 commits intorust-vmm:mainfrom
roypat:setup-script
Oct 16, 2025
Merged

Add a script for running through some basic repository setup#189
ShadowCurse merged 6 commits intorust-vmm:mainfrom
roypat:setup-script

Conversation

@roypat
Copy link
Member

@roypat roypat commented Aug 15, 2025

Summary of the PR

Add a repository_setup.sh script that automates a couple of setup steps
for setup of new rust-vmm repositories. It also supports updating the
configuration of already created repositories by comparing the
repository's configuration to the defaults in rust-vmm-ci and giving the
option to update.

Currently, the script supports dependabot setup and .platform file
generation. It does not deal with the coverage files, since I am still
hoping to switch us over to codecov.io in the future, at which point
that will all changes completely anyway. I plan to also add crates.io
publish workflow support before moving this out of draft.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@roypat roypat force-pushed the setup-script branch 2 times, most recently from b42aeec to 9679581 Compare August 15, 2025 15:46
@roypat
Copy link
Member Author

roypat commented Aug 15, 2025

Sample output of running this script in the vhost repository:

$ ./rust-vmm-ci/repository_setup.sh 
Welcome to the rust-vmm interactive repository setup!

This script will guide you through initializing basic components of a fresh
rust-vmm repository, or alternatively lets you update the configuration of an
existing repository (for example, if since the first setup of a repository,
rust-vmm-ci has added new features that you would like to use).

Please select the hardware plaforms for which you would like to enable CI support:
Enable support for x86_64? [Y/n] y
Enable support for aarch64? [Y/n] y
Enable support for riscv64? [Y/n] n

Dependabot is already configured, although configuration does not match any rust-vmm-ci provided ones. Would you like to reconfigure dependabot? [Y/n] y
Dependabot allow you to automatically receive PRs for bumping your cargo
dependencies, as well as for updating the rust-vmm-ci submodule. You can choose
to run dependabot on different schedules: weekly monthly.

Which schedule would you like to enable? (say 'n' to disable dependabot)
1) weekly
2) monthly
#? 1
Configured for weekly schedule

Setting up auto-publish for crates.io upon creation of GitHub tags...
Found workspace member 'vhost' at 'vhost'. Setup auto-publish? [Y/n] y
If not already done, go to https://crates.io/crates/vhost/settings and add publish-vhost.yml as a trusted publisher!
Found workspace member 'vhost-user-backend' at 'vhost-user-backend'. Setup auto-publish? [Y/n] y
If not already done, go to https://crates.io/crates/vhost-user-backend/settings and add publish-vhost-user-backend.yml as a trusted publisher!

where the following changes would be made:

diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 37675b73db2b..973292a9c3bc 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,18 +1,27 @@
 version: 2
 updates:
-- package-ecosystem: cargo
+
+# A weekly update of the rust-vmm-ci submodule
+- package-ecosystem: gitsubmodule
   directory: "/"
   schedule:
     interval: weekly
-  allow:
-  - dependency-type: direct
-  - dependency-type: indirect
-  groups:
-      vhost:
-        patterns:
-          - "*"
-- package-ecosystem: gitsubmodule
+    day: monday
+  open-pull-requests-limit: 1
+
+# A weekly update to rust dependencies. These will be grouped,
+# e.g. one PR will contains updates for all dependencies.
+- package-ecosystem: cargo
   directory: "/"
   schedule:
     interval: weekly
-  open-pull-requests-limit: 10
+    day: monday
+  open-pull-requests-limit: 1
+  # Make it also update transitive dependencies in Cargo.lock
+  allow:
+    - dependency-type: "all"
+  # Group all available updates into a group called "rust-dependencies"
+  groups:
+    rust-dependencies:
+      patterns:
+        - "*"
diff --git a/.github/workflows/publish-vhost-user-backend.yml b/.github/workflows/publish-vhost-user-backend.yml
new file mode 100644
index 000000000000..24aa8ed12116
--- /dev/null
+++ b/.github/workflows/publish-vhost-user-backend.yml
@@ -0,0 +1,21 @@
+name: Publish to crates.io
+
+on:
+  push:
+    tags: ['vhost-user-backend-v*']  # Triggers when pushing version tags
+
+jobs:
+  publish:
+    runs-on: ubuntu-latest
+    # environment: release  # Optional: for enhanced security
+    permissions:
+      id-token: write     # Required for OIDC token exchange
+    steps:
+    - uses: actions/checkout@v4
+    - uses: rust-lang/crates-io-auth-action@v1
+      id: auth
+    - run: |
+        cd vhost-user-backend
+        cargo publish
+      env:
+        CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
\ No newline at end of file
diff --git a/.github/workflows/publish-vhost.yml b/.github/workflows/publish-vhost.yml
new file mode 100644
index 000000000000..5bbba7cf6a64
--- /dev/null
+++ b/.github/workflows/publish-vhost.yml
@@ -0,0 +1,21 @@
+name: Publish to crates.io
+
+on:
+  push:
+    tags: ['vhost-v*']  # Triggers when pushing version tags
+
+jobs:
+  publish:
+    runs-on: ubuntu-latest
+    # environment: release  # Optional: for enhanced security
+    permissions:
+      id-token: write     # Required for OIDC token exchange
+    steps:
+    - uses: actions/checkout@v4
+    - uses: rust-lang/crates-io-auth-action@v1
+      id: auth
+    - run: |
+        cd vhost
+        cargo publish
+      env:
+        CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
\ No newline at end of file
diff --git a/.platform b/.platform
new file mode 100644
index 000000000000..86353074a1f4
--- /dev/null
+++ b/.platform
@@ -0,0 +1,2 @@
+x86_64
+aarch64

@roypat roypat marked this pull request as ready for review August 15, 2025 15:51
@roypat
Copy link
Member Author

roypat commented Aug 15, 2025

And running it a second time on the vhost repo produces

./rust-vmm-ci/repository_setup.sh 
Welcome to the rust-vmm interactive repository setup!

This script will guide you through initializing basic components of a fresh
rust-vmm repository, or alternatively lets you update the configuration of an
existing repository (for example, if since the first setup of a repository,
rust-vmm-ci has added new features that you would like to use).

This repository already has a .platform file setup. Do you want to regenerate it? Current supported platforms are: x86_64 aarch64  [Y/n] n

Dependabot is already setup for the weekly schedule. Would you like to reconfigure dependabot? [Y/n] n

Setting up auto-publish for crates.io upon creation of GitHub tags...
Publish workflow for vhost already setup, skipping
Publish workflow for vhost-user-backend already setup, skipping

and no further changes

@roypat roypat force-pushed the setup-script branch 2 times, most recently from f29ac18 to 56768d8 Compare October 2, 2025 13:40
Copy link
Member

@stefano-garzarella stefano-garzarella left a comment

Choose a reason for hiding this comment

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

Cool, thanks for that! Just something to fix, the rest LGTM!

Add a repository_setup.sh script that automates a couple of setup steps
for setup of new rust-vmm repositories. It also supports updating the
configuration of already created repositories by comparing the
repository's configuration to the defaults in rust-vmm-ci and giving the
option to update.

Currently, the script supports dependabot setup and .platform file
generation. It does not deal with the coverage files, since I am still
hoping to switch us over to codecov.io in the future, at which point
that will all changes completely anyway.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Replace the manual instructions for setting up dependabot and .platform
file with instructions to run the new script. Move the explanation of
the .platform file to the testing section (where we were incorrectly
claiming that we only support x86_64 and aarch64, so fix that up too).

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Add a github action sample workflow file for auto-publishing crates on
creation of 'v*' tags. The sample workflow assumes a non-workspace
setup, so that cargo publish can be run from the repository root (=
crate root).

For multi-crate repositories, repository_setup.sh will generate
derivatives of this file.

There is a useless `cd .` in the `run` step which only exists so that
sed can easily replace it with the path for crates in a workspace when
auto-generating workflows.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Make repository_setup.sh automatically discover whether we have a multi
crate cargo workspace, or just a single crate repository, and then
generate a publish github action for each of them that triggers when a
tag named '$crate_name-v*' (or just 'v*' for single-crate repos) is
published.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
@ShadowCurse ShadowCurse enabled auto-merge (rebase) October 16, 2025 09:15
@ShadowCurse ShadowCurse merged commit 1b48931 into rust-vmm:main Oct 16, 2025
3 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.

3 participants