diff --git a/lib/travis/yml/schema/def/lxd_build.rb b/lib/travis/yml/schema/def/lxd_build.rb new file mode 100644 index 000000000..279ea3d6c --- /dev/null +++ b/lib/travis/yml/schema/def/lxd_build.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true +require 'travis/yml/schema/type' + +module Travis + module Yml + module Schema + module Def + module LxdBuildDefs + class LxdBuild < Type::Map + register :lxd_build + + def define + summary 'Build an LXD image' + + description <<~str + Build an LXD image + str + + map :dist, to: :lxd_dist, required: true + map :name, to: :lxd_name, required: true + map :description, to: :lxd_description + map :commands, to: :lxd_commands + + export + end + end + end + end + end + end +end + +require 'travis/yml/schema/def/lxd_build_defs/lxd_dist' +require 'travis/yml/schema/def/lxd_build_defs/lxd_name' +require 'travis/yml/schema/def/lxd_build_defs/lxd_description' +require 'travis/yml/schema/def/lxd_build_defs/lxd_commands' diff --git a/lib/travis/yml/schema/def/lxd_build_defs/lxd_commands.rb b/lib/travis/yml/schema/def/lxd_build_defs/lxd_commands.rb new file mode 100644 index 000000000..29c192920 --- /dev/null +++ b/lib/travis/yml/schema/def/lxd_build_defs/lxd_commands.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true +require 'travis/yml/schema/type' + +module Travis + module Yml + module Schema + module Def + module LxdBuildDefs + class LxdCommands < Type::Seq + register :lxd_commands + + def define + summary 'LXD image commands' + description 'Run commands during LXD image setup' + normal + type :lxd_command + + export + end + end + + class LxdCommand < Type::Str + register :lxd_command + + def define + summary 'LXD command' + example 'apt-get -y install python3.8' + export + end + end + end + end + end + end +end diff --git a/lib/travis/yml/schema/def/lxd_build_defs/lxd_description.rb b/lib/travis/yml/schema/def/lxd_build_defs/lxd_description.rb new file mode 100644 index 000000000..c680c0e46 --- /dev/null +++ b/lib/travis/yml/schema/def/lxd_build_defs/lxd_description.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +require 'travis/yml/schema/type' + +module Travis + module Yml + module Schema + module Def + module LxdBuildDefs + class LxdDescription < Type::Str + register :lxd_description + + def define + summary 'LXD image description' + example 'My custom image description' + export + end + end + end + end + end + end +end diff --git a/lib/travis/yml/schema/def/lxd_build_defs/lxd_dist.rb b/lib/travis/yml/schema/def/lxd_build_defs/lxd_dist.rb new file mode 100644 index 000000000..ba64c0a00 --- /dev/null +++ b/lib/travis/yml/schema/def/lxd_build_defs/lxd_dist.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true +require 'travis/yml/schema/type' + +module Travis + module Yml + module Schema + module Def + module LxdBuildDefs + class LxdDist < Type::Str + register :lxd_dist + + def define + title 'Distribution' + summary 'LXD image Ubuntu distribution' + see 'Virtualization environments': 'https://docs.travis-ci.com/user/reference/overview/#virtualization-environments' + + downcase + + value :focal + value :bionic + + export + end + end + end + end + end + end +end diff --git a/lib/travis/yml/schema/def/lxd_build_defs/lxd_name.rb b/lib/travis/yml/schema/def/lxd_build_defs/lxd_name.rb new file mode 100644 index 000000000..77535d61a --- /dev/null +++ b/lib/travis/yml/schema/def/lxd_build_defs/lxd_name.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true +require 'travis/yml/schema/type' + +module Travis + module Yml + module Schema + module Def + module LxdBuildDefs + class LxdName < Type::Str + register :lxd_name + + def define + summary 'LXD image name' + example 'my-custom-image' + export + end + end + end + end + end + end +end diff --git a/lib/travis/yml/schema/def/os_custom.rb b/lib/travis/yml/schema/def/os_custom.rb new file mode 100644 index 000000000..92ab8a362 --- /dev/null +++ b/lib/travis/yml/schema/def/os_custom.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true +require 'travis/yml/schema/type' + +module Travis + module Yml + module Schema + module Def + class OsCustom < Type::Str + register :os_custom + + def define + summary 'Use a custom LXD image' + export + end + end + end + end + end +end diff --git a/lib/travis/yml/schema/def/root.rb b/lib/travis/yml/schema/def/root.rb index e576449f9..41c375f74 100644 --- a/lib/travis/yml/schema/def/root.rb +++ b/lib/travis/yml/schema/def/root.rb @@ -10,12 +10,14 @@ require 'travis/yml/schema/def/language' require 'travis/yml/schema/def/notification' require 'travis/yml/schema/def/os' +require 'travis/yml/schema/def/os_custom' require 'travis/yml/schema/def/stack' require 'travis/yml/schema/def/stages' require 'travis/yml/schema/def/sudo' require 'travis/yml/schema/def/version' require 'travis/yml/schema/def/virt' require 'travis/yml/schema/def/vm' +require 'travis/yml/schema/def/lxd_build' require 'travis/yml/schema/type' module Travis @@ -53,6 +55,7 @@ def define map :language, default: DEFAULT[:language] matrix :os, default: DEFAULT[:os], to: :oss + map :os_custom map :dist, default: ENV['TRAVIS_DEFAULT_DIST'] || DEFAULT[:dist] matrix :arch, to: :archs map :stack @@ -64,6 +67,7 @@ def define map :stages map :jobs, alias: :matrix map :notifications + map :lxd_build map :version map :vm, default: DEFAULT[:vm] diff --git a/schema.json b/schema.json index 852779d4d..30b292d94 100644 --- a/schema.json +++ b/schema.json @@ -52,6 +52,9 @@ "expand" ] }, + "os_custom": { + "$ref": "#/definitions/type/os_custom" + }, "dist": { "$ref": "#/definitions/type/dist", "defaults": [ @@ -1757,6 +1760,12 @@ "Build Environment Overview": "https://docs.travis-ci.com/user/reference/overview/" } }, + "os_custom": { + "$id": "os_custom", + "title": "Custom LXD image name", + "type": "string", + "summary": "Use a custom LXD image" + }, "osx_images": { "$id": "osx_images", "title": "Osx Images", @@ -2175,6 +2184,28 @@ "see": { "Customizing the Build": "https://docs.travis-ci.com/customizing-the-build/" } + }, + "lxd_build": { + "$id": "lxd_build", + "title": "LXD Build", + "description": "Build an LXD image", + "type": "object", + "properties": { + "dist": { + "$ref": "#/definitions/lxd_build_defs/lxd_dist" + }, + "name": { + "$ref": "#/definitions/lxd_build_defs/lxd_name" + }, + "description": { + "$ref": "#/definitions/lxd_build_defs/lxd_description" + }, + "commands": { + "$ref": "#/definitions/lxd_build_defs/lxd_commands" + } + }, + "additionalProperties": false, + "summary": "Build an LXD image" } }, "addon": { @@ -10064,6 +10095,61 @@ }, "normal": true } + }, + "lxd_build_defs": { + "lxd_command": { + "$id": "lxd_command", + "title": "Lxd Command", + "type": "string", + "summary": "LXD command", + "example": "apt-get -y install python3.8" + }, + "lxd_commands": { + "$id": "lxd_commands", + "title": "Lxd Commands", + "description": "Run commands during LXD image setup", + "anyOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/lxd_build_defs/lxd_command" + }, + "normal": true + }, + { + "$ref": "#/definitions/lxd_build_defs/lxd_command" + } + ], + "summary": "LXD image commands" + }, + "lxd_description": { + "$id": "lxd_description", + "title": "Lxd Description", + "type": "string", + "summary": "LXD image description", + "example": "My custom image description" + }, + "lxd_dist": { + "$id": "lxd_dist", + "title": "Distribution", + "type": "string", + "summary": "LXD image Ubuntu distribution", + "see": { + "Virtualization environments": "https://docs.travis-ci.com/user/reference/overview/#virtualization-environments" + }, + "downcase": true, + "enum": [ + "focal", + "bionic" + ] + }, + "lxd_name": { + "$id": "lxd_name", + "title": "Lxd Name", + "type": "string", + "summary": "LXD image name", + "example": "my-custom-image" + } } }, "expand": [