Skip to content

Commit 8d77497

Browse files
committed
Convert CI setup script from bash to D.
1 parent 3ea8dbc commit 8d77497

File tree

3 files changed

+70
-38
lines changed

3 files changed

+70
-38
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ addons:
66
apt:
77
packages: [ libevent-dev ]
88

9-
install: ./travis-setup.sh
9+
install: $DMD -ofci_setup ci_setup.d && ./ci_setup
1010
script: ./run-tests
1111

1212
matrix:

ci_setup.d

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import std.file;
2+
import std.process;
3+
4+
bool envBool(string name)
5+
{
6+
return environment.get(name, null) == "true";
7+
}
8+
9+
string envGet(string name)
10+
{
11+
return environment.get(name, null);
12+
}
13+
14+
void copyIfExists(string from, string to)
15+
{
16+
if(exists(from) && isFile(from))
17+
copy(from, to);
18+
}
19+
20+
void main()
21+
{
22+
auto haveRdmd = executeShell("rdmd --help").status == 0;
23+
if(!haveRdmd)
24+
{
25+
auto dmdZip = "dmd.2.076.0."~environment["TRAVIS_OS_NAME"]~".zip";
26+
spawnShell("wget http://downloads.dlang.org/releases/2017/"~dmdZip).wait;
27+
spawnShell("unzip -d local-dmd "~dmdZip).wait;
28+
}
29+
30+
// MySQL is not installed by default on OSX build agents
31+
if(environment["TRAVIS_OS_NAME"] == "osx")
32+
{
33+
spawnShell("brew update").wait;
34+
spawnShell("brew install mysql && brew services start mysql").wait;
35+
}
36+
37+
// If an alternate dub.selections.json was requested, use it.
38+
copyIfExists("dub.selections."~envGet("DUB_SELECT")~".json", "dub.selections.json");
39+
copyIfExists("examples/homePage/dub.selections."~envGet("DUB_SELECT")~".json", "examples/homePage/dub.selections.json");
40+
41+
if(envBool("DUB_UPGRADE"))
42+
{
43+
// Update all dependencies
44+
//
45+
// As a bonus, this downloads & resolves deps now so intermittent
46+
// failures are more likely to be correctly marked as "job error"
47+
// rather than "tests failed".
48+
spawnShell("dub upgrade").wait;
49+
chdir("examples/homePage");
50+
spawnShell("dub upgrade").wait;
51+
chdir("../..");
52+
}
53+
else
54+
{
55+
// Don't upgrade dependencies.
56+
//
57+
// But download & resolve deps now so intermittent failures are more likely
58+
// to be correctly marked as "job error" rather than "tests failed".
59+
spawnShell("dub upgrade --missing-only").wait;
60+
chdir("examples/homePage");
61+
spawnShell("dub upgrade --missing-only").wait;
62+
chdir("../..");
63+
}
64+
65+
// Setup DB
66+
spawnShell(`mysql -u root -e 'SHOW VARIABLES LIKE "%version%";'`).wait;
67+
spawnShell(`mysql -u root -e 'CREATE DATABASE mysqln_testdb;'`).wait;
68+
write("testConnectionStr.txt", "host=127.0.0.1;port=3306;user=root;pwd=;db=mysqln_testdb");
69+
}

travis-setup.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)