-
Notifications
You must be signed in to change notification settings - Fork 1
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
Christian Herrera
committed
Jul 21, 2024
1 parent
1eedf38
commit ad2567e
Showing
116 changed files
with
399 additions
and
2,488 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,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
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,16 @@ | ||
on: | ||
schedule: | ||
- cron: '0 6 * * 1-5' | ||
|
||
name: 🍄 Check dependencies updates | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
scala-steward: | ||
runs-on: ubuntu-22.04 | ||
name: Check Scala project dependencies updates with Scala Steward | ||
steps: | ||
- uses: scala-steward-org/scala-steward-action@v2 |
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,25 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'zulu' | ||
java-version: '21' | ||
cache: 'sbt' | ||
- name: 👌 Run "pre-push" tasks (compile and style-check) | ||
run: sbt prep | ||
- name: ✅ Run test | ||
run: sbt 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,16 @@ | ||
name: Update GitHub Dependency Graph | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: scalacenter/sbt-dependency-submission@v3 |
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 |
---|---|---|
@@ -1,4 +1,11 @@ | ||
version=2.5.2 | ||
version = 3.8.2 | ||
runner.dialect = scala213 | ||
style = default | ||
maxColumn = 120 | ||
continuationIndent.callSite = 2 | ||
align.preset = more | ||
maxColumn = 80 | ||
importSelectors = singleLine | ||
runner.optimizer.forceConfigStyleMinArgCount = 1 | ||
rewrite.rules = [SortImports] | ||
importSelectors = singleLine | ||
project.excludeFilters = ["target/"] | ||
project.git = true # Only format files tracked by git |
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 |
---|---|---|
@@ -1,38 +1,8 @@ | ||
scalaVersion := "2.12.12" | ||
version := "0.1.0-SNAPSHOT" | ||
name := "spark-for-programmers-course" | ||
organization := "com.codely" | ||
Settings.settings | ||
|
||
val sparkVesion = "3.5.0" | ||
libraryDependencies := Dependencies.all | ||
|
||
libraryDependencies ++= Seq( | ||
"org.apache.spark" %% "spark-core" % sparkVesion, | ||
"org.apache.spark" %% "spark-sql" % sparkVesion, | ||
"org.apache.spark" %% "spark-hive" % sparkVesion, | ||
"org.apache.spark" %% "spark-streaming" % sparkVesion, | ||
"org.apache.spark" %% "spark-sql-kafka-0-10" % sparkVesion, | ||
"io.delta" %% "delta-spark" % "3.1.0", | ||
// "com.amazonaws" % "aws-java-sdk-bundle" % "1.11.375", | ||
"org.apache.hadoop" % "hadoop-aws" % "3.2.2", | ||
"com.rabbitmq" % "amqp-client" % "5.12.0", | ||
"com.typesafe" % "config" % "1.4.1", | ||
//"org.apache.hadoop" % "hadoop-common" % "3.3.1", | ||
"org.scalatest" %% "scalatest" % "3.2.18" % Test, | ||
"org.scalatest" %% "scalatest-flatspec" % "3.2.18" % Test, | ||
"com.dimafeng" %% "testcontainers-scala" % "0.40.12" % Test, | ||
"com.dimafeng" %% "testcontainers-scala-kafka" % "0.40.12" % Test, | ||
"com.dimafeng" %% "testcontainers-scala-postgresql" % "0.41.4" % Test, | ||
"org.postgresql" % "postgresql" % "9.4.1207" % Test, | ||
"org.mockito" %% "mockito-scala" % "1.16.42" % Test | ||
) | ||
|
||
assembly / mainClass := Some( | ||
"com.codely.lesson_07_spark_optimize_and_monitoring.video_01__deploy_application.DeploySparkApp" | ||
) | ||
|
||
assembly / assemblyMergeStrategy := { | ||
case PathList("META-INF", xs @ _*) => MergeStrategy.discard | ||
case PathList("org", "apache", "spark", "unused", "UnusedStubClass.class") => | ||
MergeStrategy.first | ||
case _ => MergeStrategy.first | ||
SbtAliases.aliases.flatMap { | ||
case (alias, command) => | ||
addCommandAlias(alias, command) | ||
} |
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,20 @@ | ||
import sbt._ | ||
|
||
object Dependencies { | ||
private val prod = Seq( | ||
"com.github.nscala-time" %% "nscala-time" % "2.32.0", | ||
"com.lihaoyi" %% "pprint" % "0.9.0", | ||
"org.apache.spark" %% "spark-core" % "3.5.0" % Provided, | ||
"org.apache.spark" %% "spark-sql" % "3.5.0" % Provided, | ||
"org.apache.spark" %% "spark-streaming" % "3.5.0", | ||
"org.apache.spark" %% "spark-hive" % "3.5.0", | ||
"io.delta" %% "delta-spark" % "3.1.0", | ||
"org.apache.hadoop" % "hadoop-aws" % "3.2.2" | ||
) | ||
private val test = Seq( | ||
"org.scalatest" %% "scalatest" % "3.2.19", | ||
"org.mockito" %% "mockito-scala" % "1.16.42" | ||
).map(_ % Test) | ||
|
||
val all: Seq[ModuleID] = prod ++ 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,15 @@ | ||
object SbtAliases { | ||
val aliases: Seq[(String, String)] = Seq( | ||
"t" -> "test", | ||
"to" -> "testOnly", | ||
"tq" -> "testQuick", | ||
"tsf" -> "testShowFailed", | ||
"c" -> "compile", | ||
"tc" -> "Test / compile", | ||
"f" -> "scalafmt", // Format production files according to ScalaFmt | ||
"fc" -> "scalafmtCheck", // Check if production files are formatted according to ScalaFmt | ||
"tf" -> "Test / scalafmt", // Format test files according to ScalaFmt | ||
"tfc" -> "Test / scalafmtCheck", // Check if test files are formatted according to ScalaFmt | ||
"prep" -> ";c;tc;fc;tfc" // All the needed tasks before pushing to the repository (compile, compile test, format check in prod and 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,44 @@ | ||
import sbt.Keys._ | ||
import sbt.io.syntax._ | ||
import sbt.{Compile, Test, TestFrameworks, Tests, Configuration => _} | ||
|
||
object Settings { | ||
val settings = Seq( | ||
name := "spark-for-devs-course", | ||
version := "0.1.0-SNAPSHOT", | ||
scalaVersion := "2.12.12", | ||
organization := "com.codely", | ||
organizationName := "com.codely, Inc.", | ||
organizationHomepage := Some(url("https://com.codely")), | ||
// Custom folders path (remove the `/scala` default subdirectory) | ||
Compile / scalaSource := file( | ||
(baseDirectory.value / "src" / "main").toString | ||
), | ||
Test / scalaSource := file((baseDirectory.value / "src" / "test").toString), | ||
// Compiler options | ||
scalacOptions ++= Seq( | ||
"-deprecation", // Warnings deprecation | ||
"-feature", // Advise features | ||
"-unchecked", // More warnings. Strict | ||
"-Xlint", // More warnings when compiling | ||
"-Ywarn-dead-code", | ||
"-Ywarn-unused" | ||
), | ||
Test / scalacOptions += "-Xcheckinit", // Check against early initialization only in tests because it's expensive | ||
javaOptions += "-Duser.timezone=UTC", | ||
// Test options | ||
Test / parallelExecution := false, | ||
Test / testForkedParallel := false, | ||
Test / fork := true, | ||
Test / testOptions ++= 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 |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version = 1.9.8 | ||
sbt.version = 1.10.1 |
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0") | ||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.