-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from PolySync/docker-based-build
Build in docker
- Loading branch information
Showing
2 changed files
with
106 additions
and
51 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,50 @@ | ||
FROM ubuntu:16.04 | ||
|
||
WORKDIR /app | ||
|
||
# common packages | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
ca-certificates curl file tar clang libclang-dev \ | ||
build-essential cmake libssl-dev zlib1g-dev \ | ||
ruby-dev libboost-dev git wget && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# install cucumber package | ||
RUN gem install cucumber -v 2.0.0 --no-rdoc --no-ri | ||
|
||
# install rust toolchain | ||
env RUSTUP_HOME=/usr/local/rustup \ | ||
CARGO_HOME=/usr/local/cargo | ||
|
||
RUN curl https://sh.rustup.rs -sSf | \ | ||
sh -s -- --default-toolchain 1.20.0 -y | ||
|
||
env PATH=/usr/local/cargo/bin:${PATH} | ||
|
||
# install arduino toolchain | ||
RUN wget -nv http://arduino.cc/download.php?f=/arduino-1.8.5-linux64.tar.xz -O arduino-1.8.5.tar.xz | ||
|
||
RUN tar -xf arduino-1.8.5.tar.xz && \ | ||
cd arduino-1.8.5 && \ | ||
mkdir -p /usr/share/arduino && \ | ||
cp -R * /usr/share/arduino | ||
|
||
|
||
# Fetch and build cargo deps | ||
RUN mkdir src && echo "fn main() { }" >> build.rs && touch src/tests.rs | ||
|
||
COPY ./firmware/brake/kia_soul_ev_niro/tests/property/Cargo.toml . | ||
RUN cargo build | ||
|
||
COPY ./firmware/brake/kia_soul_petrol/tests/property/Cargo.toml . | ||
RUN cargo build | ||
|
||
COPY ./firmware/common/libs/pid/tests/property/Cargo.toml . | ||
RUN cargo build | ||
|
||
COPY ./firmware/steering/tests/property/Cargo.toml . | ||
RUN cargo build | ||
|
||
COPY ./firmware/throttle/tests/property/Cargo.toml . | ||
RUN cargo build |
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,60 +1,65 @@ | ||
#!groovy | ||
|
||
def cleanCheckout() { | ||
checkout([ | ||
$class: 'GitSCM', | ||
branches: scm.branches, | ||
extensions: scm.extensions + [[$class: 'CleanBeforeCheckout']], | ||
userRemoteConfigs: scm.userRemoteConfigs | ||
]) | ||
} | ||
node { | ||
checkout scm | ||
|
||
def image = docker.build("cmake-build:${env.BUILD_ID}") | ||
|
||
def builds = [:] | ||
def output = image.inside { | ||
sh returnStdout: true, script: "cmake -LA ./firmware | grep 'VEHICLE_VALUES' | cut -d'=' -f 2" | ||
} | ||
|
||
def platforms = output.trim().tokenize(';') | ||
|
||
for(int j=0; j<platforms.size(); j++) { | ||
def platform_idx = j | ||
def platform = platforms[platform_idx] | ||
builds[platform] = { | ||
node { | ||
checkout scm | ||
|
||
node('worker'){ | ||
def builds = [:] | ||
cleanCheckout() | ||
def output = sh returnStdout: true, script: "cmake -LA ./firmware | grep 'VEHICLE_VALUES' | cut -d'=' -f 2" | ||
def platforms = output.trim().tokenize(';') | ||
|
||
for(int j=0; j<platforms.size(); j++) { | ||
def platform_idx = j | ||
def platform = platforms[platform_idx] | ||
builds[platform] = { | ||
node('arduino') { | ||
try { | ||
stage("Checkout") { | ||
cleanCheckout() | ||
} | ||
stage("Build ${platform}") { | ||
sh "cd firmware && mkdir build_${platform} && cd build_${platform} \ | ||
&& cmake -DVEHICLE=${platform} -DCMAKE_BUILD_TYPE=Release .. && make" | ||
echo "${platform}: Build Complete!" | ||
} | ||
stage("Test ${platform} unit tests") { | ||
sh "cd firmware && mkdir build_${platform}_tests && \ | ||
cd build_${platform}_tests && cmake -DVEHICLE=${platform} \ | ||
-DTESTS=ON -DPORT_SUFFIX=${EXECUTOR_NUMBER}${platform_idx} \ | ||
-DCMAKE_BUILD_TYPE=Release .. && make run-unit-tests" | ||
echo "${platform}: Unit Tests Complete!" | ||
} | ||
stage("Test ${platform} property-based tests") { | ||
withEnv(["PATH+CARGO=$HOME/.cargo/bin"]) { | ||
sh "cd firmware/build_${platform}_tests && make run-property-tests" | ||
echo "${platform}: Property-Based Tests Complete!" | ||
image = docker.build("cmake-build:${env.BUILD_ID}") | ||
|
||
stage("Build ${platform}") { | ||
image.inside { | ||
sh "cd firmware && \ | ||
rm -rf build_${platform} && \ | ||
mkdir build_${platform} && \ | ||
cd build_${platform} && \ | ||
cmake -DVEHICLE=${platform} -DCMAKE_BUILD_TYPE=Release .. && \ | ||
make" | ||
|
||
echo "${platform}: Build Complete!" | ||
} | ||
} | ||
|
||
stage("Test ${platform} unit tests") { | ||
image.inside { | ||
sh "cd firmware && \ | ||
rm -rf build_${platform}_tests && \ | ||
mkdir build_${platform}_tests && \ | ||
cd build_${platform}_tests && \ | ||
cmake -DVEHICLE=${platform} \ | ||
-DTESTS=ON \ | ||
-DPORT_SUFFIX=${EXECUTOR_NUMBER}${platform_idx} \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
.. && \ | ||
make run-unit-tests" | ||
echo "${platform}: Unit Tests Complete!" | ||
} | ||
} | ||
|
||
stage("Test ${platform} property-based tests") { | ||
image.inside("--user root:root") { | ||
sh "cd firmware/build_${platform}_tests && \ | ||
make run-property-tests" | ||
echo "${platform}: Property-Based Tests Complete!" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
finally { | ||
deleteDir() | ||
} | ||
} | ||
} | ||
} | ||
|
||
try { | ||
parallel builds | ||
} | ||
finally { | ||
deleteDir() | ||
} | ||
|
||
} |