Skip to content

Commit 835015d

Browse files
svenfuchsvitalie
authored andcommitted
Shared build workspaces (#167) ship:docker
1 parent 5ce1700 commit 835015d

File tree

7 files changed

+206
-0
lines changed

7 files changed

+206
-0
lines changed

lib/travis/yml/schema/def/job.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
require 'travis/yml/schema/def/group'
88
require 'travis/yml/schema/def/osx_image'
99
require 'travis/yml/schema/def/services'
10+
require 'travis/yml/schema/def/workspaces'
1011
require 'travis/yml/schema/type'
1112

1213
module Travis
@@ -32,6 +33,7 @@ def define
3233
map :if, to: :condition
3334
map :services
3435
map :group
36+
map :workspaces
3537

3638
map :before_install, to: :seq, summary: 'Scripts to run before the install stage'
3739
map :install, to: :seq, summary: 'Scripts to run at the install stage'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# frozen_string_literal: true
2+
require 'travis/yml/schema/type'
3+
4+
module Travis
5+
module Yml
6+
module Schema
7+
module Def
8+
class Workspaces < Type::Seq
9+
register :workspaces
10+
11+
def define
12+
title 'Workspaces'
13+
14+
summary 'Shared build workspaces'
15+
16+
description <<~str
17+
Workspaces allow jobs within the same build to share files. They are
18+
useful when you want to use build artifacts from a previous job.
19+
For example, you create a cache that can be used in multiple jobs
20+
in the same build later.
21+
str
22+
23+
see 'Workspaces': 'https://docs.travis-ci.com/user/using-workspaces'
24+
25+
normal
26+
type :workspace
27+
export
28+
end
29+
end
30+
31+
class Workspace < Type::Map
32+
register :workspace
33+
34+
def define
35+
prefix :name
36+
37+
map :name, to: :str
38+
map :create, to: :bool
39+
40+
normal
41+
export
42+
end
43+
end
44+
end
45+
end
46+
end
47+
end
48+

schema.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@
909909
"group": {
910910
"$ref": "#/definitions/type/group"
911911
},
912+
"workspaces": {
913+
"$ref": "#/definitions/type/workspaces"
914+
},
912915
"before_install": {
913916
"$ref": "#/definitions/type/strs",
914917
"summary": "Scripts to run before the install stage"
@@ -2387,6 +2390,53 @@
23872390
"see": {
23882391
"Customizing the Build": "https://docs.travis-ci.com/user/customizing-the-build/"
23892392
}
2393+
},
2394+
"workspace": {
2395+
"$id": "workspace",
2396+
"title": "Workspace",
2397+
"anyOf": [
2398+
{
2399+
"type": "object",
2400+
"properties": {
2401+
"name": {
2402+
"type": "string"
2403+
},
2404+
"create": {
2405+
"type": "boolean"
2406+
}
2407+
},
2408+
"additionalProperties": false,
2409+
"prefix": {
2410+
"key": "name"
2411+
},
2412+
"normal": true
2413+
},
2414+
{
2415+
"type": "string"
2416+
}
2417+
],
2418+
"normal": true
2419+
},
2420+
"workspaces": {
2421+
"$id": "workspaces",
2422+
"title": "Workspaces",
2423+
"description": "Workspaces allow jobs within the same build to share files. They are\nuseful when you want to use build artifacts from a previous job.\nFor example, you create a cache that can be used in multiple jobs\nin the same build later.",
2424+
"anyOf": [
2425+
{
2426+
"type": "array",
2427+
"items": {
2428+
"$ref": "#/definitions/type/workspace"
2429+
},
2430+
"normal": true
2431+
},
2432+
{
2433+
"$ref": "#/definitions/type/workspace"
2434+
}
2435+
],
2436+
"summary": "Shared build workspaces",
2437+
"see": {
2438+
"Workspaces": "https://docs.travis-ci.com/user/using-workspaces"
2439+
}
23902440
}
23912441
},
23922442
"addon": {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
describe Travis::Yml do
2+
accept 'workspaces' do
3+
describe 'given a str' do
4+
yaml %(
5+
workspaces: ws1
6+
)
7+
it { should serialize_to workspaces: [name: 'ws1'] }
8+
end
9+
10+
describe 'given a map' do
11+
yaml %(
12+
workspaces:
13+
name: ws1
14+
)
15+
it { should serialize_to workspaces: [name: 'ws1'] }
16+
end
17+
18+
describe 'given a seq of strs' do
19+
yaml %(
20+
workspaces:
21+
- ws1
22+
)
23+
it { should serialize_to workspaces: [name: 'ws1'] }
24+
end
25+
26+
describe 'given a seq of maps' do
27+
yaml %(
28+
workspaces:
29+
- name: ws1
30+
create: true
31+
)
32+
it { should serialize_to workspaces: [name: 'ws1', create: true] }
33+
end
34+
end
35+
end

spec/travis/yml/schema/def/job_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
virt: {
3939
'$ref': '#/definitions/type/virt'
4040
},
41+
workspaces: {
42+
'$ref': '#/definitions/type/workspaces'
43+
},
4144
before_install: {
4245
'$ref': '#/definitions/type/strs',
4346
summary: 'Scripts to run before the install stage'

spec/travis/yml/schema/def/root_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@
136136
version
137137
virt
138138
vm
139+
workspace
140+
workspaces
139141
),
140142
addon: %i(
141143
apt
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
describe Travis::Yml::Schema::Def::Workspaces do
2+
describe 'workspaces' do
3+
subject { Travis::Yml.schema[:definitions][:type][:workspaces] }
4+
5+
# it { puts JSON.pretty_generate(subject) }
6+
7+
it do
8+
should include(
9+
'$id': :workspaces,
10+
title: 'Workspaces',
11+
summary: kind_of(String),
12+
description: kind_of(String),
13+
see: {
14+
Workspaces: kind_of(String)
15+
},
16+
anyOf: [
17+
{
18+
type: :array,
19+
items: {
20+
'$ref': '#/definitions/type/workspace',
21+
},
22+
normal: true,
23+
},
24+
{
25+
'$ref': '#/definitions/type/workspace',
26+
}
27+
],
28+
)
29+
end
30+
end
31+
32+
describe 'workspace' do
33+
subject { Travis::Yml.schema[:definitions][:type][:workspace] }
34+
35+
# it { puts JSON.pretty_generate(subject) }
36+
37+
it do
38+
should include(
39+
'$id': :workspace,
40+
title: 'Workspace',
41+
anyOf: [
42+
{
43+
type: :object,
44+
properties: {
45+
name: {
46+
type: :string
47+
},
48+
create: {
49+
type: :boolean
50+
}
51+
},
52+
prefix: {
53+
key: :name
54+
},
55+
additionalProperties: false,
56+
normal: true
57+
},
58+
{
59+
type: :string
60+
}
61+
],
62+
normal: true
63+
)
64+
end
65+
end
66+
end

0 commit comments

Comments
 (0)