Skip to content

cargo-dependency-bump

Move every Rust service to tokio 1.40.

Uses: cargo.set_dependency

Start a campaign from it, then point it at your organization:

gh fleet init --from cargo-dependency-bump --org your-org

Campaign

load("@fleet//cargo.star", "set_dependency")

def change(repo):
    repo.set_var("changed", len(set_dependency(repo, env["CRATE"], env["VERSION"])) > 0)
# yaml-language-server: $schema=https://raw.githubusercontent.com/rossedman/gh-fleet/main/internal/campaign/campaign.schema.json
apiVersion: fleet.gh/v1
name: bump-tokio
description: Move every Rust service to tokio 1.40

targets:
  orgs: [acme]
  include:
    languages: [Rust]
    files: [Cargo.toml]

change:
  steps:
    # Sets the version wherever a Cargo.toml depends on CRATE, in plain
    # (`tokio = "1.30"`) or table (`tokio = { version = ... }`) form.
    - name: Cargo.toml
      starlark: ./change.star
      timeout: 1m
    # Refreshes Cargo.lock for that crate only, if the repo commits one and
    # the step above changed a dependency.
    - name: Cargo.lock
      run: |
        if [ "$FLEET_VAR_CHANGED" = true ] && [ -f Cargo.lock ]; then cargo update --package "$CRATE"; fi
      timeout: 10m
  env:
    CRATE: tokio
    VERSION: "1.40"

pr:
  title: "build(deps): tokio {{ .Vars.version }}"
  body: |
    Updates tokio to {{ .Vars.version }} in {{ .Repo.Name }}.

    Opened by the `{{ .Campaign.Name }}` campaign with [gh fleet](https://github.com/rossedman/gh-fleet).
  labels: [fleet, dependencies]

vars:
  default:
    version: "1.40"

Test cases

gh fleet test runs the change on each case's before/ files and checks the result against after/. See Testing a campaign.

crate-not-used

Cargo.lock

# This file is automatically @generated by Cargo.

Cargo.toml

[package]
name = "rg"

[dependencies]
serde = "1"

No changes: the campaign leaves this repo alone.

Source on GitHub