Skip to content

Commit 732f7e2

Browse files
Merge pull request #5834 from dotty-staging/community-build
Fix #5809: Run the community-build on every PR
2 parents 8726cf7 + 5967bff commit 732f7e2

29 files changed

+275
-47
lines changed

.drone.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,31 @@ pipeline:
2323
# We run tests in parallel. Tests run in a copy of the working directory to avoid conflict
2424
test:
2525
group: test
26-
image: lampepfl/dotty:2018-12-12
26+
image: lampepfl/dotty:2019-02-06
2727
commands:
2828
- cp -R . /tmp/1/ && cd /tmp/1/
2929
- ./project/scripts/sbt ";compile ;test"
3030
- ./project/scripts/cmdTests
3131

3232
test_bootstrapped:
3333
group: test
34-
image: lampepfl/dotty:2018-12-12
34+
image: lampepfl/dotty:2019-02-06
3535
commands:
3636
- cp -R . /tmp/2/ && cd /tmp/2/
3737
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test ;sjsSandbox/run"
3838
- ./project/scripts/bootstrapCmdTests
3939

40+
community_build:
41+
group: test
42+
image: lampepfl/dotty:2019-02-06
43+
commands:
44+
- cp -R . /tmp/3/ && cd /tmp/3/
45+
- export PATH=/tmp/4/project/scripts:$PATH
46+
- sbt community-build/test
47+
4048
test_sbt:
4149
group: test
42-
image: lampepfl/dotty:2018-12-12
50+
image: lampepfl/dotty:2019-02-06
4351
commands:
4452
- cp -R . /tmp/4/ && cd /tmp/4/
4553
- ./project/scripts/sbt sbt-dotty/scripted
@@ -49,7 +57,7 @@ pipeline:
4957

5058
# DOCUMENTATION:
5159
documentation:
52-
image: lampepfl/dotty:2018-12-12
60+
image: lampepfl/dotty:2019-02-06
5361
commands:
5462
- ./project/scripts/genDocs
5563
secrets: [ bot_token ]
@@ -61,7 +69,7 @@ pipeline:
6169
# PUBLISHING:
6270
# Publishing expect NIGHTLYBUILD or RELEASEBUILD to be set. See dottyVersion in Build.scala
6371
publish_nightly:
64-
image: lampepfl/dotty:2018-12-12
72+
image: lampepfl/dotty:2019-02-06
6573
environment:
6674
- NIGHTLYBUILD=yes
6775
commands:
@@ -72,7 +80,7 @@ pipeline:
7280
environment: nightly
7381

7482
publish_release:
75-
image: lampepfl/dotty:2018-12-12
83+
image: lampepfl/dotty:2019-02-06
7684
environment:
7785
- RELEASEBUILD=yes
7886
commands:
@@ -96,7 +104,7 @@ pipeline:
96104
event: tag
97105

98106
publish_sbt_release:
99-
image: lampepfl/dotty:2018-12-12
107+
image: lampepfl/dotty:2019-02-06
100108
environment:
101109
- RELEASEBUILD=yes
102110
commands:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ bench/compile.txt
7979

8080
# The vscode app for testing
8181
vscode-dotty/.vscode-test
82+
dotty-bootstrapped.version
83+
sbt-dotty.sbt

.gitmodules

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,42 @@
66
path = scala2-library
77
url = https://github.com/lampepfl/scala.git
88
branch = dotty-library2.12
9-
[submodule "collection-strawman"]
10-
path = collection-strawman
11-
url = https://github.com/dotty-staging/collection-strawman.git
12-
branch = dotty
9+
[submodule "community-build/community-projects/algebra"]
10+
path = community-build/community-projects/algebra
11+
url = https://github.com/dotty-staging/algebra
12+
[submodule "community-build/community-projects/betterfiles"]
13+
path = community-build/community-projects/betterfiles
14+
url = https://github.com/dotty-staging/better-files
15+
[submodule "community-build/community-projects/scalacheck"]
16+
path = community-build/community-projects/scalacheck
17+
url = https://github.com/dotty-staging/scalacheck
18+
[submodule "community-build/community-projects/ScalaPB"]
19+
path = community-build/community-projects/ScalaPB
20+
url = https://github.com/dotty-staging/ScalaPB
21+
[submodule "community-build/community-projects/scalatest"]
22+
path = community-build/community-projects/scalatest
23+
url = https://github.com/dotty-staging/scalatest
24+
[submodule "community-build/community-projects/scopt"]
25+
path = community-build/community-projects/scopt
26+
url = https://github.com/dotty-staging/scopt
27+
[submodule "community-build/community-projects/squants"]
28+
path = community-build/community-projects/squants
29+
url = https://github.com/dotty-staging/squants
30+
[submodule "community-build/community-projects/scalap"]
31+
path = community-build/community-projects/scalap
32+
url = https://github.com/dotty-staging/scala
33+
[submodule "community-build/community-projects/minitest"]
34+
path = community-build/community-projects/minitest
35+
url = https://github.com/dotty-staging/minitest
36+
[submodule "community-build/community-projects/fastparse"]
37+
path = community-build/community-projects/fastparse
38+
url = https://github.com/dotty-staging/fastparse
39+
[submodule "community-build/community-projects/stdLib213"]
40+
path = community-build/community-projects/stdLib213
41+
url = https://github.com/dotty-staging/scala
42+
[submodule "community-build/community-projects/pdbp"]
43+
path = community-build/community-projects/pdbp
44+
url = https://github.com/dotty-staging/pdbp
45+
[submodule "community-build/community-projects/sourcecode"]
46+
path = community-build/community-projects/sourcecode
47+
url = https://github.com/dotty-staging/sourcecode

.vscode-template/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"**/*.class": true,
1010
"**/*.hasTasty": true,
1111
"**/target/": true,
12+
"community-build/community-projects": true,
1213
"scala2-library/{doc,docs,lib,META-INF,scripts,spec,test,tools}/": true, // only allow scala-backend/src
1314
"scala2-library/src/[abcefimprs]*": true, // only allow scala-backend/src/library
1415
"scala-backend/{doc,docs,lib,META-INF,scripts,spec,test,tools}/": true, // only allow scala-backend/src

bench/scripts/collection-strawman-cold.sh

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

bench/scripts/collection-strawman.sh

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

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ val `scala-reflect` = Build.`scala-reflect`
1919
val scalap = Build.scalap
2020
val dist = Build.dist
2121
val `dist-bootstrapped` = Build.`dist-bootstrapped`
22+
val `community-build` = Build.`community-build`
2223

2324
val sjsSandbox = Build.sjsSandbox
2425

collection-strawman

Lines changed: 0 additions & 1 deletion
This file was deleted.
Submodule ScalaPB added at 7b2d8ac
Submodule algebra added at 812caf0
Submodule betterfiles added at 9f14d47
Submodule fastparse added at 2a72cbe
Submodule minitest added at d2b8b63
Submodule pdbp added at 0c1fe0a
Submodule scalacheck added at 6b3fe51
Submodule scalap added at b66556a
Submodule scalatest added at cfc4026
Submodule scopt added at fedd604
Submodule sourcecode added at bed617b
Submodule squants added at 9cccea9
Submodule stdLib213 added at 655bca8
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.13.0-bin-SNAPSHOT
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.2.7

community-build/sbt-dotty.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.7-SNAPSHOT")
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
package dotty.communitybuild
2+
3+
import java.nio.file._
4+
import java.io.{PrintWriter, File}
5+
import java.nio.charset.StandardCharsets.UTF_8
6+
import org.junit.{Ignore, Test}
7+
import org.junit.Assert.{assertEquals, fail}
8+
9+
class CommunityBuildTest {
10+
lazy val communitybuildDir: Path = Paths.get(sys.props("user.dir") + "/community-build/")
11+
12+
lazy val compilerVersion: String = {
13+
val file = communitybuildDir.resolve("dotty-bootstrapped.version")
14+
new String(Files.readAllBytes(file), UTF_8)
15+
}
16+
17+
/** Build the given project with the published local compiler and sbt plugin.
18+
*
19+
* This test reads the compiler version from community-build/dotty-bootstrapped.version
20+
* and expects community-build/sbt-dotty.sbt to set the compiler plugin.
21+
*
22+
* @param project The project name, should be a git submodule in community-build/
23+
* @param command The sbt command used to build the project
24+
*/
25+
def test(project: String, command: String): Unit = {
26+
def log(msg: String) = println(Console.GREEN + msg + Console.RESET)
27+
28+
log(s"Building $project with dotty-bootstrapped $compilerVersion...")
29+
30+
val projectDir = communitybuildDir.resolve("community-projects").resolve(project)
31+
32+
if (!Files.exists(projectDir.resolve(".git"))) {
33+
fail(s"""
34+
|
35+
|Missing $project submodule. You can initialize this module using
36+
|
37+
| git submodule update --init community-build/community-projects/$project
38+
|
39+
|""".stripMargin)
40+
}
41+
42+
/** Executes shell command, returns false in case of error. */
43+
def exec(binary: String, arguments: String*): Int = {
44+
val command = binary +: arguments
45+
log(command.mkString(" "))
46+
val builder = new ProcessBuilder(command: _*).directory(projectDir.toFile).inheritIO()
47+
val process = builder.start()
48+
val exitCode = process.waitFor()
49+
exitCode
50+
}
51+
52+
// Workaround for https://github.com/sbt/sbt/issues/4395
53+
new File(sys.props("user.home") + "/.sbt/1.0/plugins").mkdirs()
54+
val pluginFilePath = communitybuildDir.resolve("sbt-dotty.sbt").toAbsolutePath().toString()
55+
56+
// Run the sbt command with the compiler version and sbt plugin set in the build
57+
val arguments = Seq(
58+
"-sbt-version", "1.2.7",
59+
s"--addPluginSbtFile=$pluginFilePath",
60+
s";clean ;set updateOptions in Global ~= (_.withLatestSnapshots(false)) ;++$compilerVersion! $command"
61+
)
62+
63+
val exitCode = exec("sbt", arguments: _*)
64+
65+
if (exitCode != 0) {
66+
fail(s"""
67+
|
68+
|sbt exited with an error code. To reproduce without JUnit, use:
69+
|
70+
| sbt community-build/prepareCommunityBuild
71+
| cd community-build/community-projects/$project
72+
| sbt ${arguments.init.mkString(" ")} "${arguments.last}"
73+
|
74+
|For a faster feedback loop, one can try to extract a direct call to dotc from
75+
|usign the sbt export command. For instance, for scalacheck, use
76+
| sbt export jvm/test:compileIncremental
77+
|
78+
|""".stripMargin)
79+
}
80+
}
81+
82+
@Test def algebra = test(
83+
project = "algebra",
84+
command = "coreJVM/compile"
85+
)
86+
87+
@Test def scalacheck = test(
88+
project = "scalacheck",
89+
command = "jvm/test:compile"
90+
)
91+
92+
@Test def scalatest = test(
93+
project = "scalatest",
94+
command = "scalatest/compile"
95+
)
96+
97+
@Test def scopt = test(
98+
project = "scopt",
99+
command = "scoptJVM/compile"
100+
)
101+
102+
@Test def scalap = test(
103+
project = "scalap",
104+
command = "scalap/compile"
105+
)
106+
107+
@Test def squants = test(
108+
project = "squants",
109+
command = "squantsJVM/compile"
110+
)
111+
112+
@Test def betterfiles = test(
113+
project = "betterfiles",
114+
command = "dottyCompile"
115+
)
116+
117+
@Test def ScalaPB = test(
118+
project = "ScalaPB",
119+
command = "dottyCompile"
120+
)
121+
122+
@Test def minitest = test(
123+
project = "minitest",
124+
command = "dottyCompile"
125+
)
126+
127+
@Test def fastparse = test(
128+
project = "fastparse",
129+
command = "fastparseJVM/compile"
130+
)
131+
132+
// TODO: revert to sourcecodeJVM/test
133+
@Test def sourcecode = test(
134+
project = "sourcecode",
135+
command = "sourcecodeJVM/compile"
136+
)
137+
138+
// TODO @smarter?
139+
// @Test def stdLib213 = test(
140+
// project = "stdLib213",
141+
// command = "library/compile"
142+
// )
143+
144+
// TODO @oderky? It got broken by #5458
145+
// @Test def pdbp = test(
146+
// project = "pdbp",
147+
// command = "compile"
148+
// )
149+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Dotty Community Build
2+
3+
This project contains tests to build and test a corpus of open sources Scala projects against the latest version of Dotty.
4+
5+
To run the community build on a local machine, first fetch all the git submodules with `git submodule update --init` and run `sbt community-build/test` from the root of the dotty repo.
6+
7+
## Adding your project
8+
9+
To add your project to the community build you can follow these steps:
10+
11+
1. Get your project to compile with Dotty. Instructions can be found on the [dotty-example-project](https://github.com/lampepfl/dotty-example-project).
12+
See the submodules in [community-projects](https://github.com/lampepfl/dotty/tree/master/community-build/community-projects/) for examples of projects that compile with Dotty.
13+
14+
2. Open a PR against this repo that:
15+
- Adds your project as a new git submodule
16+
- Adds a test in [CommunityBuildTest.scala](https://github.com/lampepfl/dotty/blob/master/src/test/scala/dotty/community-build/src/test/scala/dotty/communitybuild/CommunityBuildTest.scala)

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class CompilationTests extends ParallelTesting {
6363
),
6464
scala2Mode
6565
) +
66-
compileDir("collection-strawman/collections/src/main", defaultOptions.and("-Yno-imports")) +
6766
compileFilesInDir("tests/pos-special/spec-t5545", defaultOptions) +
6867
compileFilesInDir("tests/pos-special/strawman-collections", defaultOptions) +
6968
compileFilesInDir("tests/pos-special/isInstanceOf", allowDeepSubtypes.and("-Xfatal-warnings")) +

compiler/test/dotty/tools/dotc/IdempotencyTests.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ class IdempotencyTests extends ParallelTesting {
3232

3333
def sourcesFrom(dir: Path) = CompilationTests.sources(Files.walk(dir))
3434

35-
val strawmanSources = sourcesFrom(Paths.get("collection-strawman/collections/src/main"))
36-
val strawmanSourcesSorted = strawmanSources.sorted
37-
val strawmanSourcesRevSorted = strawmanSourcesSorted.reverse
3835

3936
val posIdempotency = {
4037
compileFilesInDir("tests/pos", opt)(TestGroup("idempotency/posIdempotency1")) +
@@ -51,13 +48,6 @@ class IdempotencyTests extends ParallelTesting {
5148
}).reduce(_ + _)
5249
}
5350

54-
val strawmanIdempotency = {
55-
compileList("strawman0", strawmanSources, opt) +
56-
compileList("strawman1", strawmanSources, opt) +
57-
compileList("strawman2", strawmanSourcesSorted, opt) +
58-
compileList("strawman3", strawmanSourcesRevSorted, opt)
59-
}
60-
6151
def check(name: String) = {
6252
val files = List(s"tests/idempotency/$name.scala", "tests/idempotency/IdempotencyCheck.scala")
6353
compileList(name, files, defaultOptions)(TestGroup("idempotency/check"))
@@ -70,8 +60,6 @@ class IdempotencyTests extends ParallelTesting {
7060
}
7161

7262
val allTests = {
73-
// Disabled until strawman is fixed
74-
// strawmanIdempotency +
7563
orderIdempotency +
7664
posIdempotency
7765
}

0 commit comments

Comments
 (0)