Skip to content

Commit

Permalink
Merge pull request #154 from travis-ci/freebsd_pkg_addon
Browse files Browse the repository at this point in the history
Freebsd pkg addon
  • Loading branch information
DamianSzymanski committed Mar 4, 2020
2 parents 68ee09b + e5ba9a3 commit 38bd987
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/travis/yml/schema/def/addon/pkg.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true
require 'travis/yml/schema/type'

module Travis
module Yml
module Schema
module Def
module Addon
class Pkg < Addon
register :pkg

def define
prefix :packages

map :packages, to: :seq, alias: :package, summary: 'Package names', eg: 'cmake'
map :branch, to: :str, summary: 'Packages branch', eg: 'quarterly'
end
end
end
end
end
end
end
2 changes: 2 additions & 0 deletions lib/travis/yml/schema/def/addons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def define
map :hosts, to: :seq, summary: 'Hosts to add to /etc/hosts'
map :jwt, to: :jwts
map :sauce_connect
map :pkg

# turn this into a proper addon definition. the map allows the key debug: true
map :srcclr, to: Class.new(Type::Any) {
Expand Down Expand Up @@ -78,4 +79,5 @@ def define
require 'travis/yml/schema/def/addon/jwts'
require 'travis/yml/schema/def/addon/sauce_connect'
require 'travis/yml/schema/def/addon/snaps'
require 'travis/yml/schema/def/addon/pkg'
require 'travis/yml/schema/def/addon/sonarcloud'
45 changes: 45 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
"sauce_connect": {
"$ref": "#/definitions/addon/sauce_connect"
},
"pkg": {
"$ref": "#/definitions/addon/pkg"
},
"srcclr": {
"anyOf": [
{
Expand Down Expand Up @@ -2491,6 +2494,48 @@
},
"deprecated": "Discontinued as of April 17, 2018"
},
"pkg": {
"$id": "pkg",
"title": "Pkg",
"anyOf": [
{
"type": "object",
"properties": {
"packages": {
"$ref": "#/definitions/type/strs",
"aliases": [
"package"
],
"summary": "Package names",
"example": "cmake"
},
"branch": {
"type": "string",
"summary": "Packages branch",
"example": "quarterly"
}
},
"additionalProperties": false,
"prefix": {
"key": "packages"
},
"normal": true,
"changes": [
{
"change": "enable"
}
]
},
{
"$ref": "#/definitions/type/strs",
"example": "cmake"
},
{
"type": "boolean"
}
],
"normal": true
},
"sauce_connect": {
"$id": "sauce_connect",
"title": "Sauce Connect",
Expand Down
55 changes: 55 additions & 0 deletions spec/travis/yml/accept/addon/pkg_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
describe Travis::Yml, 'addon: pkg' do
subject { described_class.apply(parse(yaml)) }

describe 'packages given a string' do
yaml %(
addons:
pkg:
packages: str
)
it { should serialize_to addons: { pkg: { packages: ['str'] } } }
it { should_not have_msg }
end

describe 'package given a string (alias)' do
yaml %(
addons:
pkg:
package: str
)
it { should serialize_to addons: { pkg: { packages: ['str'] } } }
it { should have_msg [:info, :'addons.pkg', :alias_key, alias: 'package', key: 'packages'] }
end

describe 'packages given a seq' do
yaml %(
addons:
pkg:
packages:
- str
)
it { should serialize_to addons: { pkg: { packages: ['str'] } } }
it { should_not have_msg }
end

describe 'package given a seq (alias)' do
yaml %(
addons:
pkg:
package:
- str
)
it { should serialize_to addons: { pkg: { packages: ['str'] } } }
it { should have_msg [:info, :'addons.pkg', :alias_key, alias: 'package', key: 'packages'] }
end

describe 'branch given a string' do
yaml %(
addons:
pkg:
branch: str
)
it { should serialize_to addons: { pkg: { branch: 'str' } } }
it { should_not have_msg }
end
end
50 changes: 50 additions & 0 deletions spec/travis/yml/schema/def/addon/pkg_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
describe Travis::Yml::Schema::Def::Addon::Pkg do
subject { Travis::Yml.schema[:definitions][:addon][:pkg] }

# it { puts JSON.pretty_generate(subject) }

it do
should eq(
'$id': :pkg,
title: 'Pkg',
anyOf: [
{
type: :object,
properties: {
packages: {
'$ref': '#/definitions/type/strs',
aliases: [
:package
],
summary: 'Package names',
example: 'cmake'
},
branch: {
type: :string,
summary: 'Packages branch',
example: 'quarterly'
}
},
additionalProperties: false,
prefix: {
key: :packages
},
normal: true,
changes: [
{
change: :enable
}
]
},
{
'$ref': '#/definitions/type/strs',
example: 'cmake'
},
{
type: :boolean
}
],
normal: true,
)
end
end
1 change: 1 addition & 0 deletions spec/travis/yml/schema/def/root_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
jwts
sauce_connect
snaps
pkg
sonarcloud
),
deploy: %i(
Expand Down

0 comments on commit 38bd987

Please sign in to comment.