Skip to content
This repository was archived by the owner on Mar 11, 2019. It is now read-only.

Commit 97d4b75

Browse files
committed
core(travis): upload automatically each new release into the public sonatype repository and update the changelog
1 parent ddd8b50 commit 97d4b75

File tree

24 files changed

+210
-139
lines changed

24 files changed

+210
-139
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ target/
3636
#bluecove
3737
*bluecove*
3838

39+
secrets.tar

.travis.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ env:
1010
- secure: "MLFJWju96LymkPNIsUeJelNN5J3BK55OV/RXVMONC5kDr4N7T4JyhT6KUa4k+FSJ0S1GTPQMWQQEkWDF1MlZXv5yGwW4h5rN3tt//vqyHk968SyqlhTdygqzx6tO6t3OsfQ2F1AqVWAWsHQckL+VmhEo53VqVXpsqLy9DyLYGjs=" # DOCKER_EMAIL
1111
- secure: "FbLHLKNAtpj7ZVgSobOPgAgdLK3/P4sR6RcaOmpVRsgaqodTPx7VkzGpkf4rOqPwxKU3+96vr0TlIdPRYWAE39Y3gMb1dyZ34+CxsrJ3avJYc2+9NT3kmAuU33Iy1DCo3IEnR7pWVVEyR80ob0c1ASfPAW1JN8DhBRRERpkMyn4=" # DOCKER_USER
1212
- secure: "VLK9NI4yE+hLV8rgjiB0hOfQn1uFO7cEHHL4sEDZKNu1TgvwfTrEWEzMMLvG8pwK/7eG78xfNB489m/Imj7Y52xK6sZuY7Y78Y06mkepZS8PisAJiW59kHWH1Ci84DYHZ0y07NAgvCOSLS9l0ncgLdlGvRboR9KBYDMEWycwEn8=" # DOCKER_PWD
13+
- secure: "YdYgoOCsfP8etDVdbURY/HCqZhGUrWzOsgQcfBCnkbBueU0ugt48rX/BFTtrq/qIJp/N9YqDpw7Vz3X1mhfT3EMpNJRDkbHaMM1YxWX++PmGdVu71ZCiONd2/Q8h8uZP7MLgeD7nnMhls8LBgiCqqWUK0NXfMQwzALYechV42nw=" # SONATYPE_USER
14+
- secure: "a5ZD5zp0Nu1GQUMJeTL9fCNxbtKfRzXOafWsrCipP/qg+uKrbNVS5sbhCBu7WB/Qf1x8cQapyXgRcFX/13bTkB+SWYEcUeRK5FH0hByaWLbjxuQNx5QjoRZEgi7lgvEbgyFPnsqAKLPoKmauRGGAlkhZOwnLRFpdha/+b2lKRs8=" # SONATYPE_PWD
15+
- secure: "ixdgd8MbWHpLYPhmUF/+yAh6YGiK3C3xnhuYgam3wKkVhC5UcdW4SPGDuB2fNjgFCzMQ5uonBwYFINLDps3VWHtA0NTvImxOUuRFeo60NkAaygmx5hjEhw69Kgpo7h1MRe6Tkexq5+u+ImrAjoQFCwXZfRG8y7jhMvGUkicGPIg=" # PGP_PASSPHRASE
16+
- secure: "A1o93OIGEa6GCRDAesU20gXUDZwWgJbz9hJJoBBVS49Zk4asB09uE5GVVPGKSs+4nDvI55os1lQZWYgvaF2Yy9kvaXcxgx1TeXNsCwlH2ZAd7yiaQJxDil2/wjle3KrT/Nqbb+VssHKHMjacQQHgwzUYCWjok7Q7D9EmFppXvR4=" # GITHUB_TOKEN
1317

1418
cache:
1519
directories:
@@ -27,24 +31,26 @@ jdk:
2731

2832
# workaround for openjdk buffer overflow
2933
addons:
30-
hostname: localhost
34+
hostname: localhost
3135

3236
script:
33-
- sbt compile test:compile
34-
- sbt 'set concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)' "project powerapi-core" coverage test
35-
- find $HOME/.sbt -name "*.lock" | xargs rm
37+
- sbt compile test:compile
38+
- sbt 'set concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)' "project powerapi-core" coverage test
39+
- find $HOME/.sbt -name "*.lock" | xargs rm
3640

3741
before_install:
38-
- wget -O influxdb.deb https://s3.amazonaws.com/influxdb/influxdb_0.10.2-1_amd64.deb
39-
- sudo dpkg -i influxdb.deb
40-
- sudo service influxdb start
41-
- sleep 5; /usr/bin/influx --execute "CREATE USER powerapi WITH PASSWORD 'powerapi'
42-
WITH ALL PRIVILEGES"
42+
- openssl aes-256-cbc -K $encrypted_48ebb0d1c0b9_key -iv $encrypted_48ebb0d1c0b9_iv -in secrets.tar.enc -out secrets.tar -d
43+
- tar xvf secrets.tar
44+
- wget -O influxdb.deb https://s3.amazonaws.com/influxdb/influxdb_0.10.2-1_amd64.deb
45+
- sudo dpkg -i influxdb.deb
46+
- sudo service influxdb start
47+
- sleep 5; /usr/bin/influx --execute "CREATE USER powerapi WITH PASSWORD 'powerapi' WITH ALL PRIVILEGES"
48+
- sudo bash -c "source /usr/local/rvm/scripts/rvm; rvm use 2.2.3; gem install github_changelog_generator"
4349

4450
after_success:
45-
- sbt "project powerapi-core" coverageReport
46-
- sbt "project powerapi-core" codacyCoverage
47-
- sbt "project powerapi-core" coveralls
51+
- sbt "project powerapi-core" coverageReport
52+
- sbt "project powerapi-core" codacyCoverage
53+
- sbt "project powerapi-core" coveralls
4854

4955
before_deploy:
5056
- sbt "project powerapi-sampling" universal:packageZipTarball
@@ -65,6 +71,12 @@ deploy:
6571
repo: Spirals-Team/powerapi
6672

6773
after_deploy:
74+
- sbt "project powerapi-core" publishSigned sonatypeRelease
75+
- github_changelog_generator Spirals-Team/powerapi --token $GITHUB_TOKEN
76+
- git config user.name "TRAVIS CI"
77+
- git add CHANGELOG.md
78+
- git commit -m "core(changelog): update the Changelog"
79+
- git push --quiet "https://${GITHUB_TOKEN}@github.com/Spirals-Team/powerapi" master > /dev/null 2>&1
6880
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PWD
6981
- docker build -f docker/sampling/Dockerfile-sampling -t spirals/powerapi-sampling:$TRAVIS_TAG .
7082
- docker build -f docker/Dockerfile-cli -t spirals/powerapi-cli:$TRAVIS_TAG .

powerapi-cli/src/main/scala/org/powerapi/app/PowerAPI.scala

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ object PowerAPI extends App {
6565
powerMeters = Seq()
6666
}
6767

68-
def validate(regex: Regex, str: String) = str match {
68+
def validate(regex: Regex, str: String): Boolean = str match {
6969
case regex(_*) => true
7070
case _ => false
7171
}
@@ -125,7 +125,8 @@ object PowerAPI extends App {
125125
sys.exit(1)
126126
}
127127

128-
def cliMonitorsSubcommand(options: List[Map[Symbol, Any]], currentMonitor: Map[Symbol, Any], args: List[String]): (List[String], List[Map[Symbol, Any]]) = args match {
128+
def cliMonitorsSubcommand(options: List[Map[Symbol, Any]], currentMonitor: Map[Symbol, Any],
129+
args: List[String]): (List[String], List[Map[Symbol, Any]]) = args match {
129130
case Nil =>
130131
(List(), options :+ currentMonitor)
131132
case "modules" :: value :: "--prefix" :: prefix :: "monitor" :: tail if validate(modulesR, value) =>
@@ -139,25 +140,45 @@ object PowerAPI extends App {
139140
case "--frequency" :: value :: tail if validate(durationR, value) =>
140141
cliMonitorsSubcommand(options, currentMonitor ++ Map('frequency -> value), tail)
141142
case "--self" :: tail =>
142-
cliMonitorsSubcommand(options, currentMonitor + ('targets -> (currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] + Process(ManagementFactory.getRuntimeMXBean.getName.split("@")(0).toInt))), tail)
143+
cliMonitorsSubcommand(options,
144+
currentMonitor + ('targets ->
145+
(currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] + Process(ManagementFactory.getRuntimeMXBean.getName.split("@")(0).toInt))
146+
), tail)
143147
case "--pids" :: value :: tail if validate(pidsR, value) =>
144-
cliMonitorsSubcommand(options, currentMonitor + ('targets -> (currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] ++ value.split(",").map(pid => Process(pid.toInt)))), tail)
148+
cliMonitorsSubcommand(options,
149+
currentMonitor + ('targets ->
150+
(currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] ++ value.split(",").map(pid => Process(pid.toInt)))
151+
), tail)
145152
case "--apps" :: value :: tail if validate(appsR, value) =>
146-
cliMonitorsSubcommand(options, currentMonitor + ('targets -> (currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] ++ value.split(",").map(app => Application(app)))), tail)
153+
cliMonitorsSubcommand(options, currentMonitor + ('targets ->
154+
(currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] ++ value.split(",").map(app => Application(app)))
155+
), tail)
147156
case "--containers" :: value :: tail if validate(containersR, value) =>
148-
cliMonitorsSubcommand(options, currentMonitor + ('targets -> (currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] ++ value.split(",").map(container => Container(container)))), tail)
157+
cliMonitorsSubcommand(options, currentMonitor + ('targets ->
158+
(currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] ++ value.split(",").map(container => Container(container)))
159+
), tail)
149160
case "--all" :: tail =>
150-
cliMonitorsSubcommand(options, currentMonitor + ('targets -> (currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] + All)), tail)
161+
cliMonitorsSubcommand(options, currentMonitor + ('targets ->
162+
(currentMonitor.getOrElse('targets, Set[Any]()).asInstanceOf[Set[Any]] + All)
163+
), tail)
151164
case "--agg" :: value :: tail if validate(aggR, value) =>
152165
cliMonitorsSubcommand(options, currentMonitor ++ Map('agg -> value), tail)
153166
case "--console" :: tail =>
154-
cliMonitorsSubcommand(options, currentMonitor + ('displays -> (currentMonitor.getOrElse('displays, Set[Any]()).asInstanceOf[Set[Any]] + new ConsoleDisplay)), tail)
167+
cliMonitorsSubcommand(options, currentMonitor + ('displays ->
168+
(currentMonitor.getOrElse('displays, Set[Any]()).asInstanceOf[Set[Any]] + new ConsoleDisplay)
169+
), tail)
155170
case "--file" :: value :: tail =>
156-
cliMonitorsSubcommand(options, currentMonitor + ('displays -> (currentMonitor.getOrElse('displays, Set[Any]()).asInstanceOf[Set[Any]] + new FileDisplay(value))), tail)
171+
cliMonitorsSubcommand(options, currentMonitor + ('displays ->
172+
(currentMonitor.getOrElse('displays, Set[Any]()).asInstanceOf[Set[Any]] + new FileDisplay(value))
173+
), tail)
157174
case "--chart" :: tail =>
158-
cliMonitorsSubcommand(options, currentMonitor + ('displays -> (currentMonitor.getOrElse('displays, Set[Any]()).asInstanceOf[Set[Any]] + new JFreeChartDisplay)), tail)
175+
cliMonitorsSubcommand(options, currentMonitor + ('displays ->
176+
(currentMonitor.getOrElse('displays, Set[Any]()).asInstanceOf[Set[Any]] + new JFreeChartDisplay)
177+
), tail)
159178
case "--influx" :: host :: user :: pwd :: db :: measurement :: tail =>
160-
cliMonitorsSubcommand(options, currentMonitor + ('displays -> (currentMonitor.getOrElse('displays, Set[Any]()).asInstanceOf[Set[Any]] + new InfluxDisplay(host, user, pwd, db, measurement))), tail)
179+
cliMonitorsSubcommand(options, currentMonitor + ('displays ->
180+
(currentMonitor.getOrElse('displays, Set[Any]()).asInstanceOf[Set[Any]] + new InfluxDisplay(host, user, pwd, db, measurement))
181+
), tail)
161182
case option :: tail =>
162183
println(s"unknown monitor option $option")
163184
sys.exit(1)
@@ -169,8 +190,9 @@ object PowerAPI extends App {
169190
}
170191

171192
else {
172-
if (System.getProperty("os.name").toLowerCase.indexOf("nix") >= 0 || System.getProperty("os.name").toLowerCase.indexOf("nux") >= 0) Seq("bash", "scripts/system.bash").!
173-
193+
if (System.getProperty("os.name").toLowerCase.indexOf("nix") >= 0 || System.getProperty("os.name").toLowerCase.indexOf("nux") >= 0) {
194+
Seq("bash", "scripts/system.bash").!
195+
}
174196
val (configuration, duration) = cli(List(), "3600", args.toList)
175197

176198
var libpfmHelper: Option[LibpfmHelper] = None

powerapi-core/build.sbt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import collection.JavaConversions._
2+
import com.typesafe.sbt.SbtPgp._
3+
14
name := "powerapi-core"
25

36
organization := "org.powerapi"
@@ -71,3 +74,21 @@ publishTo := {
7174
else
7275
Some("releases" at nexus + "service/local/staging/deploy/maven2")
7376
}
77+
78+
(System.getenv().getOrElse("SONATYPE_USERNAME", ""), System.getenv().getOrElse("SONATYPE_PASSWORD", "")) match {
79+
case (username, password) if username != "" && password != "" =>
80+
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)
81+
case _ =>
82+
credentials ++= Seq()
83+
}
84+
85+
System.getenv().getOrElse("PGP_PASSPHRASE", "") match {
86+
case passphrase if passphrase != "" =>
87+
pgpPassphrase := Some(passphrase.toCharArray)
88+
case _ =>
89+
pgpPassphrase := None
90+
}
91+
92+
pgpSecretRing := file("local.secring.gpg")
93+
94+
pgpPublicRing := file("local.pubring.gpg")

powerapi-core/src/main/scala/org/powerapi/PowerMeter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class PowerMeter(factory: ActorRefFactory, modules: Seq[PowerModule]) extends Po
152152
* @return the instance of the underlying software power meter.
153153
*/
154154
def waitFor(duration: FiniteDuration): this.type = {
155-
Await.result(underlyingActor.ask(WaitForMessage(duration))(duration + 1l.seconds), duration + 1l.seconds)
155+
Await.result(underlyingActor.ask(WaitForMessage(duration))(duration + 1L.seconds), duration + 1L.seconds)
156156
this
157157
}
158158

powerapi-core/src/main/scala/org/powerapi/core/MonitorActors.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ import akka.actor.{Actor, ActorRef, PoisonPill, Props}
3232
import akka.util.Timeout
3333

3434
import org.powerapi.core.ClockChannel.{startClock, stopClock, subscribeClockTick, unsubscribeClockTick}
35-
import org.powerapi.core.MonitorChannel.{MonitorAggregator, MonitorFrequency, MonitorStart, MonitorStop, MonitorStopAll, formatMonitorChildName, publishMonitorTick, setAggregator, setFrequency, stopMonitor, subscribeMonitorsChannel}
35+
import org.powerapi.core.MonitorChannel.{MonitorAggregator, MonitorFrequency, MonitorStart, MonitorStop, MonitorStopAll}
36+
import org.powerapi.core.MonitorChannel.{formatMonitorChildName, publishMonitorTick, setAggregator, setFrequency, stopMonitor, subscribeMonitorsChannel}
3637
import org.powerapi.core.power._
3738
import org.powerapi.core.target.Target
3839
import org.powerapi.core.TickChannel.{subscribeTick, unsubscribeTick}
3940
import org.powerapi.module.FormulaChannel.stopFormula
40-
import org.powerapi.module.PowerChannel.{AggregatePowerReport, RawPowerReport, render, subscribeAggPowerReport, subscribeRawPowerReport, unsubscribeRawPowerReport, unsubscribeAggPowerReport}
41+
import org.powerapi.module.PowerChannel.{AggregatePowerReport, RawPowerReport}
42+
import org.powerapi.module.PowerChannel.{render, subscribeAggPowerReport, subscribeRawPowerReport, unsubscribeRawPowerReport, unsubscribeAggPowerReport}
4143
import org.powerapi.module.SensorChannel.stopSensor
4244
import org.powerapi.reporter.ReporterChannel.{startReporter, stopReporter}
4345
import org.powerapi.{PowerDisplay, PowerMonitoring}

powerapi-core/src/main/scala/org/powerapi/core/OSHelper.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ trait OSHelper {
108108
case process: Process => getProcessCpuTime(process)
109109
case wrapper: Target if wrapper.isInstanceOf[Application] || wrapper.isInstanceOf[Container] =>
110110
getProcesses(wrapper).toSeq.map(process => getProcessCpuTime(process)).sum
111-
case _ => 0l
111+
case _ => 0L
112112
}
113113
}
114114
}
@@ -181,6 +181,9 @@ class LinuxHelper extends Configuration(None) with OSHelper {
181181
private val PSFormat = """^\s*(\d+)\s*""".r
182182
private val GlobalStatFormat = """cpu\s+([\d\s]+)""".r
183183
private val TimeInStateFormat = """(\d+)\s+(\d+)""".r
184+
private val procUserTimeIndex = 13
185+
private val procSysTimeIndex = 14
186+
private val procGlobalIdleTime = 3
184187

185188
def getCPUFrequencies: Set[Long] = {
186189
(for (index <- topology.values.flatten) yield {
@@ -230,13 +233,13 @@ class LinuxHelper extends Configuration(None) with OSHelper {
230233

231234
val statLine = source.getLines.toIndexedSeq(0).split("\\s")
232235
// User time + System time
233-
statLine(13).toLong + statLine(14).toLong
236+
statLine(procUserTimeIndex).toLong + statLine(procSysTimeIndex).toLong
234237
})
235238
}
236239
catch {
237240
case ioe: IOException =>
238241
log.warn("i/o exception: {}", ioe.getMessage)
239-
0l
242+
0L
240243
}
241244
}
242245

@@ -252,7 +255,7 @@ class LinuxHelper extends Configuration(None) with OSHelper {
252255
* @see http://lxr.free-electrons.com/source/kernel/sched/cputime.c#L165
253256
*/
254257
case GlobalStatFormat(times) =>
255-
val idleTime = times.split("\\s")(3).toLong
258+
val idleTime = times.split("\\s")(procGlobalIdleTime).toLong
256259
val activeTime = times.split("\\s").slice(0, 8).map(_.toLong).sum - idleTime
257260

258261
GlobalCpuTimes(idleTime, activeTime)
@@ -334,7 +337,7 @@ class SigarHelper(sigar: SigarProxy) extends OSHelper {
334337
catch {
335338
case se: SigarException =>
336339
log.warn("sigar exception: {}", se.getMessage)
337-
0l
340+
0L
338341
}
339342
}
340343

0 commit comments

Comments
 (0)