blob: 277353fb43b5b86c6d6e1a965389a98cec0f1cce (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
module session;
import core.stdc.stdlib : exit, EXIT_FAILURE;
import std.array;
import std.file;
import std.stdio;
import std.string;
import util;
import dyaml;
struct TestExtended_t {
string name;
string[string] runtime;
string test_args;
string[] commands;
}
struct Session_t {
string delivery_name;
string delivery_version;
ubyte delivery_rev;
string delivery_platform;
string delivery_python;
string delivery;
string base_spec;
string on_error;
string script_pre;
string script_post;
string[string] runtime;
string[] conda_channels;
string[] conda_requirements;
string[] pip_index;
string[] pip_requirements;
bool run_tests = false;
string test_program = "pytest";
string test_args = "-v";
TestExtended_t[] test_extended;
string[] test_conda_requirements;
string[] test_pip_requirements;
string[] test_filter_git_orgs;
string[] test_filter_git_projects;
}
Session_t getconf(string filename) {
Node root = Loader.fromFile(filename).load();
Node data;
Session_t session;
/// Required configuration items
try {
session.delivery_name = root["delivery_name"].as!string;
session.delivery_version = root["delivery_version"].as!string;
session.delivery_rev = root["delivery_rev"].as!ubyte;
session.delivery_python = root["delivery_python"].as!string;
if (!session.delivery_python.empty) {
session.conda_requirements ~= "python=" ~ session.delivery_python;
}
version (OSX) session.delivery_platform = "osx";
version (linux) session.delivery_platform = "linux";
version (Windows) session.delivery_platform = "windows";
session.delivery = format("%s-%s-%s-py%s.%02d",
session.delivery_name,
session.delivery_version,
session.delivery_platform,
short_version(session.delivery_python),
session.delivery_rev);
} catch (YAMLException e) {
stderr.writefln("\n%s: configuration error!\n%s\n", filename, e.msg);
exit(EXIT_FAILURE);
}
/// Optional configuration items
if (root.containsKey("base_spec"))
session.base_spec = root["base_spec"].as!string;
if (root.containsKey("on_error"))
session.on_error = root["on_error"].as!string;
if (root.containsKey("script_pre"))
session.script_pre = root["script_pre"].as!string;
if (root.containsKey("script_post"))
session.script_post = root["script_post"].as!string;
if (root.containsKey("runtime")) {
data = root["runtime"];
foreach (Node k, Node v; data)
session.runtime[k.as!string] = v.as!string;
}
if (root.containsKey("conda_channels")) {
data = root["conda_channels"];
foreach (Node v; data)
session.conda_channels ~= v.as!string;
}
if (root.containsKey("conda_requirements")) {
data = root["conda_requirements"];
foreach (Node v; data)
session.conda_requirements ~= v.as!string;
}
if (root.containsKey("pip_index")) {
data = root["pip_index"];
foreach (Node v; data)
session.pip_index ~= v.as!string;
}
if (root.containsKey("pip_requirements")) {
data = root["pip_requirements"];
foreach (Node v; data)
session.pip_requirements ~= v.as!string;
}
if (root.containsKey("run_tests")) {
session.run_tests = root["run_tests"].as!bool;
}
if (root.containsKey("test_program")) {
session.test_program = root["test_program"].as!string;
}
if (root.containsKey("test_args")) {
session.test_args = root["test_args"].as!string;
}
if (root.containsKey("test_conda_requirements")) {
data = root["test_conda_requirements"];
foreach (Node v; data)
session.test_conda_requirements ~= v.as!string;
}
if (root.containsKey("test_pip_requirements")) {
data = root["test_pip_requirements"];
foreach (Node v; data)
session.test_pip_requirements ~= v.as!string;
}
if (root.containsKey("test_filter_git_orgs")) {
data = root["test_filter_git_orgs"];
foreach (Node v; data)
session.test_filter_git_orgs ~= v.as!string;
}
if (root.containsKey("test_filter_git_projects")) {
data = root["test_filter_git_projects"];
foreach (Node v; data)
session.test_filter_git_projects ~= v.as!string;
}
if (root.containsKey("test_extended")) {
TestExtended_t te;
data = root["test_extended"];
foreach (Node parent_1, Node child_1; data) {
te.name = parent_1.as!string;
if (child_1.containsKey("runtime")) {
foreach (Node parent_2, Node child_2; child_1["runtime"]) {
te.runtime[parent_2.as!string] = child_2.as!string;
}
}
if (child_1.containsKey("commands")) {
foreach (Node v; child_1["commands"]) {
te.commands ~= v.as!string.strip;
}
}
if (child_1.containsKey("test_args")) {
te.test_args = child_1["test_args"].as!string;
}
session.test_extended ~= te;
}
}
return session;
}
|