Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
scottsand-db committed May 1, 2024
1 parent c38503b commit 2494813
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 8 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/spark_examples_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Delta Spark Local Publishing and Examples Compilation"
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
# These Scala versions must match those in the build.sbt
scala: [2.12.18, 2.13.13]
env:
SCALA_VERSION: ${{ matrix.scala }}
steps:
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v4
id: git-diff
with:
PATTERNS: |
**
.github/workflows/**
!kernel/**
!connectors/**
- name: install java
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "8"
- name: Cache Scala, SBT
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2
~/.cache/coursier
# Change the key if dependencies are changed. For each key, GitHub Actions will cache the
# the above directories when we use the key for the first time. After that, each run will
# just use the cache. The cache is immutable so we need to use a new key when trying to
# cache new stuff.
key: delta-sbt-cache-spark-examples-scala${{ matrix.scala }}
- name: Install Job dependencies
run: |
sudo apt-get update
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
sudo apt install libedit-dev
if: steps.git-diff.outputs.diff
- name: Run Delta Spark Local Publishing and Examples Compilation
# examples/scala/build.sbt will compile against the local Delta relase version (e.g. 3.2.0-SNAPSHOT).
# Thus, we need to publishM2 first so those jars are locally accessible.
run: |
build/sbt clean
build/sbt "++ $SCALA_VERSION publishM2"
cd examples/scala && build/sbt "++ $SCALA_VERSION compile"
if: steps.git-diff.outputs.diff
1 change: 0 additions & 1 deletion .github/workflows/spark_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,4 @@ jobs:
# when changing TEST_PARALLELISM_COUNT make sure to also change it in spark_master_test.yaml
run: |
TEST_PARALLELISM_COUNT=2 pipenv run python run-tests.py --group spark
cd examples/scala && build/sbt "++ $SCALA_VERSION compile"
if: steps.git-diff.outputs.diff
23 changes: 16 additions & 7 deletions examples/scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ organizationName := "example"

val scala212 = "2.12.18"
val scala213 = "2.13.13"
val deltaVersion = "3.0.0"
val icebergVersion = "1.4.1"
val defaultDeltaVersion = {
val versionFileContent = IO.read(file("../../version.sbt"))
val versionRegex = """.*version\s*:=\s*"([^"]+)".*""".r
versionRegex.findFirstMatchIn(versionFileContent) match {
case Some(m) => m.group(1)
case None => throw new Exception("Could not parse version from version.sbt")
}
}

def getMajorMinor(version: String): (Int, Int) = {
val majorMinor = Try {
Expand Down Expand Up @@ -58,7 +65,7 @@ val getScalaVersion = settingKey[String](
s"get scala version from environment variable SCALA_VERSION. If it doesn't exist, use $scala213"
)
val getDeltaVersion = settingKey[String](
s"get delta version from environment variable DELTA_VERSION. If it doesn't exist, use $deltaVersion"
s"get delta version from environment variable DELTA_VERSION. If it doesn't exist, use $defaultDeltaVersion"
)
val getDeltaArtifactName = settingKey[String](
s"get delta artifact name based on the delta version. either `delta-core` or `delta-spark`."
Expand All @@ -68,13 +75,14 @@ val getIcebergSparkRuntimeArtifactName = settingKey[String](
)
getScalaVersion := {
sys.env.get("SCALA_VERSION") match {
case Some("2.12") =>
case Some("2.12") | Some(`scala212`) =>
scala212
case Some("2.13") =>
case Some("2.13") | Some(`scala213`) =>
scala213
case Some(v) =>
println(
s"[warn] Invalid SCALA_VERSION. Expected 2.12 or 2.13 but got $v. Fallback to $scala213."
s"[warn] Invalid SCALA_VERSION. Expected one of {2.12, $scala212, 2.13, $scala213} but " +
s"got $v. Fallback to $scala213."
)
scala213
case None =>
Expand All @@ -88,10 +96,11 @@ version := "0.1.0"
getDeltaVersion := {
sys.env.get("DELTA_VERSION") match {
case Some(v) =>
println(s"Using Delta version $v")
println(s"Using DELTA_VERSION Delta version $v")
v
case None =>
deltaVersion
println(s"Using default Delta version $defaultDeltaVersion")
defaultDeltaVersion
}
}

Expand Down

0 comments on commit 2494813

Please sign in to comment.