-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
require 'travis/yml/schema/type' | ||
|
||
module Travis | ||
module Yml | ||
module Schema | ||
module Def | ||
class Workspaces < Type::Seq | ||
register :workspaces | ||
|
||
def define | ||
title 'Workspaces' | ||
|
||
summary 'Shared build workspaces' | ||
|
||
description <<~str | ||
Workspaces allow jobs within the same build to share files. They are | ||
useful when you want to use build artifacts from a previous job. | ||
For example, you create a cache that can be used in multiple jobs | ||
in the same build later. | ||
str | ||
|
||
see 'Workspaces': 'https://docs.travis-ci.com/user/using-workspaces' | ||
|
||
normal | ||
type :workspace | ||
export | ||
end | ||
end | ||
|
||
class Workspace < Type::Map | ||
register :workspace | ||
|
||
def define | ||
prefix :name | ||
|
||
map :name, to: :str | ||
map :create, to: :bool | ||
|
||
normal | ||
export | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
describe Travis::Yml do | ||
accept 'workspaces' do | ||
describe 'given a str' do | ||
yaml %( | ||
workspaces: ws1 | ||
) | ||
it { should serialize_to workspaces: [name: 'ws1'] } | ||
end | ||
|
||
describe 'given a map' do | ||
yaml %( | ||
workspaces: | ||
name: ws1 | ||
) | ||
it { should serialize_to workspaces: [name: 'ws1'] } | ||
end | ||
|
||
describe 'given a seq of strs' do | ||
yaml %( | ||
workspaces: | ||
- ws1 | ||
) | ||
it { should serialize_to workspaces: [name: 'ws1'] } | ||
end | ||
|
||
describe 'given a seq of maps' do | ||
yaml %( | ||
workspaces: | ||
- name: ws1 | ||
create: true | ||
) | ||
it { should serialize_to workspaces: [name: 'ws1', create: true] } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,8 @@ | |
version | ||
virt | ||
vm | ||
workspace | ||
workspaces | ||
), | ||
addon: %i( | ||
apt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
describe Travis::Yml::Schema::Def::Workspaces do | ||
describe 'workspaces' do | ||
subject { Travis::Yml.schema[:definitions][:type][:workspaces] } | ||
|
||
# it { puts JSON.pretty_generate(subject) } | ||
|
||
it do | ||
should include( | ||
'$id': :workspaces, | ||
title: 'Workspaces', | ||
summary: kind_of(String), | ||
description: kind_of(String), | ||
see: { | ||
Workspaces: kind_of(String) | ||
}, | ||
anyOf: [ | ||
{ | ||
type: :array, | ||
items: { | ||
'$ref': '#/definitions/type/workspace', | ||
}, | ||
normal: true, | ||
}, | ||
{ | ||
'$ref': '#/definitions/type/workspace', | ||
} | ||
], | ||
) | ||
end | ||
end | ||
|
||
describe 'workspace' do | ||
subject { Travis::Yml.schema[:definitions][:type][:workspace] } | ||
|
||
# it { puts JSON.pretty_generate(subject) } | ||
|
||
it do | ||
should include( | ||
'$id': :workspace, | ||
title: 'Workspace', | ||
anyOf: [ | ||
{ | ||
type: :object, | ||
properties: { | ||
name: { | ||
type: :string | ||
}, | ||
create: { | ||
type: :boolean | ||
} | ||
}, | ||
prefix: { | ||
key: :name | ||
}, | ||
additionalProperties: false, | ||
normal: true | ||
}, | ||
{ | ||
type: :string | ||
} | ||
], | ||
normal: true | ||
) | ||
end | ||
end | ||
end |