-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ztombol bats libraries + using multi stage build for dependenc…
…y resolution Signed-off-by: Damien DUPORTAL <[email protected]>
- Loading branch information
Showing
6 changed files
with
95 additions
and
19 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 |
---|---|---|
@@ -1,20 +1,31 @@ | ||
|
||
# We use npm for dependency management | ||
FROM node:alpine as dependencies-solver | ||
RUN apk add --no-cache git | ||
COPY package*.json /bats/ | ||
WORKDIR /bats | ||
RUN npm install | ||
|
||
# Minimalistic image | ||
FROM alpine:3.7 | ||
LABEL Maintainer="Damien DUPORTAL <[email protected]>" | ||
ENV BATS_HELPERS_DIR=/opt/bats-helpers | ||
|
||
ARG bats_version=0.4.0 | ||
ENV BATS_VERSION=${bats_version} | ||
# Bats | ||
COPY --from=dependencies-solver /bats/node_modules/bats /opt/bats | ||
|
||
# ztombol's bats helpers | ||
COPY --from=dependencies-solver /bats/node_modules/bats-support /opt/bats-helpers/bats-support | ||
COPY --from=dependencies-solver /bats/node_modules/bats-file /opt/bats-helpers/bats-file | ||
COPY --from=dependencies-solver /bats/node_modules/bats-assert /opt/bats-helpers/bats-assert | ||
|
||
WORKDIR /tests | ||
|
||
RUN apk add --no-cache \ | ||
bash \ | ||
curl \ | ||
&& curl -sSL -o "/tmp/v${BATS_VERSION}.tgz" \ | ||
"https://github.com/bats-core/bats-core/archive/v${BATS_VERSION}.tar.gz" \ | ||
&& tar -xzf "/tmp/v${BATS_VERSION}.tgz" -C /tmp/ \ | ||
&& bash "/tmp/bats-core-${BATS_VERSION}/install.sh" /opt/bats \ | ||
RUN apk add --no-cache bash \ | ||
&& ln -s /opt/bats/libexec/bats /sbin/bats | ||
|
||
WORKDIR /tests | ||
|
||
|
||
ENTRYPOINT ["/sbin/bats"] | ||
|
||
CMD ["-v"] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,14 @@ | ||
{ | ||
"name": "dduportal-bats", | ||
"version": "1.0.0", | ||
"description": "This file is use for dependency management only and will never be used on the end Docker image", | ||
"private": "true", | ||
"author": "Damien DUPORTAL <[email protected]>", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"bats": "^0.4.2", | ||
"bats-support": "git+https://github.com/ztombol/bats-support.git#v0.3.0", | ||
"bats-assert": "git+https://github.com/ztombol/bats-assert.git#v0.3.0", | ||
"bats-file": "git+https://github.com/ztombol/bats-file.git#v0.2.0" | ||
} | ||
} |
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,5 +1,18 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "${BATS_HELPERS_DIR}/bats-support/load.bash" | ||
load "${BATS_HELPERS_DIR}/bats-file/load.bash" | ||
load "${BATS_HELPERS_DIR}/bats-assert/load.bash" | ||
|
||
@test "Simple echo test" { | ||
echo "Hello Bats" | ||
} | ||
|
||
@test "I can use an assert() from helper bats-assert" { | ||
touch '/var/log/test.log' | ||
assert [ -e '/var/log/test.log' ] | ||
} | ||
|
||
@test "I can use an assert_file_exist() from helper bats-file" { | ||
assert_file_exist '/tmp' | ||
} |
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