Skip to content

Commit

Permalink
chore: cleanup more references to generate-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Sep 21, 2023
1 parent 095cfcf commit b1ebd78
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion book/src/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Ok so you've defined your App, but what should we actually build for it? Let's l
[workspace.metadata.dist]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.0.3"
# CI backends to support (see 'cargo dist generate-ci')
# CI backends to support
ci = ["github"]
# The installers to generate for each app
installers = ["shell", "powershell"]
Expand Down
12 changes: 6 additions & 6 deletions book/src/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ Example: `cargo-dist-version = "0.0.3"`

**This can only be set globally**

This is added automatically by `cargo dist init`, and is a recording of its own version for the sake of reproducibility and documentation. When you run [generate-ci][] the resulting CI scripts will use that version of cargo-dist to build your applications.
This is added automatically by `cargo dist init`, and is a recording of its own version for the sake of reproducibility and documentation. When you run [generate][] the resulting CI scripts will use that version of cargo-dist to build your applications.

The syntax must be a valid [Cargo-style SemVer Version][semver-version] (not a VersionReq!).

If you delete the key, generate-ci will just use the version of cargo-dist that's currently running.
If you delete the key, generate will just use the version of cargo-dist that's currently running.

### rust-toolchain-version

Expand All @@ -79,11 +79,11 @@ Example: `rust-toolchain-version = "1.67.1"`
**This can only be set globally**

This is added automatically by `cargo dist init`, recorded for the sake of reproducibility and documentation. It represents the "ideal" Rust toolchain to build your project with. This is in contrast to the builtin Cargo [rust-version][] which is used to specify the *minimum* supported Rust version. When you run [generate-ci][] the resulting CI scripts will install that version of the Rust toolchain with [rustup][]. There's nothing special about the chosen value, it's just a hardcoded "recent stable version".
This is added automatically by `cargo dist init`, recorded for the sake of reproducibility and documentation. It represents the "ideal" Rust toolchain to build your project with. This is in contrast to the builtin Cargo [rust-version][] which is used to specify the *minimum* supported Rust version. When you run [generate][] the resulting CI scripts will install that version of the Rust toolchain with [rustup][]. There's nothing special about the chosen value, it's just a hardcoded "recent stable version".

The syntax must be a valid rustup toolchain like "1.60.0" or "stable" (should not specify the platform, we want to install this toolchain on all platforms).

If you delete the key, generate-ci won't explicitly setup a toolchain, so whatever's on the machine will be used (with things like rust-toolchain.toml behaving as normal). Before being deprecated the default was to `rustup update stable`, but this is no longer the case.
If you delete the key, generate won't explicitly setup a toolchain, so whatever's on the machine will be used (with things like rust-toolchain.toml behaving as normal). Before being deprecated the default was to `rustup update stable`, but this is no longer the case.

### ci

Expand All @@ -93,7 +93,7 @@ Example: `ci = ["github"]`

**This can only be set globally**

This is a list of CI backends you want to support, allowing subsequent runs of [generate-ci][] to know what CI scripts to generate. Its presence also enables certain CI-specific features. For instance if "github" is included we'll try to generate the body for a Github Release and tell [installers][] to fetch binaries from a Github Release. Once we introduce more CI backends we'll need to more completely rationalize what that means. In all likelihood each set of CI scripts will need to explicitly select just its own CI by passing `--ci=...` for every invocation.
This is a list of CI backends you want to support, allowing subsequent runs of [generate][] to know what CI scripts to generate. Its presence also enables certain CI-specific features. For instance if "github" is included we'll try to generate the body for a Github Release and tell [installers][] to fetch binaries from a Github Release. Once we introduce more CI backends we'll need to more completely rationalize what that means. In all likelihood each set of CI scripts will need to explicitly select just its own CI by passing `--ci=...` for every invocation.

"github" is currently the only supported CI backend.

Expand Down Expand Up @@ -424,7 +424,7 @@ Caveat: the default "host" Artifact Mode does something fuzzier with `--target`
[cargo-manifest]: https://doc.rust-lang.org/cargo/reference/manifest.html
[concepts]: ./concepts.md
[workspace]: https://doc.rust-lang.org/cargo/reference/workspaces.html
[generate-ci]: ./cli.md#cargo-dist-generate-ci
[generate]: ./cli.md#cargo-dist-generate
[semver-version]: https://docs.rs/semver/latest/semver/struct.Version.html
[rust-version]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
[rustup]: https://rust-lang.github.io/rustup/
Expand Down
14 changes: 7 additions & 7 deletions book/src/simple-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can rerun `init` as many times as you want, as it also functions as an "upda
cargo dist init
```

[`init`][init] on its own just edits your Cargo.toml to include the recommended defaults. If you have enabled CI support, it will also run `cargo dist generate-ci` after setting things up. This ensures your config and your CI scripts are in sync, but will unfortunately clobber any hand-edits you made to the scripts.
[`init`][init] on its own just edits your Cargo.toml to include the recommended defaults. If you have enabled CI support, it will also run `cargo dist generate` after setting things up. This ensures your config and your CI scripts are in sync, but will unfortunately clobber any hand-edits you made to the scripts.

Let's look at those defaults that were added (yes those comments are generated too, you will never stop me from adding more docs!!!):

Expand All @@ -34,7 +34,7 @@ lto = "thin"
[workspace.metadata.dist]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.0.6"
# CI backends to support (see 'cargo dist generate-ci')
# CI backends to support
ci = ["github"]
# The installers to generate for each app
installers = []
Expand All @@ -58,11 +58,11 @@ cargo-dist uses the existence of `[profile.dist]` in your Cargo.toml to detect i

Next let's talk about `[workspace.metadata.dist]`. Cargo allows other tools to include their own project-wide settings in this kind of [metadata table][workspace-metadata]. See [config][] for the full set of options, but here we'll look at the defaults.

`cargo-dist-version = "0.0.6"` is cargo-dist recording its own version in your config for the sake of reproducibility and documentation. When you run [generate-ci][] the resulting CI scripts will use that version of cargo-dist.
`cargo-dist-version = "0.0.6"` is cargo-dist recording its own version in your config for the sake of reproducibility and documentation. When you run [generate][] the resulting CI scripts will use that version of cargo-dist.

`rust-toolchain-version = "1.67.1"` is the Rust toolchain that is considered "ideal" for building your application, recorded for the sake of reproducibility and documentation. This is in contrast to the builtin Cargo [rust-version][] which is used to specify the *minimum* supported Rust version. When you run [generate-ci][] the resulting CI scripts will install that version of the Rust toolchain with [rustup][]. There's nothing special about the chosen value, it's just a hardcoded "recent stable version".
`rust-toolchain-version = "1.67.1"` is the Rust toolchain that is considered "ideal" for building your application, recorded for the sake of reproducibility and documentation. This is in contrast to the builtin Cargo [rust-version][] which is used to specify the *minimum* supported Rust version. When you run [generate][] the resulting CI scripts will install that version of the Rust toolchain with [rustup][]. There's nothing special about the chosen value, it's just a hardcoded "recent stable version".

`ci = ["github"]` lets subsequent runs of [generate-ci][] know what CI scripts to generate. Its presence also enables certain Github-specific features like generating the body for a Github Release and telling installers to fetch binaries from a Github Release. It will be enabled by default if you have `repository = "https://github.com/..."` consistently set in your Cargo.toml(s). ("github" is currently the only supported CI backend.)
`ci = ["github"]` lets subsequent runs of [generate][] know what CI scripts to generate. Its presence also enables certain Github-specific features like generating the body for a Github Release and telling installers to fetch binaries from a Github Release. It will be enabled by default if you have `repository = "https://github.com/..."` consistently set in your Cargo.toml(s). ("github" is currently the only supported CI backend.)

`installer = []` is just saying that we haven't enabled any [installers][]. Installers are intentionally excluded here to keep this example focused.

Expand All @@ -72,7 +72,7 @@ Next let's talk about `[workspace.metadata.dist]`. Cargo allows other tools to i

### The CI Script

Because we set `ci = ["github"]`, [init][] invoked [generate-ci][] for us. Creating the Github CI workflow we wanted at `.github/workflows/release.yml`. Rather than including the full text here, I'll just link [cargo-dist's own release.yml][release-yml], because cargo-dist is self-hosting and has an extremely boring build/config that is basically equivalent to the one we're looking at in this example.
Because we set `ci = ["github"]`, [init][] invoked [generate][] for us. Creating the Github CI workflow we wanted at `.github/workflows/release.yml`. Rather than including the full text here, I'll just link [cargo-dist's own release.yml][release-yml], because cargo-dist is self-hosting and has an extremely boring build/config that is basically equivalent to the one we're looking at in this example.

The first thing you might notice is that there's a *lot* of comments describing the script. As always: you will never stop me from writing more docs and shoving them in your face. Actually ok you *can* stop me because I need to write a lot of docs here and those comments are already decent docs. Feel free to peruse them to get a feel for it.

Expand Down Expand Up @@ -195,7 +195,7 @@ If none of the previous rules apply, "1.0.0-prerelease.1" will also match a spec
[cargo-release]: https://github.com/crate-ci/cargo-release
[git-tag]: https://git-scm.com/book/en/v2/Git-Basics-Tagging
[init]: ./cli.md#cargo-dist-init
[generate-ci]: ./cli.md#cargo-dist-generate-ci
[generate]: ./cli.md#cargo-dist-generate
[cargo-profile]: https://doc.rust-lang.org/cargo/reference/profiles.html
[thin-lto]: https://doc.rust-lang.org/cargo/reference/profiles.html#lto
[workspace-metadata]: https://doc.rust-lang.org/cargo/reference/workspaces.html#the-metadata-table
Expand Down
8 changes: 4 additions & 4 deletions cargo-dist/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub enum Commands {
/// Setup or update cargo-dist
///
/// This will interactively guide you through the process of selecting configuration options
/// and will also automatically run 'cargo dist generate-ci' afterwards as necessary. It will
/// and will also automatically run 'cargo dist generate' afterwards as necessary. It will
/// also handle updating your project to a new version of cargo-dist if you're running one.
#[clap(disable_version_flag = true)]
Init(InitArgs),
Expand Down Expand Up @@ -227,9 +227,9 @@ pub struct InitArgs {
/// during the interactive prompts.
#[clap(long, short)]
pub yes: bool,
/// Don't automatically invoke 'cargo dist generate-ci' at the end
#[clap(long)]
pub no_generate_ci: bool,
/// Don't automatically invoke 'cargo dist generate' at the end
#[clap(long, alias = "no-generate-ci")]
pub no_generate: bool,
/// A path to a json file containing values to set in workspace.metadata.dist
/// and package.metadata.dist, for building tools that edit these configs.
///
Expand Down
9 changes: 4 additions & 5 deletions cargo-dist/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct DistMetadata {
///
/// FIXME: Should we produce a warning if running locally with a different version? In theory
/// it shouldn't be a problem and newer versions should just be Better... probably you
/// Really want to have the exact version when running generate-ci to avoid generating
/// Really want to have the exact version when running generate to avoid generating
/// things other cargo-dist versions can't handle!
#[serde(rename = "cargo-dist-version")]
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -49,9 +49,8 @@ pub struct DistMetadata {
///
/// Currently only accepts "github".
///
/// When running `generate-ci` with no arguments this list will be used.
///
/// This value isn't Optional because it's global, and therefore can't be overriden by packages.
/// When running `generate` this list will be used if it's Some, otherwise all known
/// CI backends will be used.
#[serde(skip_serializing_if = "Option::is_none")]
pub ci: Option<Vec<CiStyle>>,

Expand Down Expand Up @@ -441,7 +440,7 @@ impl DistMetadata {
pub struct Config {
/// Whether we need to compute an announcement tag or if we can fudge it
///
/// Commands like generate-ci and init don't need announcements, but want to run gather_work
/// Commands like generate and init don't need announcements, but want to run gather_work
pub needs_coherent_announcement_tag: bool,
/// The subset of artifacts we want to build
pub artifact_mode: ArtifactMode,
Expand Down
13 changes: 4 additions & 9 deletions cargo-dist/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct InitArgs {
/// Whether to auto-accept the default values for interactive prompts
pub yes: bool,
/// Don't automatically generate ci
pub no_generate_ci: bool,
pub no_generate: bool,
/// A path to a json file containing values to set in workspace.metadata.dist
pub with_json_config: Option<Utf8PathBuf>,
}
Expand Down Expand Up @@ -120,8 +120,8 @@ pub fn do_init(cfg: &Config, args: &InitArgs) -> Result<()> {

// If there's CI stuff, regenerate it
if let Some(ci) = multi_meta.workspace.as_ref().and_then(|w| w.ci.as_ref()) {
if !ci.is_empty() && !args.no_generate_ci {
eprintln!("running 'cargo dist generate-ci' to apply any changes to your CI scripts");
if !ci.is_empty() && !args.no_generate {
eprintln!("running 'cargo dist generate' to apply any changes to your CI scripts");
eprintln!();

let ci_args = GenerateArgs {
Expand Down Expand Up @@ -702,12 +702,7 @@ fn apply_dist_to_metadata(metadata: &mut toml_edit::Item, meta: &DistMetadata) {
rust_toolchain_version.as_deref(),
);

apply_string_list(
table,
"ci",
"# CI backends to support (see 'cargo dist generate-ci')\n",
ci.as_ref(),
);
apply_string_list(table, "ci", "# CI backends to support\n", ci.as_ref());

apply_string_list(
table,
Expand Down
2 changes: 1 addition & 1 deletion cargo-dist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fn cmd_init(cli: &Cli, args: &InitArgs) -> Result<(), miette::Report> {
};
let args = cargo_dist::InitArgs {
yes: args.yes,
no_generate_ci: args.no_generate_ci,
no_generate: args.no_generate,
with_json_config: args.with_json_config.clone(),
};
do_init(&config, &args)
Expand Down
4 changes: 2 additions & 2 deletions cargo-dist/tests/gallery/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<'a> TestContext<'a, Tools> {

self.load_dist_results(test_name)
}
/// Run 'cargo dist generate-ci' and return paths to various files that were generated
/// Run 'cargo dist generate' and return paths to various files that were generated
pub fn cargo_dist_generate(&self, test_name: &str) -> Result<GenerateResult> {
let github_ci_path = Utf8Path::new(".github/workflows/release.yml").to_owned();
let wxs_path = Utf8Path::new("wix/main.wxs").to_owned();
Expand All @@ -171,7 +171,7 @@ impl<'a> TestContext<'a, Tools> {
LocalAsset::remove_file(&wxs_path)?;
}

// run generate-ci
// run generate
eprintln!("running cargo dist generate...");
self.tools
.cargo_dist
Expand Down
6 changes: 3 additions & 3 deletions cargo-dist/tests/snapshots/markdown-help.snap
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ This subcommand accepts all the [global options](#global-options)
## cargo dist init
Setup or update cargo-dist

This will interactively guide you through the process of selecting configuration options and will also automatically run 'cargo dist generate-ci' afterwards as necessary. It will also handle updating your project to a new version of cargo-dist if you're running one.
This will interactively guide you through the process of selecting configuration options and will also automatically run 'cargo dist generate' afterwards as necessary. It will also handle updating your project to a new version of cargo-dist if you're running one.

### Usage

Expand All @@ -146,8 +146,8 @@ Automatically accept all recommended/default values

This is equivalent to just mashing ENTER over and over during the interactive prompts.

#### `--no-generate-ci`
Don't automatically invoke 'cargo dist generate-ci' at the end
#### `--no-generate`
Don't automatically invoke 'cargo dist generate' at the end

#### `--with-json-config <WITH_JSON_CONFIG>`
A path to a json file containing values to set in workspace.metadata.dist and package.metadata.dist, for building tools that edit these configs.
Expand Down

0 comments on commit b1ebd78

Please sign in to comment.