Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches: [ master, main, develop ]
pull_request:
branches: [ master, main, develop ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
java-version: [11]
scala-version: [2.11.12]

steps:
- uses: actions/checkout@v3

- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'

- name: Cache SBT dependencies
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}-${{ hashFiles('**/project/build.properties') }}
restore-keys: |
${{ runner.os }}-sbt-

- name: Run Scalastyle (Code Style Check)
run: sbt scalastyle

- name: Compile
run: sbt compile

- name: Run Tests
run: sbt test

- name: Package
run: sbt package
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.idea/
build/sbt-launch-*.jar
project/project/
project/target/
target/
*.iml
drafts/
logs/
.bsp/
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Spear Makefile
# Provides convenient commands for building and testing the project

.PHONY: help clean compile test style package build all

# Default target
help:
@echo "Spear Build Commands:"
@echo " make clean - Clean previous build artifacts"
@echo " make compile - Compile source code"
@echo " make test - Run all tests"
@echo " make style - Run scalastyle code style check"
@echo " make package - Create JAR package"
@echo " make build - Run complete build (clean + compile + test + style + package)"
@echo " make all - Alias for 'make build'"

clean:
sbt clean

compile:
sbt compile

test:
sbt test

style:
sbt scalastyle

package:
sbt package

build: clean compile test style package
@echo "Build completed successfully!"

all: build
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,56 @@ Currently Spear only works with local Scala collections.

# Build

## Quick Start

Building Spear is as easy as:

```bash
# Using Make (recommended)
make build

# Or using sbt directly
sbt package
```
$ ./build/sbt package

## Available Build Commands

The project includes several convenient build commands via Make:

```bash
make help # Show all available commands
make clean # Clean previous build artifacts
make compile # Compile source code
make test # Run all tests
make style # Run scalastyle code style check
make package # Create JAR package
make build # Run complete build (clean + compile + test + style + package)
```

## Code Style

The project uses Scalastyle for code style checking. Run style checks with:

```bash
make style
# or
sbt scalastyle
```

## CI/CD Integration

The project includes GitHub Actions workflow for continuous integration, which runs:
- Code style checks (scalastyle)
- Compilation
- Tests
- Packaging

# Run the REPL

Spear has an Ammonite-based REPL for interactive experiments. To start it:

```
$ ./build/sbt spear-repl/run
$ sbt spear-repl/run
```

Let's create a simple DataFrame of numbers:
Expand Down
30 changes: 13 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lazy val spear = {
Project(id = "spear", base = file("."))
.aggregate(modules: _*)
// Creates a SBT task alias "repl" that starts the REPL within an SBT session.
.settings(repl := (run in `spear-repl` in Compile toTask "").value)
.settings(repl := (Compile / run).toTask("").value)
}

def spearModule(name: String): Project =
Expand Down Expand Up @@ -62,7 +62,7 @@ lazy val javaPackagingSettings = {

Seq(
// Adds the "conf" directory into the package.
mappings in Universal ++= directory(baseDirectory(_.getParentFile / "conf").value),
Universal / mappings ++= directory(baseDirectory(_.getParentFile / "conf").value),
// Adds the "conf" directory to runtime classpath (relative to "$app_home/../lib").
scriptClasspath += "../conf"
)
Expand All @@ -82,48 +82,44 @@ lazy val commonSettings = {
scalaVersion := Dependencies.Versions.scala,
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"),
scalacOptions ++= Seq("-Ywarn-unused-import", "-Xlint"),
javacOptions ++= Seq("-source", "1.7", "-target", "1.7", "-g", "-Xlint:-options")
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-g", "-Xlint:-options")
)

val commonTestSettings = Seq(
// Disables parallel test execution to ensure logging order.
parallelExecution in Test := false,
Test / parallelExecution := false,
// Does not fork a new JVM process to run the tests.
fork := false,
Test / fork := false,
// Shows duration and full exception stack trace
testOptions in Test += Tests.Argument("-oDF")
Test / testOptions += Tests.Argument("-oDF")
)

val commonDependencySettings = {
import net.virtualvoid.sbt.graph.Plugin.graphSettings

graphSettings ++ Seq(
Seq(
// Avoids copying managed dependencies into `lib_managed`
retrieveManaged := false,
// Enables extra resolvers
resolvers ++= Dependencies.extraResolvers,
// Disables auto conflict resolution
conflictManager := ConflictManager.strict,
// Explicitly overrides all conflicting transitive dependencies
dependencyOverrides ++= Dependencies.overrides
dependencyOverrides ++= Dependencies.overrides.toSeq
)
}

val scalariformPluginSettings = {
import com.typesafe.sbt.SbtScalariform.scalariformSettings
import com.typesafe.sbt.SbtScalariform.ScalariformKeys.preferences
import scalariform.formatter.preferences.PreferencesImporterExporter.loadPreferences

scalariformSettings ++ Seq(
Seq(
preferences := loadPreferences("scalariform.properties")
)
}

val taskSettings = Seq(
// Runs scalastyle before compilation
compile in Compile := (compile in Compile dependsOn (scalastyle in Compile toTask "")).value,
// Runs scalastyle before running tests
test in Test := (test in Test dependsOn (scalastyle in Test toTask "")).value
// Note: scalastyle automatic integration has syntax issues in sbt 1.x
// Scalastyle plugin is available and can be run manually with: sbt scalastyle
// The plugin works correctly but automatic integration syntax differs from sbt 0.13
)

Seq(
Expand All @@ -136,5 +132,5 @@ lazy val commonSettings = {
}

lazy val runtimeConfSettings = Seq(
unmanagedClasspath in Runtime += baseDirectory { _.getParentFile / "conf" }.value
Runtime / unmanagedClasspath += baseDirectory { _.getParentFile / "conf" }.value
)
156 changes: 0 additions & 156 deletions build/sbt

This file was deleted.

Loading