Skip to content

Commit

Permalink
Move pipelins to own schema
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed Jul 23, 2024
1 parent 9e29bf7 commit 6b445b8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 18 deletions.
15 changes: 1 addition & 14 deletions schema/v2/dependencies.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,7 @@
}
},
"postgres": { "$ref": "postgres.schema.json" },
"pipeline": {
"description": "The build pipeline required to configure, build, test, and install the package provided by the distribution.",
"enum": [
"pgxs",
"meson",
"pgrx",
"autoconf",
"gem",
"cpan",
"pip",
"go",
"cargo"
]
},
"pipeline": { "$ref": "pipeline.schema.json" },
"packages": { "$ref": "packages.schema.json" },
"variations": { "$ref": "variations.schema.json" }
},
Expand Down
7 changes: 7 additions & 0 deletions schema/v2/pipeline.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://pgxn.org/meta/v2/pipeline.schema.json",
"title": "Pipeline",
"description": "The build pipeline required to configure, build, test, and install the package provided by the distribution.",
"enum": ["pgxs", "meson", "pgrx", "autoconf", "npm", "cpanm", "go", "cargo"]
}
51 changes: 47 additions & 4 deletions tests/v2_schema_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn test_v2_glob() -> Result<(), Box<dyn Error>> {
let id = id_for(SCHEMA_VERSION, "glob");
let idx = compiler.compile(&id, &mut schemas)?;

// Test valid relative paths.
// Test valid globs.
for valid_path in [
json!("README.txt"),
json!("/.git"),
Expand All @@ -125,7 +125,7 @@ fn test_v2_glob() -> Result<(), Box<dyn Error>> {
}
}

// Test invalid paths.
// Test invalid globs.
for invalid_path in [
json!("this\\and\\that.txt"),
json!(null),
Expand Down Expand Up @@ -1328,7 +1328,7 @@ fn test_v2_ignore() -> Result<(), Box<dyn Error>> {
let id = id_for(SCHEMA_VERSION, "ignore");
let idx = compiler.compile(&id, &mut schemas)?;

// Test valid relative paths.
// Test valid ignores.
for valid in [
("README.txt", json!(["README.txt"])),
("/.git", json!(["/.git"])),
Expand All @@ -1353,7 +1353,7 @@ fn test_v2_ignore() -> Result<(), Box<dyn Error>> {
}
}

// Test invalid paths.
// Test invalid ignores.
for invalid in [
("empty array", json!([])),
("string", json!("")),
Expand Down Expand Up @@ -1718,3 +1718,46 @@ fn test_v2_postgres() -> Result<(), Box<dyn Error>> {

Ok(())
}

#[test]
fn test_v2_pipeline() -> Result<(), Box<dyn Error>> {
// Load the schemas and compile the semver schema.
let mut compiler = new_compiler("schema/v2")?;
let mut schemas = Schemas::new();
let id = id_for(SCHEMA_VERSION, "pipeline");
let idx = compiler.compile(&id, &mut schemas)?;

// Test valid pipelines.
for valid in [
json!("pgxs"),
json!("meson"),
json!("pgrx"),
json!("autoconf"),
json!("npm"),
json!("cpanm"),
json!("go"),
json!("cargo"),
] {
if let Err(e) = schemas.validate(&valid, idx) {
panic!("path {} failed: {e}", valid);
}
}

// Test invalid pipelines.
for invalid in [
json!("vroom"),
json!("🎃🎃"),
json!("pgsx"),
json!(""),
json!(true),
json!(false),
json!(null),
json!([]),
json!({}),
] {
if schemas.validate(&invalid, idx).is_ok() {
panic!("{} unexpectedly passed!", invalid)
}
}
Ok(())
}

0 comments on commit 6b445b8

Please sign in to comment.