Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ jobs:
# release.yaml builds for Windows only on a signed tag, and the release
# rehearsal runs only when a release input changes. A pull request that
# changes Rust code alone reached a tag with a Windows build that did
# not compile. This job compiles every target of the workspace for
# Windows on every pull request, and a warning fails it. It then runs
# the release build command, which compiles code that only the release
# profile enables and links rune.exe, and the rune-docs tests.
# not compile, and a build that compiles says nothing about whether
# rune works there. This job compiles every target of the workspace for
# Windows on every pull request, and a warning fails it. It runs the
# release build command, which compiles code that only the release
# profile enables and links rune.exe. Then it runs the workspace tests.
windows:
runs-on: windows-latest
env:
Expand All @@ -62,9 +63,26 @@ jobs:
- name: Build the release binary
run: cargo build --release --locked --target x86_64-pc-windows-msvc

# Spec transactions open, link, rename, and flush files through
# Windows calls, and file identity comes from an open handle.
# Only a Windows runner can prove that a transaction completes
# there and that a hard link equals its target.
- name: Test rune-docs
run: cargo test --locked -p rune-docs --all-features
# The tests start jj and mdschema, as on Linux, and sh, bash,
# and ssh-keygen from Git for Windows. Its tools go first on
# the PATH: System32 can hold a bash.exe that is the WSL
# launcher, which cannot read a Windows path.
- name: Install jj and mdschema
shell: bash
run: |
bash scripts/install-tools jj mdschema
cygpath -w "$HOME/.local/bin" >> "$GITHUB_PATH"
cygpath -w /usr/bin >> "$GITHUB_PATH"

- name: Show the mdschema version
run: mdschema version

# A test that needs a Unix shell script as a program, the
# executable bit, a process group, or python3 is marked
# `#[cfg_attr(windows, ignore = "...")]` with its reason, and
# the run reports it as ignored. Every other test runs here:
# spec transactions, file identity from an open handle,
# install, deploy, drift, doctor, and the isolation of every
# test from the runner's own profile.
- name: Test
run: cargo test --locked --workspace
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,17 @@ ansi-to-tui = { version = "8.0.1", optional = true }
unicode-width = { version = "0.2", optional = true }
edtui = { version = "0.11", default-features = false, optional = true }

# Only nix is Unix-only. This table stays after every other dependency:
# a dependency written below a target table header belongs to that target.
# Only nix is Unix-only. The target tables stay after every other
# dependency: a dependency written below a target table header belongs to
# that target.
[target.'cfg(unix)'.dependencies]
nix = { version = "0.30", features = ["fs", "process", "resource", "signal"] }

# The seal nonce is 32 random bytes. Unix reads them from /dev/urandom, and
# Windows has no such file. getrandom is already in the dependency tree.
[target.'cfg(windows)'.dependencies]
getrandom = "0.3"

[build-dependencies]
sha2 = "0.10"

Expand Down
13 changes: 13 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ fn main() {
build_commit(&manifest_dir)
);
println!("cargo:rustc-env=RUNE_BUILD_TIME={}", build_time());

// Windows reserves 1 MB of stack for the main thread, where Linux and
// macOS give it 8 MB. A debug build of rune overflows 1 MB while it
// builds its command tree, before any command runs, so rune.exe asks
// the linker for the 8 MB the other platforms have.
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
let argument = if std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc") {
"/STACK:8388608"
} else {
"-Wl,--stack,8388608"
};
println!("cargo:rustc-link-arg-bins={argument}");
}
}

fn build_commit(manifest_dir: &Path) -> String {
Expand Down
7 changes: 4 additions & 3 deletions rune-docs/src/links.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Broken internal links and orphan pages across a repo's `docs/` tree.
//! Pure analysis: the caller renders the report.

use crate::support::Canonical as _;
use std::collections::{BTreeMap, BTreeSet};
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -66,7 +67,7 @@ fn link_report(root: &Path, docs_root: &Path, pages: &[PathBuf]) -> DocsReport {
LinkTarget::Relative(relative) => {
let resolved = page_dir.join(decode_spaces(relative));
if resolved.exists() {
if let Ok(canonical) = resolved.canonicalize() {
if let Ok(canonical) = resolved.canonical() {
linked.insert(canonical);
}
} else {
Expand All @@ -78,7 +79,7 @@ fn link_report(root: &Path, docs_root: &Path, pages: &[PathBuf]) -> DocsReport {
}
LinkTarget::Wikilink(name) => match basenames.get(name.as_str()) {
Some(found) => {
if let Ok(canonical) = found.canonicalize() {
if let Ok(canonical) = found.canonical() {
linked.insert(canonical);
}
}
Expand All @@ -92,7 +93,7 @@ fn link_report(root: &Path, docs_root: &Path, pages: &[PathBuf]) -> DocsReport {
}

for page in pages {
let Ok(canonical) = page.canonicalize() else {
let Ok(canonical) = page.canonical() else {
continue;
};
let is_entry = page
Expand Down
7 changes: 4 additions & 3 deletions rune-docs/src/spec/openspec_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! `tests/fixtures/openspec/` proving that artifacts the pinned upstream
//! release accepts load, apply, and round-trip here without semantic loss.

use crate::support::Canonical as _;
use serde::Deserialize;
use std::collections::{BTreeMap, BTreeSet};
use std::fs;
Expand Down Expand Up @@ -90,7 +91,7 @@ fn compatibility_manifest_references_pinned_existing_fixtures() {
let manifest: CompatibilityManifest =
serde_yaml::from_str(MANIFEST).expect("compatibility manifest must deserialize");
let fixture_root = Path::new(FIXTURE_ROOT)
.canonicalize()
.canonical()
.expect("fixture root must exist");

assert_eq!(manifest.version, 1);
Expand Down Expand Up @@ -306,7 +307,7 @@ fn assert_fixture_path(fixture_root: &Path, relative_path: &str) {
);
let canonical_path = fixture_root
.join(declared_path)
.canonicalize()
.canonical()
.unwrap_or_else(|error| panic!("fixture path is missing: {relative_path}: {error}"));
assert!(
canonical_path.starts_with(fixture_root),
Expand All @@ -316,7 +317,7 @@ fn assert_fixture_path(fixture_root: &Path, relative_path: &str) {

fn collect_tree(root_path: &Path) -> Result<BTreeMap<PathBuf, Vec<u8>>, String> {
let canonical_root = root_path
.canonicalize()
.canonical()
.map_err(|error| format!("failed to resolve {}: {error}", root_path.display()))?;
let mut files = BTreeMap::new();
collect_tree_files(&canonical_root, &canonical_root, &mut files)?;
Expand Down
3 changes: 2 additions & 1 deletion rune-docs/src/spec/root.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::error::{Error, ErrorKind};
use crate::support::Canonical as _;
use std::path::{Path, PathBuf};
use std::sync::OnceLock;

Expand Down Expand Up @@ -92,7 +93,7 @@ pub(super) fn resolve_with_config(
configured: Option<&str>,
) -> Result<SpecRoot, Error> {
let repository = root
.canonicalize()
.canonical()
.map_err(|error| root_error("resolve repository", root, error))?;
let relative = match configured {
Some(configured) => shared::validate_configured_root(configured),
Expand Down
3 changes: 2 additions & 1 deletion rune-docs/src/spec/root_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// transaction journal wins so recovery reacquires the same lock. Two
// journals, or none, stay ambiguous and require `spec.root`.

use crate::support::Canonical as _;
use std::ffi::OsString;
use std::path::{Component, Path, PathBuf};

Expand Down Expand Up @@ -86,7 +87,7 @@ pub(crate) fn resolve_confined_destination(
.ok_or_else(|| format!("cannot resolve spec path: {}", candidate.display()))?;
}

let resolved_existing = existing.canonicalize().map_err(|error| {
let resolved_existing = existing.canonical().map_err(|error| {
format!("cannot resolve spec path {}: {error}", existing.display())
})?;
if !resolved_existing.starts_with(repository) {
Expand Down
3 changes: 2 additions & 1 deletion rune-docs/src/spec/term_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use super::prose::prose_lines;
use super::terms::{Term, Terms, kebab};
use super::{Error, ErrorKind};
use crate::support::Canonical as _;
use regex::Regex;
use std::collections::BTreeMap;
use std::path::{Component, Path, PathBuf};
Expand Down Expand Up @@ -353,7 +354,7 @@ pub(super) fn canonical(path: &Path) -> PathBuf {
let mut rest = Vec::new();
let mut ancestor = path.as_path();
loop {
if let Ok(real) = ancestor.canonicalize() {
if let Ok(real) = ancestor.canonical() {
let mut result = real;
for component in rest.iter().rev() {
result.push(component);
Expand Down
3 changes: 2 additions & 1 deletion rune-docs/src/spec/transaction/confine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use super::io_error;
use crate::error::{Error, ErrorKind};
use crate::support::Canonical as _;
use std::fs;
use std::io;
use std::path::{Component, Path};
Expand Down Expand Up @@ -231,7 +232,7 @@ pub(super) fn inspect_existing_ancestors(root: &Path, candidate: &Path) -> Resul
}
Ok(_) => {
let resolved = current
.canonicalize()
.canonical()
.map_err(|error| io_error("resolve", &current, error))?;
if !resolved.starts_with(root) {
return Err(Error::new(
Expand Down
9 changes: 5 additions & 4 deletions rune-docs/src/spec/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub(crate) use verify::sha256_file;

use super::root::SpecRoot;
use crate::error::{Error, ErrorKind};
use crate::support::Canonical as _;
use confine::{
create_confined_directories, file_identity, inspect_existing_ancestors, is_same_file,
path_exists_without_following, reject_symlink,
Expand Down Expand Up @@ -215,11 +216,11 @@ impl<I: TransactionIo> Transaction<I> {
.map_err(|error| io_error("create", spec_root.base(), error))?;
let repository = spec_root
.repository()
.canonicalize()
.canonical()
.map_err(|error| io_error("resolve", spec_root.repository(), error))?;
let root = spec_root
.base()
.canonicalize()
.canonical()
.map_err(|error| io_error("resolve", spec_root.base(), error))?;
let lock_path = root.join(LOCK_FILE);
reject_symlink(&lock_path)?;
Expand Down Expand Up @@ -602,7 +603,7 @@ pub(super) fn health_findings(
}
let root = spec_root
.base()
.canonicalize()
.canonical()
.map_err(|error| io_error("resolve", spec_root.base(), error))?;
// Diagnosis never writes: the lock is probed only if it already exists
// (acquisition creates it), and a created lock is never unlinked here
Expand Down Expand Up @@ -671,7 +672,7 @@ fn incomplete_transaction_findings(
};
let repository = spec_root
.repository()
.canonicalize()
.canonical()
.map_err(|error| io_error("resolve", spec_root.repository(), error))?;
let transaction = Transaction {
repository,
Expand Down
Loading
Loading