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
28 changes: 28 additions & 0 deletions e2e/config/test_schema_tombi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mise use -g tombi@$TOMBI_VERSION

SCHEMA_PATH="$ROOT/schema/mise.json"
TASK_SCHEMA_PATH="$ROOT/schema/mise-task.json"
REGISTRY_TOOL_SCHEMA_PATH="$ROOT/schema/mise-registry-tool.json"
TOMBI="mise x tombi@$TOMBI_VERSION -- tombi"
TOMBI_LINT="$TOMBI lint --offline --no-cache --error-on-warnings --quiet"
assert_contains "$TOMBI --version" "tombi $TOMBI_VERSION"
Expand All @@ -32,6 +33,10 @@ include = ["mise.toml", "mise-age.toml", "mise-env-directives.toml", "mise-os.to
[[schemas]]
path = "file://$TASK_SCHEMA_PATH"
include = ["mise-task-os.toml"]

[[schemas]]
path = "file://$REGISTRY_TOOL_SCHEMA_PATH"
include = ["mise-registry-tool.toml"]
EOF

# Create a mise.toml exercising task properties that were previously broken
Expand Down Expand Up @@ -98,13 +103,23 @@ run = "echo ok"
node = { version = "latest", os = ["linux/x64", "macos/arm64"], profile = "release" }
TOML

cat >"$HOME/workdir/mise-registry-tool.toml" <<'TOML'
backends = [
{ full = "aqua:ImageMagick/ImageMagick", platforms = ["windows-x64"] },
{ full = "github:owner/repo", platforms = ["linux", "arm64"], options = { platforms = { linux-x64 = { asset_pattern = "tool-linux.tar.gz" }, darwin-aarch64 = { asset_pattern = "tool-darwin.tar.gz" } } } },
]
description = "Example tool"
test = { cmd = "tool --version", expected = "tool {{version}}" }
TOML

# tombi lint should succeed with no errors (warnings about table order are ok)
cd "$HOME/workdir"
assert_succeed "$TOMBI_LINT mise.toml"
assert_succeed "$TOMBI_LINT mise-age.toml"
assert_succeed "$TOMBI_LINT mise-env-directives.toml"
assert_succeed "$TOMBI_LINT mise-os.toml"
assert_succeed "$TOMBI_LINT mise-task-os.toml"
assert_succeed "$TOMBI_LINT mise-registry-tool.toml"

# Verify that invalid properties on tasks are rejected
cat >"$HOME/workdir/mise-bad.toml" <<'TOML'
Expand All @@ -128,6 +143,10 @@ include = ["mise-bad.toml", "mise-bad-age.toml", "mise-bad-env-directive.toml",
[[schemas]]
path = "file://$TASK_SCHEMA_PATH"
include = ["mise-bad-task-os.toml", "mise-bad-task-tool-extra.toml"]

[[schemas]]
path = "file://$REGISTRY_TOOL_SCHEMA_PATH"
include = ["mise-bad-registry-tool.toml"]
EOF

assert_fail "$TOMBI_LINT mise-bad.toml"
Expand Down Expand Up @@ -200,3 +219,12 @@ node = { version = "latest", os = "linux/x64", backend_options = { nested = true
TOML

assert_fail "$TOMBI_LINT mise-bad-task-tool-extra.toml"

cat >"$HOME/workdir/mise-bad-registry-tool.toml" <<'TOML'
backends = [
{ full = "github:owner/repo", platforms = ["windows-amd64"] },
{ full = "github:owner/repo", options = { platforms = { linux-x64-musl = { asset_pattern = "tool-linux.tar.gz" } } } },
]
TOML

assert_fail "$TOMBI_LINT mise-bad-registry-tool.toml"
29 changes: 26 additions & 3 deletions schema/mise-registry-tool.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@
"type": "string",
"enum": ["freebsd", "linux", "macos", "openbsd", "windows"]
},
"platform": {
"type": "string",
"pattern": "^(linux|macos|windows)-(x64|arm64|x86|loongarch64|riscv64)$"
},
"optionPlatform": {
"type": "string",
"pattern": "^(linux|macos|darwin|windows)-(x64|amd64|x86_64|arm64|aarch64|x86|loongarch64|riscv64)$"
},
"platformSelector": {
"description": "OS, architecture, or platform this backend supports.",
"oneOf": [
{
"$ref": "#/$defs/os"
},
{
"type": "string",
"enum": ["x64", "arm64", "x86", "loongarch64", "riscv64"]
},
{
"$ref": "#/$defs/platform"
}
]
},
"toolId": {
"type": "string",
"pattern": "^[a-zA-Z0-9_.-]+$"
Expand Down Expand Up @@ -70,9 +93,9 @@
"platforms": {
"type": "array",
"items": {
"$ref": "#/$defs/os"
"$ref": "#/$defs/platformSelector"
},
"description": "Operating systems this backend supports"
"description": "Operating systems, architectures, or platforms this backend supports"
},
"options": {
"type": "object",
Expand All @@ -82,7 +105,7 @@
"type": "object",
"description": "Platform-specific options (e.g., macos-arm64, linux-x64)",
"propertyNames": {
"pattern": "^(linux|macos|windows)-(x64|arm64|armv7)$"
"$ref": "#/$defs/optionPlatform"
},
"additionalProperties": {
"type": "object",
Expand Down
Loading