diff --git a/.tangled/workflow.schema.json b/.tangled/workflow.schema.json --- a/.tangled/workflow.schema.json +++ b/.tangled/workflow.schema.json @@ -2,14 +2,14 @@ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://rssbase.io/schemas/tangled-workflow.schema.json", "title": "Tangled Spindle workflow", - "description": "Local JSON Schema for Tangled CI / Spindle workflow files under .tangled/workflows/*.yml. Based on https://docs.tangled.org/spindles.", + "description": "Local JSON Schema for Tangled CI / Spindle workflow files under .tangled/workflows/*.yml. Based on https://docs.tangled.org/spindles and Tangled's workflow parser.", "type": "object", "additionalProperties": false, "required": ["when", "engine"], "properties": { "when": { "title": "Trigger conditions", - "description": "Defines when the workflow runs. Each condition can match events, branches, and/or tags.", + "description": "Defines when the workflow runs. Each condition can match events, branches, tags, and optional changed-file path globs.", "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/trigger" }, @@ -25,6 +25,12 @@ "label": "tag push", "body": [ { "event": ["push"], "tag": ["v*"] } + ] + }, + { + "label": "path-filtered push", + "body": [ + { "event": "push", "branch": "main", "paths": ["src/**", "package.json"] } ] } ] @@ -56,12 +62,16 @@ "description": "Recursively fetch git submodules. Default: false.", "type": "boolean", "default": false + }, + "tags": { + "description": "Fetch Git tags during clone. Default depends on the Spindle runner.", + "type": "boolean" } }, "defaultSnippets": [ { "label": "default clone options", - "body": { "skip": false, "depth": 1, "submodules": false } + "body": { "skip": false, "depth": 1, "submodules": false, "tags": false } } ] }, @@ -244,7 +254,7 @@ { "event": ["pull_request"], "branch": ["main"] } ], "engine": "nixery", - "clone": { "skip": false, "depth": 1, "submodules": false }, + "clone": { "skip": false, "depth": 1, "submodules": false, "tags": false }, "dependencies": { "nixpkgs": ["nodejs", "go"] }, @@ -262,29 +272,32 @@ "required": ["event"], "properties": { "event": { - "description": "Events that can trigger this condition.", - "type": "array", - "minItems": 1, - "uniqueItems": true, - "items": { - "type": "string", - "enum": ["push", "pull_request", "manual"] - } + "description": "Events that can trigger this condition. Tangled accepts either a single string or a list.", + "$ref": "#/definitions/eventList" }, "branch": { - "description": "Branch patterns. For push, matches pushed branches. For pull_request, matches target branches. No effect for manual. Supports * and ** globs.", - "$ref": "#/definitions/patternList" + "description": "Branch patterns. For push, matches pushed branches. For pull_request, matches target branches. No effect for manual. Supports * and ** globs. Tangled accepts either a single string or a list.", + "$ref": "#/definitions/stringOrPatternList" }, "tag": { - "description": "Tag patterns for push events. No effect for pull_request or manual. Supports * and ** globs.", - "$ref": "#/definitions/patternList" + "description": "Tag patterns for push events. No effect for pull_request or manual. Supports * and ** globs. Tangled accepts either a single string or a list.", + "$ref": "#/definitions/stringOrPatternList" + }, + "paths": { + "description": "Changed-file path globs. If set, the workflow only runs when at least one changed file matches one of these patterns. Supports * and ** globs. Tangled accepts either a single string or a list.", + "$ref": "#/definitions/stringOrPatternList" } }, "allOf": [ { "if": { "properties": { - "event": { "contains": { "const": "push" } } + "event": { + "anyOf": [ + { "const": "push" }, + { "type": "array", "contains": { "const": "push" } } + ] + } }, "required": ["event"] }, @@ -294,12 +307,32 @@ { "required": ["tag"] } ] } + }, + { + "if": { + "properties": { + "event": { + "anyOf": [ + { "const": "pull_request" }, + { "type": "array", "contains": { "const": "pull_request" } } + ] + } + }, + "required": ["event"] + }, + "then": { + "required": ["branch"] + } } ], "defaultSnippets": [ { "label": "push to main", "body": { "event": ["push"], "branch": ["main"] } + }, + { + "label": "path-filtered push to main", + "body": { "event": "push", "branch": "main", "paths": ["src/**"] } }, { "label": "pull request to main", @@ -315,10 +348,33 @@ } ] }, + "eventList": { + "oneOf": [ + { + "type": "string", + "enum": ["push", "pull_request", "manual"] + }, + { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string", + "enum": ["push", "pull_request", "manual"] + } + } + ] + }, "patternList": { "type": "array", "minItems": 1, "items": { "type": "string" } + }, + "stringOrPatternList": { + "oneOf": [ + { "type": "string" }, + { "$ref": "#/definitions/patternList" } + ] }, "environment": { "type": "object", diff --git a/.tangled/workflows/build.yml b/.tangled/workflows/build.yml --- a/.tangled/workflows/build.yml +++ b/.tangled/workflows/build.yml @@ -2,9 +2,13 @@ when: - event: ["push", "manual"] - branch: ["main"] - - event: ["pull_request"] - branch: ["main"] + branch: main + paths: + - application/** + - event: pull_request + branch: main + paths: + - application/** engine: microvm image: nixos diff --git a/.tangled/workflows/check.yml b/.tangled/workflows/check.yml --- a/.tangled/workflows/check.yml +++ b/.tangled/workflows/check.yml @@ -2,9 +2,9 @@ when: - event: ["push", "manual"] - branch: ["main"] - - event: ["pull_request"] - branch: ["main"] + branch: main + - event: pull_request + branch: main engine: microvm image: nixos