-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathci_script.d
75 lines (61 loc) · 1.57 KB
/
ci_script.d
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
import std.process;
import std.file;
import std.process;
import std.stdio;
// Commandline args
string[] unitThreadedArgs;
// Utils ///////////////////////////////////////////////
bool envBool(string name)
{
return environment.get(name, null) == "true";
}
string envGet(string name)
{
return environment.get(name, null);
}
void copyIfExists(string from, string to)
{
if(exists(from) && isFile(from))
copy(from, to);
}
void tryMkdir(string dir)
{
if(!exists(dir))
mkdir(dir);
}
int run(string command)
{
writeln(command);
return spawnShell(command).wait;
}
// Main ///////////////////////////////////////////////
int main(string[] args)
{
unitThreadedArgs = args[1..$];
//writeln("unitThreadedArgs: ", unitThreadedArgs);
// GDC doesn't autocreate the dir (and git doesn't beleive in empty dirs)
tryMkdir("bin");
// If an alternate dub.selections.json was requested, use it.
copyIfExists("dub.selections."~envGet("DUB_SELECT")~".json", "dub.selections.json");
if(envBool("DUB_UPGRADE"))
{
// Update all dependencies
//
// As a bonus, this downloads & resolves deps now so intermittent
// failures are more likely to be correctly marked as "job error"
// rather than "tests failed".
spawnShell("dub upgrade").wait;
}
else
{
// Don't upgrade dependencies.
//
// But download & resolve deps now so intermittent failures are more likely
// to be correctly marked as "job error" rather than "tests failed".
spawnShell("dub upgrade --missing-only").wait;
}
if(envBool("NO_UT"))
return run("dub run -c unittest-builtin");
else
return run("dub test");
}