Skip to content

Commit fed73f3

Browse files
committed
Add cache integration testing
1 parent 1903fa1 commit fed73f3

File tree

13 files changed

+220
-0
lines changed

13 files changed

+220
-0
lines changed

test/spec/cache_spec.rb

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'spec_helper'
4+
5+
describe 'Scala buildpack' do
6+
it 'caches compiled artifacts between builds' do
7+
new_default_hatchet_runner('sbt-0.11.7-play-3.x-scala-2.13.x').tap do |app|
8+
app.deploy do
9+
# First build should compile everything from scratch
10+
expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
11+
remote: -----> Scala app detected
12+
remote: -----> Installing Azul Zulu OpenJDK 21.0.[0-9]+
13+
remote: -----> Running: sbt compile stage
14+
remote: Downloading sbt launcher for 1.11.7:
15+
remote: From https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/1.11.7/sbt-launch-1.11.7.jar
16+
remote: To /tmp/scala_buildpack_build_dir/.sbt_home/launchers/1.11.7/sbt-launch.jar
17+
remote: Downloading sbt launcher 1.11.7 md5 hash:
18+
remote: From https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/1.11.7/sbt-launch-1.11.7.jar.md5
19+
remote: To /tmp/scala_buildpack_build_dir/.sbt_home/launchers/1.11.7/sbt-launch.jar.md5
20+
remote: /tmp/scala_buildpack_build_dir/.sbt_home/launchers/1.11.7/sbt-launch.jar: OK
21+
remote: \\[info\\] \\[launcher\\] getting org.scala-sbt sbt 1.11.7 \\(this may take some time\\)...
22+
remote: \\[info\\] \\[launcher\\] getting Scala 2.12.20 \\(for sbt\\)...
23+
remote: \\[info\\] welcome to sbt 1.11.7 \\(Azul Systems, Inc. Java 21.0.[0-9]+\\)
24+
remote: \\[info\\] loading global plugins from /tmp/scala_buildpack_build_dir/.sbt_home/plugins
25+
remote: \\[info\\] compiling 1 Scala source to /tmp/scala_buildpack_build_dir/.sbt_home/plugins/target/scala-2.12/sbt-1.0/classes ...
26+
remote: \\[info\\] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.20. Compiling...
27+
remote: \\[info\\] Compilation completed in .*s.
28+
remote: \\[info\\] done compiling
29+
remote: \\[info\\] loading settings for project scala_buildpack_build_dir-build from plugins.sbt...
30+
remote: \\[info\\] loading project definition from /tmp/scala_buildpack_build_dir/project
31+
remote: \\[info\\] loading settings for project root from build.sbt...
32+
remote: \\[info\\] __ __
33+
remote: \\[info\\] \\\\ \\\\ ____ / /____ _ __ __
34+
remote: \\[info\\] \\\\ \\\\ / __ \\\\ / // __ `// / / /
35+
remote: \\[info\\] / / / /_/ // // /_/ // /_/ /
36+
remote: \\[info\\] /_/ / .___//_/ \\\\__,_/ \\\\__, /
37+
remote: \\[info\\] /_/ /____/
38+
remote: \\[info\\]
39+
remote: \\[info\\] Version 3.0.9 running Java 21.0.[0-9]+
40+
remote: \\[info\\]
41+
remote: \\[info\\] Play is run entirely by the community. Please consider contributing and/or donating:
42+
remote: \\[info\\] https://www.playframework.com/sponsors
43+
remote: \\[info\\]
44+
remote: \\[info\\] Executing in batch mode. For better performance use sbt's shell
45+
remote: \\[info\\] compiling 7 Scala sources and 1 Java source to /tmp/scala_buildpack_build_dir/target/scala-2.13/classes ...
46+
remote: \\[info\\] done compiling
47+
remote: \\[success\\] Total time: .* s, completed .*
48+
remote: \\[info\\] Wrote /tmp/scala_buildpack_build_dir/target/scala-2.13/sbt-0-11-7-play-3-x-scala-2-13-x_2.13-1.0-SNAPSHOT.pom
49+
remote: \\[success\\] Total time: .*
50+
remote: -----> Collecting dependency information
51+
remote: -----> Dropping ivy cache from the slug
52+
remote: -----> Dropping sbt boot dir from the slug
53+
remote: -----> Dropping sbt cache dir from the slug
54+
remote: -----> Dropping compilation artifacts from the slug
55+
remote: -----> Discovering process types
56+
remote: Procfile declares types -> \\(none\\)
57+
remote: Default types for buildpack -> web
58+
remote:
59+
remote: -----> Compressing...
60+
REGEX
61+
62+
app.commit!
63+
app.push!
64+
65+
# Second build should use cached artifacts and doesn't recompile previously compiled application files
66+
expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
67+
remote: -----> Scala app detected
68+
remote: -----> Installing Azul Zulu OpenJDK 21.0.[0-9]+
69+
remote: -----> Running: sbt compile stage
70+
remote: \\[info\\] welcome to sbt 1.11.7 \\(Azul Systems, Inc. Java 21.0.[0-9]+\\)
71+
remote: \\[info\\] loading global plugins from /tmp/scala_buildpack_build_dir/.sbt_home/plugins
72+
remote: \\[info\\] loading settings for project scala_buildpack_build_dir-build from plugins.sbt...
73+
remote: \\[info\\] loading project definition from /tmp/scala_buildpack_build_dir/project
74+
remote: \\[info\\] loading settings for project root from build.sbt...
75+
remote: \\[info\\] __ __
76+
remote: \\[info\\] \\\\ \\\\ ____ / /____ _ __ __
77+
remote: \\[info\\] \\\\ \\\\ / __ \\\\ / // __ `// / / /
78+
remote: \\[info\\] / / / /_/ // // /_/ // /_/ /
79+
remote: \\[info\\] /_/ / .___//_/ \\\\__,_/ \\\\__, /
80+
remote: \\[info\\] /_/ /____/
81+
remote: \\[info\\]
82+
remote: \\[info\\] Version 3.0.9 running Java 21.0.[0-9]+
83+
remote: \\[info\\]
84+
remote: \\[info\\] Play is run entirely by the community. Please consider contributing and/or donating:
85+
remote: \\[info\\] https://www.playframework.com/sponsors
86+
remote: \\[info\\]
87+
remote: \\[info\\] Executing in batch mode. For better performance use sbt's shell
88+
remote: \\[success\\] Total time: .* s, completed .*
89+
remote: \\[info\\] Wrote /tmp/scala_buildpack_build_dir/target/scala-2.13/sbt-0-11-7-play-3-x-scala-2-13-x_2.13-1.0-SNAPSHOT.pom
90+
remote: \\[success\\] Total time: .*
91+
remote: -----> Collecting dependency information
92+
remote: -----> Dropping ivy cache from the slug
93+
remote: -----> Dropping sbt boot dir from the slug
94+
remote: -----> Dropping sbt cache dir from the slug
95+
remote: -----> Dropping compilation artifacts from the slug
96+
remote: -----> Discovering process types
97+
remote: Procfile declares types -> \\(none\\)
98+
remote: Default types for buildpack -> web
99+
remote:
100+
remote: -----> Compressing...
101+
REGEX
102+
end
103+
end
104+
end
105+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
logs
2+
target
3+
/.bsp
4+
/.idea
5+
/.idea_modules
6+
/.classpath
7+
/.project
8+
/.settings
9+
/RUNNING_PID
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package controllers
2+
3+
import javax.inject._
4+
import play.api._
5+
import play.api.mvc._
6+
7+
@Singleton
8+
class HomeController @Inject()(val controllerComponents: ControllerComponents) extends BaseController {
9+
10+
def index() = Action { implicit request: Request[AnyContent] =>
11+
Ok(views.html.index())
12+
}
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@()
2+
3+
@main("Welcome to Play") {
4+
<h1>Welcome to Play!</h1>
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@(title: String)(content: Html)
2+
3+
<!DOCTYPE html>
4+
<html lang="en">
5+
<head>
6+
<title>@title</title>
7+
</head>
8+
<body>
9+
@content
10+
</body>
11+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name := """sbt-0.11.7-play-3.x-scala-2.13.x"""
2+
organization := "com.heroku"
3+
4+
version := "1.0-SNAPSHOT"
5+
6+
lazy val root = (project in file(".")).enablePlugins(PlayScala)
7+
8+
scalaVersion := "2.13.17"
9+
10+
libraryDependencies += guice
11+
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "7.0.2" % Test
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
play.http.secret.key="hG;fgBT`Kd/=MBH75?R:xsP:mv=L2D4<43;SqF_NVb/3IKYCGf5mfHT^kJ?RSk^_"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<!-- https://www.playframework.com/documentation/latest/SettingsLogger -->
4+
5+
<!DOCTYPE configuration>
6+
7+
<configuration>
8+
<import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/>
9+
<import class="ch.qos.logback.classic.AsyncAppender"/>
10+
<import class="ch.qos.logback.core.FileAppender"/>
11+
<import class="ch.qos.logback.core.ConsoleAppender"/>
12+
13+
<appender name="FILE" class="FileAppender">
14+
<file>${application.home:-.}/logs/application.log</file>
15+
<encoder class="PatternLayoutEncoder">
16+
<charset>UTF-8</charset>
17+
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern>
18+
</encoder>
19+
</appender>
20+
21+
<appender name="STDOUT" class="ConsoleAppender">
22+
<!--
23+
On Windows, enabling Jansi is recommended to benefit from color code interpretation on DOS command prompts,
24+
which otherwise risk being sent ANSI escape sequences that they cannot interpret.
25+
See https://logback.qos.ch/manual/layouts.html#coloring
26+
-->
27+
<!-- <withJansi>true</withJansi> -->
28+
<encoder class="PatternLayoutEncoder">
29+
<charset>UTF-8</charset>
30+
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern>
31+
</encoder>
32+
</appender>
33+
34+
<appender name="ASYNCFILE" class="AsyncAppender">
35+
<appender-ref ref="FILE"/>
36+
</appender>
37+
38+
<appender name="ASYNCSTDOUT" class="AsyncAppender">
39+
<appender-ref ref="STDOUT"/>
40+
</appender>
41+
42+
<logger name="play" level="INFO"/>
43+
<logger name="application" level="DEBUG"/>
44+
45+
<root level="WARN">
46+
<appender-ref ref="ASYNCFILE"/>
47+
<appender-ref ref="ASYNCSTDOUT"/>
48+
</root>
49+
50+
</configuration>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# https://www.playframework.com/documentation/latest/ScalaI18N
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Routes
2+
# This file defines all application routes (Higher priority routes first)
3+
# https://www.playframework.com/documentation/latest/ScalaRouting
4+
# ~~~~
5+
6+
# An example controller showing a sample home page
7+
GET / controllers.HomeController.index()
8+
9+
# Map static resources from the /public folder to the /assets URL path
10+
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)

0 commit comments

Comments
 (0)