Skip to content

Commit b6a7794

Browse files
committed
chore(ci): WIP setup cmd tests
1 parent 018450c commit b6a7794

File tree

11 files changed

+330
-187
lines changed

11 files changed

+330
-187
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ on:
1313
- cron: "27 0 * * *" # nightly test for RA
1414

1515
env:
16-
CARGO_TERM_COLOR: always
16+
CARGO_TERM_COLOR: "always"
17+
RUST_LOG: "info"
18+
RUST_BACKTRACE: "1"
1719

1820
concurrency:
1921
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
@@ -23,11 +25,16 @@ jobs:
2325
test:
2426
name: Test
2527

26-
runs-on: ubuntu-latest
2728
strategy:
2829
matrix:
2930
toolchain:
3031
- stable
32+
platform:
33+
- ubuntu-latest
34+
- windows-latest
35+
fail-fast: false
36+
37+
runs-on: ${{ matrix.platform }}
3138

3239
permissions:
3340
contents: read
@@ -42,6 +49,8 @@ jobs:
4249
with:
4350
toolchain: ${{ matrix.toolchain }}
4451

52+
- uses: cargo-bins/cargo-binstall@b9bf4400702f721d469eec4d280125f650c85638
53+
4554
- name: Get cache key
4655
run: |
4756
CARGO_VERSION=$(cargo --version)
@@ -54,6 +63,7 @@ jobs:
5463
echo "EOF"
5564
} >> "$GITHUB_OUTPUT"
5665
id: cache-key
66+
shell: bash
5767

5868
- uses: actions/cache/restore@v4
5969
with:
@@ -64,14 +74,11 @@ jobs:
6474
id: cache-restore
6575

6676
- name: Prepare binaries
67-
run: cargo bin --install
68-
69-
- name: Prepare rust-analyzer
70-
run: cargo run --package util-rust-analyzer -- download
77+
run: |
78+
cargo bin --install
79+
cargo run --package util-rust-analyzer -- download
7180
72-
- run: cargo test --release --all-features
73-
env:
74-
RUST_LOG: info
81+
- run: cargo test --all-features --no-fail-fast -- --include-ignored
7582

7683
- name: Evict cache
7784
run: gh cache delete '${{ steps.cache-key.outputs.CACHE_KEY }}'
@@ -92,8 +99,7 @@ jobs:
9299
CACHE_KEY_RESTORE: ${{ steps.cache-key.outputs.CACHE_KEY_RESTORE }}
93100

94101
build_features:
95-
name: Build
96-
runs-on: ubuntu-latest
102+
name: Build features
97103

98104
needs:
99105
- test
@@ -109,6 +115,8 @@ jobs:
109115
- lib-link-forever
110116
fail-fast: false
111117

118+
runs-on: ubuntu-latest
119+
112120
steps:
113121
- uses: actions/checkout@v4
114122
with:
@@ -125,11 +133,10 @@ jobs:
125133
key: ${{ needs.test.outputs.CACHE_KEY }}
126134
restore-keys: ${{ needs.test.outputs.CACHE_KEY_RESTORE }}
127135

128-
- run: cargo build --release --features ${{ matrix.features }}
136+
- run: cargo build --features ${{ matrix.features }}
129137

130138
test_rustdoc_link_ra:
131-
name: rustdoc-link RA
132-
runs-on: ubuntu-latest
139+
name: (rustdoc-link) Test RA
133140

134141
needs:
135142
- test
@@ -142,6 +149,8 @@ jobs:
142149
- "nightly"
143150
fail-fast: false
144151

152+
runs-on: ubuntu-latest
153+
145154
steps:
146155
- uses: actions/checkout@v4
147156
with:
@@ -162,6 +171,4 @@ jobs:
162171
env:
163172
RA_VERSION: ${{ matrix.ra-version }}
164173

165-
- run: cargo test --release --features rustdoc-link
166-
env:
167-
RUST_LOG: info
174+
- run: cargo test --features rustdoc-link

Cargo.lock

Lines changed: 63 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ edition = "2021"
99
rust-version = "1.81.0"
1010

1111
[profile.dev.package]
12-
cargo-run-bin.opt-level = 3
1312
insta.opt-level = 3
1413
similar.opt-level = 3
1514

crates/mdbookkit/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ cargo-run-bin = { workspace = true }
6363
insta = { workspace = true }
6464
predicates = { workspace = true }
6565
similar = { workspace = true }
66-
util-rust-analyzer = { path = "../../utils/rust-analyzer" }
6766
util-testing = { workspace = true }
6867

6968
[features]

crates/mdbookkit/src/bin/link_forever/git.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ impl Environment {
2525
let vcs_root = repo
2626
.workdir()
2727
.unwrap_or_else(|| repo.commondir())
28+
.canonicalize()
29+
.context("failed to locate repo root")?
2830
.pipe(Url::from_directory_path)
29-
.expect("failed to locate repo root");
31+
.map_err(|_| anyhow!("failed to locate repo root"))?;
3032

3133
let book_src = book
3234
.root
35+
.canonicalize()
36+
.context("failed to locate book root")?
3337
.join(&book.config.book.src)
3438
.pipe(Url::from_directory_path)
35-
.expect("book `src` should be a valid absolute path");
39+
.map_err(|_| anyhow!("book `src` should be a valid absolute path"))?;
3640

3741
let markdown = mdbook_markdown().tap_mut(|m| {
3842
if smart_punctuation(&book.config) {

crates/mdbookkit/tests/link_forever.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn test_snapshots() -> Result<()> {
7070
fn test_minimum_env() -> Result<()> {
7171
util::setup_logging();
7272

73-
log::debug!("setup: compile self");
73+
log::info!("setup: compile self");
7474
Command::new("cargo")
7575
.args([
7676
"build",
@@ -84,17 +84,17 @@ fn test_minimum_env() -> Result<()> {
8484
"--profile=dev"
8585
} else {
8686
"--profile=release"
87-
});
87+
})
88+
.assert()
89+
.success();
8890

8991
let path = setup_paths()?;
9092

9193
let root = TempDir::new()?;
9294

93-
let _dir = root.path().to_string_lossy();
94-
9595
log::debug!("{root:?}");
9696

97-
log::debug!("given: a book");
97+
log::info!("given: a book");
9898
Command::new("mdbook")
9999
.args(["init", "--force"])
100100
.env("PATH", &path)
@@ -103,21 +103,21 @@ fn test_minimum_env() -> Result<()> {
103103
.assert()
104104
.success();
105105

106-
log::debug!("given: preprocessor is enabled");
106+
log::info!("given: preprocessor is enabled");
107107
std::fs::File::options()
108108
.append(true)
109109
.open(root.path().join("book.toml"))?
110110
.pipe(|mut file| file.write_all("[preprocessor.link-forever]\n".as_bytes()))?;
111111

112-
log::debug!("when: book has path-based links");
112+
log::info!("when: book has path-based links");
113113
std::fs::File::options()
114114
.append(true)
115115
.open(root.path().join("src/chapter_1.md"))?
116116
.pipe(|mut file| file.write_all("\n[book.toml](../book.toml)\n".as_bytes()))?;
117117

118-
log::debug!("when: book is not in source control");
118+
log::info!("when: book is not in source control");
119119

120-
log::debug!("then: book builds with warnings");
120+
log::info!("then: book builds with warnings");
121121
Command::new("mdbook")
122122
.arg("build")
123123
.env("PATH", &path)
@@ -126,15 +126,15 @@ fn test_minimum_env() -> Result<()> {
126126
.success()
127127
.stderr(predicate::str::contains("requires a git repository"));
128128

129-
log::debug!("when: repo has no commit");
129+
log::info!("when: repo has no commit");
130130
Command::new("git")
131131
.arg("init")
132132
.env("PATH", &path)
133133
.current_dir(&root)
134134
.assert()
135135
.success();
136136

137-
log::debug!("then: book builds with warnings");
137+
log::info!("then: book builds with warnings");
138138
Command::new("mdbook")
139139
.arg("build")
140140
.env("PATH", &path)
@@ -143,15 +143,20 @@ fn test_minimum_env() -> Result<()> {
143143
.success()
144144
.stderr(predicate::str::contains("no commit found"));
145145

146-
log::debug!("when: repo has no origin");
146+
log::info!("when: repo has no origin");
147147
Command::new("git")
148-
.args(["commit", "--allow-empty", "--message", "init"])
148+
.args(["commit", "--allow-empty"])
149+
.args(["--message", "init"])
149150
.env("PATH", &path)
151+
.env("GIT_AUTHOR_NAME", "me")
152+
.env("GIT_AUTHOR_EMAIL", "me@example.org")
153+
.env("GIT_COMMITTER_NAME", "me")
154+
.env("GIT_COMMITTER_EMAIL", "me@example.org")
150155
.current_dir(&root)
151156
.assert()
152157
.success();
153158

154-
log::debug!("then: book builds with warnings");
159+
log::info!("then: book builds with warnings");
155160
Command::new("mdbook")
156161
.arg("build")
157162
.env("PATH", &path)
@@ -160,7 +165,7 @@ fn test_minimum_env() -> Result<()> {
160165
.success()
161166
.stderr(predicate::str::contains("failed to determine GitHub url"));
162167

163-
log::debug!("when: repo has origin");
168+
log::info!("when: repo has origin");
164169
Command::new("git")
165170
.args([
166171
"remote",
@@ -173,7 +178,7 @@ fn test_minimum_env() -> Result<()> {
173178
.assert()
174179
.success();
175180

176-
log::debug!("then: book builds");
181+
log::info!("then: book builds");
177182
Command::new("mdbook")
178183
.arg("build")
179184
.env("PATH", &path)

0 commit comments

Comments
 (0)