Skip to content

Commit b599f30

Browse files
authored
Merge pull request #2768 from fermyon/more-CI-fixes
[factors] More CI fixes
2 parents c132a03 + a79898c commit b599f30

File tree

6 files changed

+34
-19
lines changed

6 files changed

+34
-19
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ concurrency:
2121

2222
env:
2323
CARGO_TERM_COLOR: always
24-
RUST_VERSION: 1.76
24+
RUST_VERSION: 1.79
2525

2626
jobs:
2727
dependency-review:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
concurrency: ${{ github.workflow }}-${{ github.ref }}
1212

1313
env:
14-
RUST_VERSION: 1.76
14+
RUST_VERSION: 1.79
1515

1616
jobs:
1717
build-and-sign:

crates/factor-sqlite/src/runtime_config/spin.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use spin_factors::{
1010
anyhow::{self, Context as _},
1111
runtime_config::toml::GetTomlValue,
1212
};
13+
use spin_sqlite_inproc::InProcDatabaseLocation;
1314
use spin_world::v2::sqlite as v2;
1415
use tokio::sync::OnceCell;
1516

@@ -108,10 +109,7 @@ impl DefaultLabelResolver for RuntimeConfigResolver {
108109
.as_deref()
109110
.map(|p| p.join(DEFAULT_SQLITE_DB_FILENAME));
110111
let factory = move || {
111-
let location = match &path {
112-
Some(path) => spin_sqlite_inproc::InProcDatabaseLocation::Path(path.clone()),
113-
None => spin_sqlite_inproc::InProcDatabaseLocation::InMemory,
114-
};
112+
let location = InProcDatabaseLocation::from_path(path.clone())?;
115113
let connection = spin_sqlite_inproc::InProcConnection::new(location)?;
116114
Ok(Box::new(connection) as _)
117115
};
@@ -202,17 +200,11 @@ impl LocalDatabase {
202200
///
203201
/// `base_dir` is the base directory path from which `path` is resolved if it is a relative path.
204202
fn connection_creator(self, base_dir: &Path) -> anyhow::Result<impl ConnectionCreator> {
205-
let location = match self.path {
206-
Some(path) => {
207-
let path = resolve_relative_path(&path, base_dir);
208-
// Create the store's parent directory if necessary
209-
// unwrapping the parent is fine, because `resolve_relative_path`` will always return a path with a parent
210-
std::fs::create_dir_all(path.parent().unwrap())
211-
.context("Failed to create sqlite database directory")?;
212-
spin_sqlite_inproc::InProcDatabaseLocation::Path(path)
213-
}
214-
None => spin_sqlite_inproc::InProcDatabaseLocation::InMemory,
215-
};
203+
let path = self
204+
.path
205+
.as_ref()
206+
.map(|p| resolve_relative_path(p, base_dir));
207+
let location = InProcDatabaseLocation::from_path(path)?;
216208
let factory = move || {
217209
let connection = spin_sqlite_inproc::InProcConnection::new(location.clone())?;
218210
Ok(Box::new(connection) as _)

crates/sqlite-inproc/src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@ pub enum InProcDatabaseLocation {
1616
Path(PathBuf),
1717
}
1818

19+
impl InProcDatabaseLocation {
20+
/// Convert an optional path to a database location.
21+
///
22+
/// Ensures that the parent directory of the database exists.
23+
pub fn from_path(path: Option<PathBuf>) -> anyhow::Result<Self> {
24+
match path {
25+
Some(path) => {
26+
// Create the store's parent directory if necessary
27+
if let Some(parent) = path.parent() {
28+
std::fs::create_dir_all(parent).with_context(|| {
29+
format!(
30+
"failed to create sqlite database directory '{}'",
31+
parent.display()
32+
)
33+
})?;
34+
}
35+
Ok(Self::Path(path))
36+
}
37+
None => Ok(Self::InMemory),
38+
}
39+
}
40+
}
41+
1942
/// A connection to a sqlite database
2043
pub struct InProcConnection {
2144
location: InProcDatabaseLocation,

tests/conformance-tests/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fn main() {
33
.nth(1)
44
.expect("expected first argument to be path to spin binary")
55
.into();
6-
conformance_tests::run_tests("v0.1.0", move |test| {
6+
conformance_tests::run_tests("canary", move |test| {
77
conformance::run_test(test, &spin_binary)
88
})
99
.unwrap();

tests/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mod runtime_tests {
2828

2929
#[test]
3030
fn conformance_tests() {
31-
conformance_tests::run_tests("v0.1.0", move |test| {
31+
conformance_tests::run_tests("canary", move |test| {
3232
conformance::run_test(test, &spin_binary())
3333
})
3434
.unwrap();

0 commit comments

Comments
 (0)