Skip to content

Commit e95741d

Browse files
committed
restored ci_setup.d
1 parent db2df74 commit e95741d

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

ci_setup.d

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import std.file;
2+
import std.process;
3+
import std.stdio : writeln;
4+
5+
string envGet(string name)
6+
{
7+
return environment.get(name, null);
8+
}
9+
10+
bool envBool(string name)
11+
{
12+
return environment.get(name, null) == "true";
13+
}
14+
15+
void copyIfExists(string from, string to)
16+
{
17+
if(exists(from) && isFile(from))
18+
copy(from, to);
19+
}
20+
21+
int main()
22+
{
23+
auto haveRdmd = executeShell("rdmd --help").status == 0;
24+
if(!haveRdmd)
25+
{
26+
auto dmdZip = "dmd.2.076.0."~environment["TRAVIS_OS_NAME"]~".zip";
27+
spawnShell("wget http://downloads.dlang.org/releases/2017/"~dmdZip).wait;
28+
spawnShell("unzip -q -d local-dmd "~dmdZip).wait;
29+
}
30+
31+
// MySQL is not installed by default on OSX build agents
32+
auto mysqlPrefix = "";
33+
if(environment["TRAVIS_OS_NAME"] == "osx")
34+
{
35+
if(envGet("DB") == "mysql-5.6")
36+
{
37+
spawnShell("brew update").wait;
38+
spawnShell("brew install [email protected] && brew services start mysql56").wait;
39+
mysqlPrefix = "/usr/local/opt/[email protected]/bin/";
40+
}
41+
else if(envGet("DB") == "mysql-latest")
42+
{
43+
spawnShell("brew update").wait;
44+
spawnShell("brew install mysql && brew services start mysql").wait;
45+
}
46+
else
47+
{
48+
writeln("Envar 'DB' must be 'mysql-5.6' or 'mysql-latest', not '", envGet("DB"), "'");
49+
return 1;
50+
}
51+
}
52+
53+
// Use the requested version of dub.selections.json.
54+
if(envGet("DUB_SELECT") != null)
55+
{
56+
string dubSelections = "dub.selections."~envGet("DUB_SELECT")~".json";
57+
writeln("Using alternative dub dependencies file: ", dubSelections);
58+
copy(dubSelections, "dub.selections.json");
59+
copy("examples/homePage/dub.selections."~envGet("DUB_SELECT")~".json", "examples/homePage/dub.selections.json");
60+
}
61+
else if(!envBool("NO_VIBE") && !envBool("DUB_UPGRADE"))
62+
{
63+
writeln("ERROR: All travis jobs must specify one of the following environment variables:");
64+
writeln(" DUB_SELECT=... *or* DUB_UPGRADE=true *or* NO_VIBE=true.");
65+
return 1;
66+
}
67+
68+
// Download (and maybe upgrade) DUB dependencies
69+
//
70+
// Doing this here, instead of when "dub test" is run later,
71+
// ensures that any intermittent server
72+
// failures are more likely to be correctly marked as "job error"
73+
// rather than "tests failed".
74+
if(envBool("DUB_UPGRADE"))
75+
{
76+
// Update all dependencies
77+
writeln("Updating all DUB dependencies...");
78+
spawnShell("dub upgrade").wait;
79+
chdir("examples/homePage");
80+
spawnShell("dub upgrade").wait;
81+
chdir("../..");
82+
}
83+
else
84+
{
85+
// Don't upgrade dependencies.
86+
writeln("Downloading dependencies WITHOUT upgrading them...");
87+
spawnShell("dub upgrade --missing-only").wait;
88+
chdir("examples/homePage");
89+
spawnShell("dub upgrade --missing-only").wait;
90+
chdir("../..");
91+
}
92+
93+
// Setup DB
94+
spawnShell(mysqlPrefix~`mysql -u root -e 'SHOW VARIABLES LIKE "%version%";'`).wait;
95+
spawnShell(mysqlPrefix~`mysql -u root -e 'CREATE DATABASE mysqln_testdb;'`).wait;
96+
write("testConnectionStr.txt", "host=127.0.0.1;port=3306;user=root;pwd=;db=mysqln_testdb");
97+
98+
return 0;
99+
}

0 commit comments

Comments
 (0)