Skip to content

Commit

Permalink
Problem: isolated Linux testing, release builds
Browse files Browse the repository at this point in the history
Currently, running some of the tests can be problematic
if SIT is also being used on that same machine by the same
user as SIT will try to pick up the existing user config.

Also, building releases requires the additional setup of
musl target.

Solution: provide a Docker container with the musl build environment
  • Loading branch information
yrashk committed Jun 23, 2018
1 parent 6f129b6 commit 534a925
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target
.idea
.sit/items/*/.lock
._docker_osx
._docker_linux
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
osx: target/x86_64-apple-darwin/release/sit target/x86_64-apple-darwin/release/sit-web
linux: target/x86_64-unknown-linux-musl/release/sit target/x86_64-unknown-linux-musl/release/sit-web

target/x86_64-apple-darwin/release/sit target/x86_64-apple-darwin/release/sit-web: build-tools/cross-compile-osx/Dockerfile sit-core sit-web sit
docker build --iidfile ._docker_osx build-tools/cross-compile-osx
sed -i s/sha256://g ._docker_osx
docker run -u `id -u`:`id -g` -v `pwd`:/sit -w /sit -t `cat ._docker_osx` sh -c "cargo build --release --target=x86_64-apple-darwin"
rm -f ._docker_osx

target/x86_64-unknown-linux-musl/release/sit target/x86_64-unknown-linux-musl/release/sit-web: build-tools/linux-build-container/Dockerfile sit-core sit-web sit
docker build --iidfile ._docker_linux build-tools/linux-build-container
sed -i s/sha256://g ._docker_linux
docker run -u `id -u`:`id -g` -v `pwd`:/sit -w /sit -t `cat ._docker_linux` sh -c "cargo build --release --target=x86_64-unknown-linux-musl && strip target/x86_64-unknown-linux-musl/release/sit target/x86_64-unknown-linux-musl/release/sit-web"
rm -f ._docker_linux
3 changes: 3 additions & 0 deletions build-tools/linux-build-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM rust:1.26.2
RUN apt-get update && apt-get install -y cmake libgit2-dev musl-tools
RUN rustup target add x86_64-unknown-linux-musl
12 changes: 12 additions & 0 deletions build-tools/linux-build-container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This container provides a convenient way to build and test sit in isolation
from the local environment (Linux-specific). This is particularly useful for
running integration tests that might inadvertently read user configuration and
fail because of that (or introduce undesired behaviour such as requiring gnupg
signatures and triggering gpg-agent popups) ir building releases.

A suggested way to run such isolated environment would be:

```
docker run -v /host/path/to/sit/repo:/sit -e CARGO_TARGET_DIR=/sit/test_target -ti <image tag>
```

0 comments on commit 534a925

Please sign in to comment.