Skip to content

Commit 3373288

Browse files
committed
Move build and testing out of the Dockerfile
Add a test script which will build and run the test suite inside the docker image so that the docker image can be used for development.
1 parent 4b86816 commit 3373288

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ compiler: gcc
44

55
script:
66
- docker-compose build $TEST_ENV
7-
- docker run --rm -ti scala-native-bindgen:$TEST_ENV /usr/include/ctype.h -name ctype --
8-
- docker-compose run --rm sbt-test
7+
- docker-compose run $TEST_ENV
98

109
matrix:
1110
include:

Dockerfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN set -x \
1111
&& rm -rf /var/lib/apt/lists/*
1212

1313
ARG LLVM_VERSION=6.0
14+
ENV LLVM_VERSION=$LLVM_VERSION
1415
# LLVM dev versions do not have a "-x.y" version suffix.
1516
ARG LLVM_DEB_COMPONENT=-$LLVM_VERSION
1617
RUN set -x \
@@ -21,8 +22,4 @@ RUN set -x \
2122
&& apt install -y clang-$LLVM_VERSION libclang-$LLVM_VERSION-dev \
2223
&& rm -rf /var/lib/apt/lists/*
2324

24-
WORKDIR /src/target
25-
COPY . /src
26-
RUN cmake .. && make VERBOSE=1
27-
28-
ENTRYPOINT ["/src/target/scalaBindgen"]
25+
WORKDIR /src

docker-compose.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,41 @@ version: '3'
22

33
services:
44
ubuntu-18.04-llvm-dev:
5-
image: scala-native-bindgen:ubuntu-18.04-llvm-dev
5+
image: scalabindgen/scala-native-bindgen:ubuntu-18.04-llvm-dev
66
build:
77
context: .
88
args:
99
- UBUNTU_VERSION=18.04
1010
- LLVM_VERSION=7
1111
- LLVM_DEB_COMPONENT=
12+
command: scripts/test.sh
13+
volumes:
14+
- .:/src
15+
- ${HOME}/.ivy2:/root/.ivy2
16+
- ${HOME}/.sbt:/root/.sbt
1217

1318
ubuntu-18.04-llvm-6.0:
14-
image: scala-native-bindgen:ubuntu-18.04-llvm-6.0
19+
image: scalabindgen/scala-native-bindgen:ubuntu-18.04-llvm-6.0
1520
build:
1621
context: .
1722
args:
1823
- UBUNTU_VERSION=18.04
1924
- LLVM_VERSION=6.0
25+
command: scripts/test.sh
26+
volumes:
27+
- .:/src
28+
- ${HOME}/.ivy2:/root/.ivy2
29+
- ${HOME}/.sbt:/root/.sbt
2030

2131
ubuntu-18.04-llvm-5.0:
22-
image: scala-native-bindgen:ubuntu-18.04-llvm-5.0
32+
image: scalabindgen/scala-native-bindgen:ubuntu-18.04-llvm-5.0
2333
build:
2434
context: .
2535
args:
2636
- UBUNTU_VERSION=18.04
2737
- LLVM_VERSION=5.0
28-
29-
sbt-test:
30-
image: scala-native-bindgen:${TEST_ENV}
31-
entrypoint:
32-
- sh
33-
- -c
34-
- |
35-
cd /src/tests
36-
sbt compile test
38+
command: scripts/test.sh
3739
volumes:
40+
- .:/src
3841
- ${HOME}/.ivy2:/root/.ivy2
3942
- ${HOME}/.sbt:/root/.sbt

scripts/test.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
# Bash strict mode
4+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
5+
set -euo pipefail
6+
IFS=$'\n\t'
7+
8+
if [[ ! -e target/.llvm-version ]] || [[ "$(<target/.llvm-version)" != "${LLVM_VERSION:-}" ]]; then
9+
rm -rf target
10+
mkdir -p target
11+
echo "${LLVM_VERSION:-}" > target/.llvm-version
12+
(cd target && cmake ..)
13+
make -C target
14+
fi
15+
16+
cd tests
17+
sbt "${@:-test}"

0 commit comments

Comments
 (0)