Skip to content

Commit c79b3ac

Browse files
authored
Merge pull request #49 from codacy/newCI
Publishing from CI and new SBT plugin
2 parents e546749 + 36b92b6 commit c79b3ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+597
-313
lines changed

.circleci/config.yml

Lines changed: 97 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,6 @@ references:
1818
- image: codacy/ci-aws:3.0.2
1919
working_directory: ~/workdir/.aws
2020

21-
setup_aws_credentials: &setup_aws_credentials
22-
run:
23-
name: Setup AWS Credentials
24-
command: |
25-
mkdir -p ~/.aws && touch ~/.aws/credentials
26-
cat >> ~/.aws/credentials << EOF
27-
[default]
28-
aws_access_key_id=$ACCESS_KEY_ID
29-
aws_secret_access_key=$SECRET_ACCESS_KEY
30-
[integration]
31-
source_profile = default
32-
role_arn = arn:aws:iam::$AWS_ACCOUNT_ID_INTEGRATION:role/$CONTINUOUS_DELIVERY_ROLE
33-
region=eu-west-1
34-
3521
restore_sbt_cache: &restore_sbt_cache
3622
restore_cache:
3723
keys:
@@ -56,21 +42,112 @@ references:
5642
- "~/.m2"
5743

5844
jobs:
59-
test:
45+
checkout_and_version:
46+
docker:
47+
- image: codacy/git-version:latest
48+
working_directory: ~/workdir
49+
steps:
50+
- checkout
51+
- run:
52+
name: Set version
53+
command: /bin/git-version > .version
54+
- run:
55+
name: Set Sbt version
56+
command: echo "version in ThisBuild := \"$(cat .version)\"" > version.sbt
57+
- run:
58+
name: Current version
59+
command: cat .version
60+
- persist_to_workspace:
61+
root: ~/
62+
paths:
63+
- workdir/*
64+
65+
checkfmt:
66+
<<: *default_sbt_job
67+
steps:
68+
- attach_workspace:
69+
at: ~/
70+
- *restore_sbt_cache
71+
- run:
72+
name: Check formatting
73+
command: sbt ";scalafmt::test;test:scalafmt::test;sbt:scalafmt::test"
74+
- *clean_sbt_cache
75+
- *save_sbt_cache
76+
77+
populate_cache:
78+
<<: *default_sbt_job
79+
steps:
80+
- attach_workspace:
81+
at: ~/
82+
- *restore_sbt_cache
83+
- run:
84+
name: Safely populate caches
85+
command: sbt ";set scalafmtUseIvy in ThisBuild := false;update"
86+
- *clean_sbt_cache
87+
- *save_sbt_cache
88+
89+
compile_and_test:
6090
<<: *default_sbt_job
6191
steps:
6292
- attach_workspace:
6393
at: ~/
6494
- *restore_sbt_cache
6595
- run:
66-
name: Test
67-
command: |
68-
sbt +test
96+
name: Compile / Test and send coverage results
97+
command: sbt ";compile;test:compile;coverage;test;coverageReport;coverageAggregate;codacyCoverage"
98+
- *clean_sbt_cache
99+
- *save_sbt_cache
100+
101+
tag_version:
102+
<<: *default_sbt_job
103+
steps:
104+
- attach_workspace:
105+
at: ~/
106+
- add_ssh_keys:
107+
fingerprints:
108+
- "df:83:d7:c7:d5:79:06:c2:3b:d1:fd:e2:a3:d1:12:c5"
109+
- run:
110+
name: Tag
111+
command: git tag $(cat .version) && git push --tags
112+
113+
publish:
114+
<<: *default_sbt_job
115+
steps:
116+
- attach_workspace:
117+
at: ~/
118+
- *restore_sbt_cache
119+
- run:
120+
name: Publish to sonatype
121+
command: sbt ";clean;retrieveGPGKeys;+publishSigned;sonatypeReleaseAll"
69122

70123
workflows:
71124
version: 2
72125
compile_deploy:
73126
jobs:
74-
- test:
127+
- checkout_and_version
128+
- populate_cache:
129+
requires:
130+
- checkout_and_version
131+
- checkfmt:
132+
requires:
133+
- populate_cache
134+
- compile_and_test:
135+
requires:
136+
- populate_cache
137+
- publish:
138+
filters:
139+
branches:
140+
only:
141+
- master
142+
context: CodacyAWS
143+
requires:
144+
- compile_and_test
145+
- checkfmt
146+
- tag_version:
147+
filters:
148+
branches:
149+
only:
150+
- master
75151
context: CodacyAWS
76-
requires:
152+
requires:
153+
- publish

.scalafmt.conf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version = "1.5.1"
2+
style = IntelliJ
3+
4+
align = none
5+
assumeStandardLibraryStripMargin = false
6+
binPack.literalArgumentLists = true
7+
binPack.parentConstructors = false
8+
continuationIndent.defnSite = 4
9+
danglingParentheses = true
10+
docstrings = ScalaDoc
11+
includeCurlyBraceInSelectChains = true
12+
lineEndings = unix
13+
maxColumn = 120
14+
newlines.alwaysBeforeTopLevelStatements = true
15+
newlines.penalizeSingleSelectMultiArgList = false
16+
newlines.sometimesBeforeColonInMethodReturnType = true
17+
optIn.breakChainOnFirstMethodDot = true
18+
project.git = true
19+
# rewrite.rules = [ AvoidInfix, SortImports, PreferCurlyFors ]
20+
# https://github.com/scalameta/scalafmt/issues/932 removing AvoidInfix
21+
rewrite.rules = [ SortImports, PreferCurlyFors ]
22+
spaces.afterKeywordBeforeParen = true
23+
24+
project.includeFilters = [".*\\.sbt$", ".*\\.scala$"]
25+
project.excludeFilters = [".*\\.scala.html$", "target/.*", "modules/admin/target/.*"]
26+
onTestFailure = "To fix this, run `scalafmt` within sbt or `sbt scalafmt` on the project base directory"

build.sbt

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,57 @@
1-
import Dependencies._
1+
import codacy.libs._
22

33
import scala.io.Source
44
import scala.util.parsing.json.JSON
55

66
name := """bitbucket-scala-client"""
77

8-
version := "1.9.0-SNAPSHOT"
9-
108
scalaVersion := "2.11.12"
119

1210
scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-Ywarn-adapted-args", "-Xlint")
1311

1412
resolvers += "Typesafe maven repository" at "http://repo.typesafe.com/typesafe/maven-releases/"
1513

16-
libraryDependencies ++= Seq(
17-
Dependencies.playWS,
18-
Dependencies.playJson,
19-
Dependencies.scalaTest
20-
)
14+
libraryDependencies ++= Seq(playWs, playJson, scalatest % Test)
2115

2216
mimaPreviousArtifacts := {
23-
val latestVersion = JSON.parseFull(
24-
Source.fromURL("https://api.github.com/repos/codacy/bitbucket-scala-client/releases/latest").mkString
25-
).flatMap(_.asInstanceOf[Map[String, String]].get("tag_name")).getOrElse("5.0.0")
17+
val latestVersion = JSON
18+
.parseFull(
19+
Source
20+
.fromURL("https://api.github.com/repos/codacy/bitbucket-scala-client/releases/latest")
21+
.mkString
22+
)
23+
.flatMap(_.asInstanceOf[Map[String, String]].get("tag_name"))
24+
.getOrElse("5.0.0")
2625
Set("com.codacy" %% "bitbucket-scala-client" % latestVersion)
2726
}
2827
mimaBinaryIssueFilters ++= ignoredABIProblems
28+
2929
val ignoredABIProblems = {
3030
import com.typesafe.tools.mima.core._
3131
import com.typesafe.tools.mima.core.ProblemFilters._
3232
Seq()
3333
}
3434

35-
organization := "com.codacy"
36-
3735
organizationName := "Codacy"
3836

3937
organizationHomepage := Some(new URL("https://www.codacy.com"))
4038

41-
publishMavenStyle := true
42-
43-
publishArtifact in Test := false
44-
45-
pomIncludeRepository := { _ => false }
46-
47-
publishTo := sonatypePublishTo.value
48-
49-
//Credentials for sonatype
50-
credentials += Credentials(
51-
"Sonatype Nexus Repository Manager",
52-
"oss.sonatype.org",
53-
sys.env.getOrElse("SONATYPE_USER", "username"),
54-
sys.env.getOrElse("SONATYPE_PASSWORD", "password"))
55-
5639
startYear := Some(2014)
5740

5841
description := "Bitbucket Scala Client"
5942

60-
licenses := Seq("The Apache Software License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
61-
6243
homepage := Some(url("https://github.com/codacy/bitbucket-scala-client.git"))
6344

64-
pomExtra :=
65-
<scm>
66-
<url>https://github.com/codacy/bitbucket-scala-client.git</url>
67-
<connection>scm:git:git@github.com:codacy/bitbucket-scala-client.git</connection>
68-
<developerConnection>scm:git:https://github.com/codacy/bitbucket-scala-client.git</developerConnection>
69-
</scm>
70-
<developers>
71-
<developer>
72-
<id>rtfpessoa</id>
73-
<name>Rodrigo</name>
74-
<email>rodrigo [at] codacy.com</email>
75-
<url>https://github.com/rtfpessoa</url>
76-
</developer>
77-
</developers>
45+
scmInfo := Some(
46+
ScmInfo(
47+
url("https://github.com/codacy/bitbucket-scala-client.git"),
48+
"scm:git:[email protected]:codacy/bitbucket-scala-client.git"
49+
)
50+
)
51+
52+
pgpPassphrase := Option(System.getenv("SONATYPE_GPG_PASSPHRASE"))
53+
.map(_.toCharArray)
54+
55+
resolvers ~= { _.filterNot(_.name.toLowerCase.contains("codacy")) }
56+
57+
publicMvnPublish

project/Dependencies.scala

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

project/plugins.sbt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import sbt._
1+
resolvers += Resolver.jcenterRepo
22

3-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
3+
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.2.0")
44

5-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
5+
// Temporary until maven central sync, to be removed
6+
resolvers += Resolver.sonatypeRepo("releases")
67

7-
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.2.0")
8+
addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "13.0.3")

src/main/scala/com/codacy/client/bitbucket/client/Authentication.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ object Authentication {
2222
*/
2323
case class BasicAuthCredentials(username: String, password: String) extends Credentials
2424

25-
2625
sealed trait Authenticator {
2726
def authenticate(req: WSRequest): WSRequest
2827
}
2928

3029
object Authenticator {
31-
def fromCredentials(credentials: Credentials): Authenticator = {
30+
31+
def fromCredentials(credentials: Credentials): Authenticator = {
3232
credentials match {
33-
case c: OAuthCredentials => new OAuthAuthenticator(c)
34-
case c: OAuth2Credentials => new OAuth2Authenticator(c)
33+
case c: OAuthCredentials => new OAuthAuthenticator(c)
34+
case c: OAuth2Credentials => new OAuth2Authenticator(c)
3535
case c: BasicAuthCredentials => new BasicAuthAuthenticator(c)
3636
}
3737
}
@@ -47,11 +47,14 @@ object Authentication {
4747
}
4848

4949
class OAuth2Authenticator(credentials: OAuth2Credentials) extends Authenticator {
50-
override def authenticate(req: WSRequest): WSRequest = req.withQueryString("access_token" -> credentials.accessToken)
50+
override def authenticate(req: WSRequest): WSRequest =
51+
req.withQueryString("access_token" -> credentials.accessToken)
5152
}
5253

5354
class BasicAuthAuthenticator(credentials: BasicAuthCredentials) extends Authenticator {
54-
def authenticate(req: WSRequest): WSRequest = req.withAuth(credentials.username, credentials.password, WSAuthScheme.BASIC)
55+
56+
def authenticate(req: WSRequest): WSRequest =
57+
req.withAuth(credentials.username, credentials.password, WSAuthScheme.BASIC)
5558
}
5659

5760
/**

0 commit comments

Comments
 (0)