Skip to content

Commit f30601c

Browse files
authored
Merge pull request #21 from 2m/wip-update-scalafmt-2m
Latest scalafmt and travis stages
2 parents e6d00d1 + cd8a674 commit f30601c

8 files changed

Lines changed: 107 additions & 69 deletions

File tree

.scalafmt.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version = 2.0.0-RC6
2+
13
style = defaultWithAlign
24

35
align.tokens = ["%", "%%"]

.travis.yml

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
11
language: scala
2-
3-
scala:
4-
- "2.12.4"
5-
6-
jdk:
7-
- oraclejdk8
8-
9-
before_script:
10-
# start X for the clipboard access in tests
11-
- "export DISPLAY=:99.0"
12-
- "sh -e /etc/init.d/xvfb start"
13-
- sleep 3 # give xvfb some time to start
14-
15-
script: sbt test scripted
16-
17-
deploy:
18-
provider: script
19-
script:
20-
- sbt core/publish core/bintraySyncMavenCentral plugin/publish
21-
on:
22-
tags: true
23-
repo: 2m/authors
2+
jdk: oraclejdk8
3+
4+
jobs:
5+
include:
6+
- stage: check
7+
script: sbt scalafmtCheck || { echo "[error] Unformatted code found. Please run 'Test/compile' and commit the reformatted code."; false; }
8+
name: "Code style check (fixed with `sbt Test/compile`)"
9+
- script: sbt scalafmtSbtCheck || { echo "[error] Unformatted sbt code found. Please run 'scalafmtSbt' and commit the reformatted code."; false; }
10+
name: "Build code style check (fixed with `sbt scalafmtSbt`)"
11+
12+
- stage: test
13+
script: sbt test
14+
name: Run all unit tests
15+
- before_script:
16+
# start X for the clipboard access in tests
17+
- "export DISPLAY=:99.0"
18+
- "sh -e /etc/init.d/xvfb start"
19+
- sleep 3 # give xvfb some time to start
20+
script: sbt scripted
21+
name: Run all sbt scripted tests
22+
23+
- stage: publish
24+
script: sbt core/publish core/bintraySyncMavenCentral plugin/publish
25+
name: Publish artifacts
26+
27+
stages:
28+
# runs on master commits and PRs
29+
- name: check
30+
if: NOT tag =~ ^v
31+
32+
# runs on master commits and PRs
33+
- name: test
34+
if: NOT tag =~ ^v
35+
36+
# runs on main repo master commits or version-tagged commits
37+
- name: publish
38+
if: repo = 2m/authors AND ( ( branch = master AND type = push ) OR tag =~ ^v )
2439

2540
before_cache:
2641
- find $HOME/.ivy2 -name "ivydata-*.properties" -print -delete
@@ -30,6 +45,7 @@ cache:
3045
directories:
3146
- $HOME/.ivy2/cache
3247
- $HOME/.sbt/boot
48+
- $HOME/.sbt/launchers
3349

3450
env:
3551
global:

build.sbt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ lazy val authors = project
55
lazy val core = project
66
.settings(
77
name := "authors-core",
8+
// stick to 2.12.4 until 2.12.9 comes out with the following fixed:
9+
// https://github.com/scala/bug/issues/11373
10+
scalaVersion := "2.12.4",
811
resolvers += Resolver.bintrayRepo("jypma", "maven"), {
912
val Akka = "2.5.22"
1013
val AkkaHttp = "10.1.8"
@@ -13,9 +16,9 @@ lazy val core = project
1316
"com.typesafe.akka" %% "akka-stream" % Akka,
1417
"com.typesafe.akka" %% "akka-slf4j" % Akka,
1518
"com.typesafe.akka" %% "akka-http" % AkkaHttp,
16-
"com.tradeshift" %% "ts-reaktive-marshal-akka" % "0.11.0" exclude("org.slf4j", "slf4j-log4j12"),
19+
"com.tradeshift" %% "ts-reaktive-marshal-akka" % "0.11.0" exclude ("org.slf4j", "slf4j-log4j12"),
1720
"com.madgag.scala-git" %% "scala-git" % "4.0",
18-
"ch.qos.logback" % "logback-classic" % "1.2.3",
21+
"ch.qos.logback" % "logback-classic" % "1.2.3",
1922
"org.scalatest" %% "scalatest" % "3.0.7" % "test",
2023
"com.typesafe.akka" %% "akka-testkit" % Akka % "test"
2124
)
@@ -41,10 +44,12 @@ inThisBuild(
4144
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0")),
4245
homepage := Some(url("https://github.com/2m/authors")),
4346
scmInfo := Some(ScmInfo(url("https://github.com/2m/authors"), "git@github.com:2m/authors.git")),
44-
developers += Developer("contributors",
45-
"Contributors",
46-
"https://gitter.im/2m/authors",
47-
url("https://github.com/2m/authors/graphs/contributors")),
47+
developers += Developer(
48+
"contributors",
49+
"Contributors",
50+
"https://gitter.im/2m/authors",
51+
url("https://github.com/2m/authors/graphs/contributors")
52+
),
4853
bintrayOrganization := Some("2m"),
4954
scalafmtOnCompile := true,
5055
// show full stack traces and test case durations

core/src/main/scala/Authors.scala

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ object Authors {
9292
}
9393

9494
object DiffSource {
95-
def apply(repo: String, from: String, to: String)(implicit ec: ExecutionContext,
96-
sys: ActorSystem): Source[ByteString, NotUsed] =
95+
def apply(repo: String, from: String, to: String)(
96+
implicit ec: ExecutionContext,
97+
sys: ActorSystem
98+
): Source[ByteString, NotUsed] =
9799
Source
98100
.fromFuture(
99101
Marshal(Uri(s"/repos/$repo/compare/$from...$to"))
@@ -121,10 +123,12 @@ object StatsAggregator {
121123
.reduce(
122124
(aggr, elem) =>
123125
aggr.copy(
124-
stats = Stats(additions = aggr.stats.additions + elem.stats.additions,
125-
deletions = aggr.stats.deletions + elem.stats.deletions,
126-
aggr.stats.commits + elem.stats.commits)
127-
)
126+
stats = Stats(
127+
additions = aggr.stats.additions + elem.stats.additions,
128+
deletions = aggr.stats.deletions + elem.stats.deletions,
129+
aggr.stats.commits + elem.stats.commits
130+
)
131+
)
128132
)
129133
.mergeSubstreams
130134
}
@@ -134,12 +138,12 @@ object MarkdownConverter {
134138
Flow[AuthorStats]
135139
.map { author =>
136140
val authorId = author.githubAuthor.map { gh =>
137-
// using html instead of markdown, because default
138-
// avatars come from github not resized
139-
s"""[<img width="20" alt="${gh.login}" src="${gh.avatar}&amp;s=40"/> **${gh.login}**](${gh.url})"""
140-
} getOrElse {
141-
author.gitAuthor.name
142-
}
141+
// using html instead of markdown, because default
142+
// avatars come from github not resized
143+
s"""[<img width="20" alt="${gh.login}" src="${gh.avatar}&amp;s=40"/> **${gh.login}**](${gh.url})"""
144+
} getOrElse {
145+
author.gitAuthor.name
146+
}
143147

144148
s"| $authorId | ${author.stats.commits} | ${author.stats.additions} | ${author.stats.deletions} |"
145149
}

core/src/main/scala/GithubProtocol.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ object GithubProtocol {
2525
option(
2626
field("author", githubAuthorProto)
2727
),
28-
field("commit",
29-
`object`(
30-
field("author", gitAuthorProto),
31-
field("message", stringValue),
32-
(gitAuthor: GitAuthor, message: String) => (gitAuthor, message)
33-
)),
28+
field(
29+
"commit",
30+
`object`(
31+
field("author", gitAuthorProto),
32+
field("message", stringValue),
33+
(gitAuthor: GitAuthor, message: String) => (gitAuthor, message)
34+
)
35+
),
3436
field("sha", stringValue),
3537
(githubAuthor: VavrOption[GithubAuthor], gitAuthorAndMessage: (GitAuthor, String), sha: String) =>
3638
Commit(sha, gitAuthorAndMessage._2, gitAuthorAndMessage._1, githubAuthor)

core/src/test/scala/AuthorsSpec.scala

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@ class AuthorsSpec
5353
implicit val repo = Authors.gitRepo(".git/modules/core/src/test/resources/authors-test-repo")
5454
val stats = Source(
5555
List(
56-
Commit("f576a45",
57-
"message",
58-
GitAuthor("test", "test@test.lt"),
59-
Some(GithubAuthor("test", "http://users/test", "http://avatars/test"))),
60-
Commit("bce0e63",
61-
"message",
62-
GitAuthor("test", "test@test.lt"),
63-
Some(GithubAuthor("test", "http://users/test", "http://avatars/test")))
56+
Commit(
57+
"f576a45",
58+
"message",
59+
GitAuthor("test", "test@test.lt"),
60+
Some(GithubAuthor("test", "http://users/test", "http://avatars/test"))
61+
),
62+
Commit(
63+
"bce0e63",
64+
"message",
65+
GitAuthor("test", "test@test.lt"),
66+
Some(GithubAuthor("test", "http://users/test", "http://avatars/test"))
67+
)
6468
)
6569
).via(StatsAggregator())
6670
.runWith(Sink.head)
@@ -76,14 +80,18 @@ class AuthorsSpec
7680
implicit val repo = Authors.gitRepo(".git/modules/core/src/test/resources/authors-test-repo")
7781
val stats = Source(
7882
List(
79-
Commit("f576a45",
80-
"message",
81-
GitAuthor("test", "test1@test.lt"),
82-
Some(GithubAuthor("test", "http://users/test", "http://avatars/test"))),
83-
Commit("bce0e63",
84-
"message",
85-
GitAuthor("test", "test2@test.lt"),
86-
Some(GithubAuthor("test", "http://users/test", "http://avatars/test")))
83+
Commit(
84+
"f576a45",
85+
"message",
86+
GitAuthor("test", "test1@test.lt"),
87+
Some(GithubAuthor("test", "http://users/test", "http://avatars/test"))
88+
),
89+
Commit(
90+
"bce0e63",
91+
"message",
92+
GitAuthor("test", "test2@test.lt"),
93+
Some(GithubAuthor("test", "http://users/test", "http://avatars/test"))
94+
)
8795
)
8896
).via(StatsAggregator())
8997
.runWith(Sink.head)
@@ -99,10 +107,12 @@ class AuthorsSpec
99107
implicit val repo = Authors.gitRepo(".git/modules/core/src/test/resources/authors-test-repo")
100108
val stats = Source(
101109
List(
102-
Commit("901392a",
103-
"message",
104-
GitAuthor("test", "test1@test.lt"),
105-
Some(GithubAuthor("test", "http://users/test", "http://avatars/test")))
110+
Commit(
111+
"901392a",
112+
"message",
113+
GitAuthor("test", "test1@test.lt"),
114+
Some(GithubAuthor("test", "http://users/test", "http://avatars/test"))
115+
)
106116
)
107117
).via(StatsAggregator())
108118
.runWith(Sink.head)

plugin/src/main/scala/AuthorsPlugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ object AuthorsPlugin extends AutoPlugin {
4646

4747
Await.result(summary, 30.seconds)
4848
},
49-
aggregate in authors := false,
49+
aggregate in authors := false
5050
)
5151
}

project/plugins.sbt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "3.3.0")
2-
addSbtPlugin("com.dwijnand" % "sbt-travisci" % "1.2.0")
3-
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.4.0")
2+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0")
43
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")
54
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.6")

0 commit comments

Comments
 (0)