-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6f62383
Showing
12 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.scala] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
target/ | ||
boot/ | ||
lib_managed/ | ||
src_managed/ | ||
project/plugins/project/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
style = defaultWithAlign | ||
|
||
maxColumn = 120 | ||
|
||
project.excludeFilters = ["target/"] | ||
|
||
# Only format files tracked by git. | ||
project.git = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: scala | ||
|
||
scala: | ||
- 2.12.2 | ||
|
||
jdk: | ||
- oraclejdk8 | ||
|
||
script: | ||
## This runs the template with the default parameters, and runs test within the templated app. | ||
- sbt -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** ********* PROJECT INFO ******************/ | ||
name := "poker_api" | ||
version := "0.0.1" | ||
|
||
/** ********* PROJECT SETTINGS ******************/ | ||
Configuration.settings | ||
|
||
/** ********* PROD DEPENDENCIES *****************/ | ||
libraryDependencies ++= Seq( | ||
"com.github.nscala-time" %% "nscala-time" % "2.16.0", | ||
"com.lihaoyi" %% "pprint" % "0.5.2" | ||
) | ||
|
||
/** ********* TEST DEPENDENCIES *****************/ | ||
libraryDependencies ++= Seq( | ||
"org.scalatest" %% "scalatest" % "3.0.1" % Test, | ||
"org.scalamock" %% "scalamock-scalatest-support" % "3.6.0" % Test | ||
) | ||
|
||
/** ********* COMMANDS ALIASES ******************/ | ||
addCommandAlias("t", "test") | ||
addCommandAlias("to", "testOnly") | ||
addCommandAlias("tq", "testQuick") | ||
addCommandAlias("tsf", "testShowFailed") | ||
|
||
addCommandAlias("c", "compile") | ||
addCommandAlias("tc", "test:compile") | ||
|
||
addCommandAlias("f", "scalafmt") // Format all files according to ScalaFmt | ||
addCommandAlias("ft", "scalafmtTest") // Test if all files are formatted according to ScalaFmt | ||
|
||
addCommandAlias("prep", ";c;tc;ft") // All the needed tasks before running the test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
cd "$(dirname "$0")/../.." | ||
|
||
rm -rf .git/hooks | ||
|
||
ln -s ../doc/hooks .git/hooks | ||
sudo chmod -R 777 doc/hooks/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# Checks if locally staged changes are formatted properly ignoring non-staged changes. | ||
# Install it with the `install-hooks.sh` script | ||
# Based on: https://gist.github.com/cvogt/2676ed6c6d1abafa3d6a | ||
|
||
PATH=$PATH:/usr/local/bin:/usr/local/sbin | ||
|
||
echo "" | ||
echo "Running pre-push hook… (you can omit this with --no-verify, but don't)" | ||
|
||
echo "* Moving to the project directory…" | ||
_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
DIR=$( echo $_DIR | sed 's/\/.git\/hooks$//' ) | ||
|
||
echo "* Stashing non-staged changes so we avoid checking them…" | ||
git diff --quiet | ||
hadNoNonStagedChanges=$? | ||
|
||
if ! [ $hadNoNonStagedChanges -eq 0 ] | ||
then | ||
git stash --keep-index -u > /dev/null | ||
fi | ||
|
||
echo "* Checking pre push conditions ('prep' SBT task)…" | ||
sbt prep > /dev/null | ||
canPush=$? | ||
|
||
if [ $canPush -ne 0 ] | ||
then | ||
echo " [KO] Error :(" | ||
fi | ||
|
||
echo "* Applying the stash with the non-staged changes…" | ||
if ! [ $hadNoNonStagedChanges -eq 0 ] | ||
then | ||
sleep 1 && git stash pop --index > /dev/null & # sleep because otherwise commit fails when this leads to a merge conflict | ||
fi | ||
|
||
# Final result | ||
echo "" | ||
|
||
if [ $canPush -eq 0 ] | ||
then | ||
echo "[OK] Your code will be pushed young Padawan" | ||
exit 0 | ||
else | ||
echo "[KO] Cancelling push due to test code style error (run 'sbt prep' for more information)" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sbt.{Tests, _} | ||
import sbt.Keys._ | ||
|
||
object Configuration { | ||
val settings = Seq( | ||
organization := "com.lambtors", | ||
scalaVersion := "2.12.2", | ||
// Compiler options | ||
scalacOptions ++= Seq( | ||
"-deprecation", // Warnings deprecation | ||
"-feature", // Advise features | ||
"-unchecked", // More warnings. Strict | ||
"-Xlint", // More warnings when compiling | ||
"-Xfatal-warnings", // Warnings became errors | ||
"-Ywarn-dead-code", | ||
"-Ywarn-unused", | ||
"-Ywarn-unused-import", | ||
"-Xcheckinit" // Check against early initialization | ||
), | ||
scalacOptions in run in Compile -= "-Xcheckinit", // Remove it in production because it's expensive | ||
javaOptions += "-Duser.timezone=UTC", | ||
// Test options | ||
parallelExecution in Test := false, | ||
testForkedParallel in Test := false, | ||
fork in Test := true, | ||
testOptions in Test ++= Seq( | ||
Tests.Argument(TestFrameworks.ScalaTest, "-u", "target/test-reports"), // Save test reports | ||
Tests.Argument("-oDF") // Show full stack traces and time spent in each test | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=0.13.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.6.6") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.lambtors.poker_api | ||
|
||
class Poker_api { | ||
def greet(name: String): String = "Hello " + name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.lambtors.poker_api | ||
|
||
import org.scalatest._ | ||
import org.scalatest.Matchers._ | ||
|
||
final class Poker_apiTest extends WordSpec with GivenWhenThen { | ||
"Poker_api" should { | ||
"greet" in { | ||
Given("a Poker_api") | ||
|
||
val poker_api = new Poker_api | ||
|
||
When("we ask him to greet someone") | ||
|
||
val nameToGreet = "CodelyTV" | ||
val greeting = poker_api.greet(nameToGreet) | ||
|
||
Then("it should say hello to someone") | ||
|
||
greeting shouldBe "Hello " + nameToGreet | ||
} | ||
} | ||
} |