Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freebsd pkg addon #154

Merged
merged 8 commits into from
Mar 4, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd suggest using names here pkg already suggests "package", so "package names" would read better than "package package".

also, i'd suggest not adding aliases unless we have to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was suggestion from freebsd community c (like apt)

  pkg:
    packages:
    - cmake
    - vim

and alias

  pkg:
    package: cmake

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Ubuntu builds we keep aliases as follows:

addons:
  apt:
    packages:
  • so FreeBSD community proposed something consistent. The apt is replaced with pkg in FreeBSD, which may be not so fortunate, but I'm for keeping it consistent with linux based mechanism - less confusion for users

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and we already made it consistent on macos:

addons:
  homebrew:
    packages:

so if we introduce something different now, we should allow it for all other OSes - I'd prefer to give less options to the users

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 @@ -2472,6 +2475,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