Skip to content

Commit f28dbef

Browse files
authored
Add GitHub Actions matrix build for Spark 3 and 4 (#74)
* Add GitHub Actions matrix build for Spark 3 and 4 Implemented a matrix build strategy to run integration test against both Spark 3.x and Spark 4.x. Ensures CI coverage for multiple Spark versions and compatibility validation. * Remove sparkVersion from sparkApplication spec
1 parent ee05358 commit f28dbef

File tree

6 files changed

+57
-23
lines changed

6 files changed

+57
-23
lines changed

.github/workflows/e2e.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
main:
99
name: Run spark-measure end-to-end tests
1010
runs-on: ubuntu-24.04
11+
strategy:
12+
matrix:
13+
spark_image_tag: [ '3.5.6-scala2.12-java17-python3-ubuntu', '4.0.0-scala2.13-java17-python3-ubuntu' ]
1114
steps:
1215
- name: Checkout code
1316
uses: actions/checkout@v2
@@ -25,7 +28,7 @@ jobs:
2528
./e2e/prereq.sh
2629
- name: Build spark-measure image
2730
run: |
28-
./e2e/build.sh
31+
./e2e/build.sh -i ${{ matrix.spark_image_tag }}
2932
- name: Load spark-measure image into k8s/kind cluster
3033
run: |
3134
./e2e/push-image.sh -k -d

Dockerfile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
# Use a Scala SBT base image with Java 17 for building sparkMeasure jar files
1+
ARG spark_image_tag=4.0.0-scala2.13-java17-python3-ubuntu
2+
ARG scala_version
3+
24
FROM sbtscala/scala-sbt:eclipse-temurin-alpine-17.0.15_6_1.11.3_2.13.16 AS builder
5+
ARG scala_version
36

47
# Set the working directory
58
WORKDIR /app
69

710
# Copy the SBT configuration file
811
COPY build.sbt ./
12+
913
# Copy the SBT project configuration directory
1014
COPY project ./project
1115

1216
# Copy the application source code
1317
COPY src ./src
1418

15-
# Compile the project with Scala 2.12.18
16-
ENV SCALA_VERSION=2.12.18
17-
RUN sbt ++${SCALA_VERSION} package
19+
# Compile the project with Scala
20+
ENV SCALA_VERSION_LONG=${scala_version}.8
21+
RUN sbt ++${SCALA_VERSION_LONG} package
1822

19-
# Use the official Spark image with Scala 2.12, Java 17, and Python 3 for runtime
20-
FROM docker.io/library/spark:3.5.6-scala2.12-java17-python3-ubuntu
23+
# Build the spark image container sparkMeasure
24+
FROM docker.io/library/spark:${spark_image_tag}
25+
ARG scala_version
2126

2227
USER root
2328

24-
# Set up the Prometheus JMX exporter to expose metrics to Prometheus
29+
# Setup for the Prometheus JMX exporter.
30+
# Add the Prometheus JMX exporter Java agent jar for exposing metrics sent to the JmxSink to Prometheus.
2531
ENV JMX_EXPORTER_AGENT_VERSION=1.1.0
2632
ADD https://github.com/prometheus/jmx_exporter/releases/download/${JMX_EXPORTER_AGENT_VERSION}/jmx_prometheus_javaagent-${JMX_EXPORTER_AGENT_VERSION}.jar /opt/spark/jars
2733
RUN chmod 644 /opt/spark/jars/jmx_prometheus_javaagent-${JMX_EXPORTER_AGENT_VERSION}.jar
@@ -35,8 +41,8 @@ RUN pip install /opt/src/python
3541
# Add rootfs filesystem, it contains python scripts for runnning end-to-end tests
3642
ADD e2e/rootfs/ /
3743

38-
# Copy the compiled jar from the build stage
39-
COPY --from=builder /app/target/scala-2.12/*.jar /opt/spark/jars/
44+
# Copy the sparkMeasure compiled jar from the build stage
45+
COPY --from=builder /app/target/scala-${scala_version}/*.jar /opt/spark/jars/
4046

4147
# Set the Spark user
4248
ARG spark_uid=185
@@ -47,4 +53,4 @@ USER ${spark_uid}
4753
EXPOSE 4040
4854

4955
# Set the default entrypoint
50-
CMD ["/bin/bash"]
56+
CMD ["/bin/bash"]

e2e/argocd.sh

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Install pre-requisite for fink ci
3+
# Run integration tests for sparkMeasure over Kubernetes
44

55
# @author Fabrice Jammes
66

@@ -9,6 +9,28 @@ set -euxo pipefail
99
DIR=$(cd "$(dirname "$0")"; pwd -P)
1010
PROJECT_DIR=$(cd "$DIR/.."; pwd -P)
1111

12+
usage() {
13+
cat << EOD
14+
15+
Usage: `basename $0` [options]
16+
17+
Available options:
18+
-h this message
19+
20+
Run integration tests for sparkMeasure over Kubernetes
21+
22+
EOD
23+
}
24+
25+
# get the options
26+
while getopts hi: c ; do
27+
case $c in
28+
h) usage ; exit 0 ;;
29+
\?) usage ; exit 2 ;;
30+
esac
31+
done
32+
shift `expr $OPTIND - 1`
33+
1234
ciux ignite --selector itest "$PROJECT_DIR"
1335

1436
# Run the CD pipeline
@@ -27,7 +49,7 @@ if [ "${GITHUB_EVENT_NAME:-}" = "pull_request" ]; then
2749
# During a PR, the git repository containing the CI code is the forked one
2850
git_repo=$(jq -r '.pull_request.head.repo.full_name' "$GITHUB_EVENT_PATH")
2951
else
30-
revision="${SPARKMEASURE_WORKBRANCH:-main}"
52+
revision="${SPARKMEASURE_WORKBRANCH}"
3153
git_repo="${GITHUB_REPOSITORY}"
3254
fi
3355
git_repo="https://github.com/${git_repo}"
@@ -45,4 +67,4 @@ argocd app set spark-jobs -p image.tag="$CIUX_IMAGE_TAG"
4567
argocd app sync -l app.kubernetes.io/part-of=$app_name,app.kubernetes.io/component=operator
4668
argocd app wait -l app.kubernetes.io/part-of=$app_name,app.kubernetes.io/component=operator
4769

48-
argocd app sync -l app.kubernetes.io/part-of=$app_name
70+
argocd app sync -l app.kubernetes.io/part-of=$app_name

e2e/build.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
#!/bin/bash
2-
3-
42
# Build image containing integration tests for sparkMeasure over Kubernetes
5-
63
# @author Fabrice Jammes
74

85
set -euxo pipefail
96

107
DIR=$(cd "$(dirname "$0")"; pwd -P)
118
PROJECT_DIR=$(cd "$DIR/.."; pwd -P)
9+
spark_image_tag="3.5.6-scala2.12-java17-python3-ubuntu"
1210

1311
usage() {
1412
cat << EOD
1513
1614
Usage: `basename $0` [options]
1715
1816
Available options:
19-
-h this message
17+
-h this message
18+
-i spark image tag to use as base image (default: 3.5.6-scala2.12-java17-python3-ubuntu)
2019
2120
Build image containing integration tests for sparkMeasure over Kubernetes
2221
EOD
2322
}
2423

2524
# get the options
26-
while getopts h c ; do
25+
while getopts hi: c ; do
2726
case $c in
2827
h) usage ; exit 0 ;;
28+
i) spark_image_tag="$OPTARG" ;;
2929
\?) usage ; exit 2 ;;
3030
esac
3131
done
@@ -34,8 +34,13 @@ shift `expr $OPTIND - 1`
3434
ciux ignite --selector build $PROJECT_DIR
3535
. $PROJECT_DIR/.ciux.d/ciux_build.sh
3636

37+
scala_version=$(echo "$spark_image_tag" | grep -oP 'scala\K[0-9]+\.[0-9]+')
38+
3739
echo "Building Docker image for sparkMeasure integration tests"
38-
docker image build --tag "$CIUX_IMAGE_URL" "$PROJECT_DIR"
40+
docker image build \
41+
--build-arg "spark_image_tag=$spark_image_tag" \
42+
--build-arg "scala_version=$scala_version" \
43+
--tag "$CIUX_IMAGE_URL" "$PROJECT_DIR"
3944

4045
echo "Build successful"
4146

e2e/charts/spark-jobs/templates/spark-pi.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ spec:
1010
mainApplicationFile: local:///opt/spark/examples/spark-pi.py
1111
arguments:
1212
- "10"
13-
sparkVersion: "3.5.6"
1413
driver:
1514
cores: 1
1615
coreLimit: "1200m"
@@ -19,4 +18,4 @@ spec:
1918
executor:
2019
cores: 1
2120
instances: 1
22-
memory: "512m"
21+
memory: "512m"

e2e/charts/spark-jobs/templates/spark-sql.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ spec:
88
image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
99
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
1010
mainApplicationFile: local:///opt/spark/examples/spark-sql.py
11-
sparkVersion: "3.5.6"
1211
driver:
1312
cores: 1
1413
coreLimit: "1200m"

0 commit comments

Comments
 (0)