diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index d9d73b4e..6193b327 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -34,16 +34,11 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - name: Install dist - # we specify bash to get pipefail; it guards against the `curl` command - # failing. otherwise `sh` won't catch that `curl` returned non-0 - shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.27.0/cargo-dist-installer.sh | sh" - uses: actions/setup-node@v4 with: node-version: 20 - name: Run tests run: | cd server - ./bt install + ./bt install --dev ./bt check diff --git a/builder/Cargo.toml b/builder/Cargo.toml index a4440de2..48bb795d 100644 --- a/builder/Cargo.toml +++ b/builder/Cargo.toml @@ -25,4 +25,4 @@ edition = "2021" [dependencies] clap = { version = "4.5.19", features = ["derive"] } cmd_lib = "1.9.5" -current_platform = "0.2.0" \ No newline at end of file +current_platform = "0.2.0" diff --git a/builder/src/main.rs b/builder/src/main.rs index 70b40fb6..6831c0b4 100644 --- a/builder/src/main.rs +++ b/builder/src/main.rs @@ -200,10 +200,9 @@ fn quick_copy_dir>( println!("{:#?}", ©_process); // Check for errors. - let exit_status = match copy_process.status() { - Ok(es) => es, - Err(err) => return Err(format!("Error running copy process: {err}").into()), - }; + let exit_status = copy_process + .status() + .map_err(|err| -> String { format!("Error running copy process: {err}") })?; let exit_code = exit_status .code() .expect("Copy process terminated by signal"); @@ -291,9 +290,13 @@ fn run_install(dev: bool) -> Result<(), Box> { cargo fetch; )?; if dev { + // If the dist install reports an error, perhaps it's already installed. + if run_cmd!(cargo install --locked cargo-dist;).is_err() { + run_cmd!(dist --version;)?; + } run_cmd!( cargo install --locked cargo-outdated; - cargo install --locked cargo-dist; + cargo install cargo-sort; )?; } Ok(()) @@ -318,6 +321,22 @@ fn run_update() -> Result<(), Box> { } fn run_check() -> Result<(), Box> { + // On Windows, `cargo sort --check` fails since it default to LF, not CRLF, + // line endings. Work around this by changing this setting only on Windows. + // See the + // [cargo sort config docs](https://github.com/DevinR528/cargo-sort?tab=readme-ov-file#config) + // and the + // [related issue](https://github.com/DevinR528/cargo-sort/issues/85). + // + // However, this still fails: `cargo sort` uses + // [inconsistent line endings](https://github.com/DevinR528/cargo-sort/issues/86). + /*** + #[cfg(windows)] + { + fs::write("tomlfmt.toml", "crlf = true") + .map_err(|err| -> String { format!("Unable to write tomlfmt.toml: {err}") })?; + } + */ // The `-D warnings` flag causes clippy to return a non-zero exit status if // it issues warnings. run_cmd!( @@ -326,6 +345,14 @@ fn run_check() -> Result<(), Box> { cargo clippy --all-targets --manifest-path=../builder/Cargo.toml -- -D warnings; cargo fmt --check --manifest-path=../builder/Cargo.toml; )?; + // `cargo sort` produces false positives under Windows. Ignore for now. See + // the above comments. It also doesn't support the + #[cfg(not(windows))] + run_cmd!( + cargo sort --check; + cd ../builder; + cargo sort --check; + )?; run_build()?; // Verify that compiling for release produces no errors. run_cmd!(dist build;)?; @@ -351,7 +378,7 @@ fn run_build() -> Result<(), Box> { fn run_prerelease() -> Result<(), Box> { // Clean out all bundled files before the rebuild. remove_dir_all_if_exists("../client/static/bundled")?; - run_install(false)?; + run_install(true)?; run_script("npm", &["run", "dist"], "../client", true)?; Ok(()) } diff --git a/server/dist-workspace.toml b/server/dist-workspace.toml index 74de10bc..cb20bdc1 100644 --- a/server/dist-workspace.toml +++ b/server/dist-workspace.toml @@ -34,3 +34,5 @@ targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux- ci = "github" # Skip checking whether the specified configuration files are up to date allow-dirty = ["ci"] +# Which actions to run on pull requests +pr-run-mode = "upload"