summaryrefslogtreecommitdiff
path: root/ci
diff options
context:
space:
mode:
Diffstat (limited to 'ci')
-rw-r--r--ci/README.md48
-rw-r--r--ci/before_deploy.ps123
-rw-r--r--ci/before_deploy.sh33
-rw-r--r--ci/cargo-config18
-rw-r--r--ci/install.sh24
-rwxr-xr-xci/run-all.sh29
-rwxr-xr-xci/run-docker.sh15
-rw-r--r--ci/run-travis.sh41
-rwxr-xr-xci/run.sh137
-rw-r--r--ci/script.sh22
10 files changed, 102 insertions, 288 deletions
diff --git a/ci/README.md b/ci/README.md
deleted file mode 100644
index c86fd715..00000000
--- a/ci/README.md
+++ /dev/null
@@ -1,48 +0,0 @@
-Test Infrastructure
-===================
-
-The ci directory contains scripts that aid in the testing of nix both
-in our continuous integration environment (Travis CI) but also for
-developers working locally.
-
-Nix interfaces very directly with the underlying platform (usually via
-libc) and changes need to be tested on a large number of platforms to
-avoid problems.
-
-Running Tests For Host Architecture
------------------------------------
-
-Running the tests for one's host architecture can be done by simply
-doing the following:
-
- $ cargo test
-
-Running Tests Against All Architectures/Versions
-------------------------------------------------
-
-Testing for other architectures is more involved. Currently,
-developers may run tests against several architectures and versions of
-rust by running the `ci/run-all.sh` script. This scripts requires
-that docker be set up. This will take some time:
-
- $ ci/run-all.sh
-
-The list of versions and architectures tested by this can be
-determined by looking at the contents of the script. The docker image
-used is [posborne/rust-cross][posborne/rust-cross].
-
-[posborne/rust-cross]: https://github.com/rust-embedded/docker-rust-cross
-
-Running Test for Specific Architectures/Versions
-------------------------------------------------
-
-Suppose we have a failing test with Rust 1.7 on the raspberry pi. In
-that case, we can run the following:
-
- $ DOCKER_IMAGE=posborne/rust-cross:arm \
- RUST_VERSION=1.7.0 \
- RUST_TARGET=arm-unknown-linux-gnueabihf ci/run-docker.sh
-
-Currently, the docker images only support Rust 1.7. To get a better
-idea of combinations that might work, look at the contents of the
-[travis configuration](../.travis.yml) or [run-all.sh](run-all.sh).
diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1
new file mode 100644
index 00000000..191a30b8
--- /dev/null
+++ b/ci/before_deploy.ps1
@@ -0,0 +1,23 @@
+# This script takes care of packaging the build artifacts that will go in the
+# release zipfile
+
+$SRC_DIR = $PWD.Path
+$STAGE = [System.Guid]::NewGuid().ToString()
+
+Set-Location $ENV:Temp
+New-Item -Type Directory -Name $STAGE
+Set-Location $STAGE
+
+$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip"
+
+# TODO Update this to package the right artifacts
+Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\hello.exe" '.\'
+
+7z a "$ZIP" *
+
+Push-AppveyorArtifact "$ZIP"
+
+Remove-Item *.* -Force
+Set-Location ..
+Remove-Item $STAGE
+Set-Location $SRC_DIR
diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh
new file mode 100644
index 00000000..026dc289
--- /dev/null
+++ b/ci/before_deploy.sh
@@ -0,0 +1,33 @@
+# This script takes care of building your crate and packaging it for release
+
+set -ex
+
+main() {
+ local src=$(pwd) \
+ stage=
+
+ case $TRAVIS_OS_NAME in
+ linux)
+ stage=$(mktemp -d)
+ ;;
+ osx)
+ stage=$(mktemp -d -t tmp)
+ ;;
+ esac
+
+ test -f Cargo.lock || cargo generate-lockfile
+
+ # TODO Update this to build the artifacts that matter to you
+ cross rustc --bin hello --target $TARGET --release -- -C lto
+
+ # TODO Update this to package the right artifacts
+ cp target/$TARGET/release/hello $stage/
+
+ cd $stage
+ tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
+ cd $src
+
+ rm -rf $stage
+}
+
+main
diff --git a/ci/cargo-config b/ci/cargo-config
deleted file mode 100644
index 6fee5be7..00000000
--- a/ci/cargo-config
+++ /dev/null
@@ -1,18 +0,0 @@
-# Configuration of which linkers to call on Travis for various architectures
-[target.arm-linux-androideabi]
-linker = "arm-linux-androideabi-gcc"
-
-[target.arm-unknown-linux-gnueabihf]
-linker = "arm-linux-gnueabihf-gcc-4.7"
-
-[target.mips-unknown-linux-gnu]
-linker = "mips-linux-gnu-gcc-5"
-
-[target.mipsel-unknown-linux-gnu]
-linker = "mipsel-linux-gnu-gcc-5"
-
-[target.aarch64-unknown-linux-gnu]
-linker = "aarch64-linux-gnu-gcc-4.8"
-
-[target.powerpc-unknown-linux-gnu]
-linker = "powerpc-linux-gnu-gcc-4.8"
diff --git a/ci/install.sh b/ci/install.sh
new file mode 100644
index 00000000..4093c9b2
--- /dev/null
+++ b/ci/install.sh
@@ -0,0 +1,24 @@
+set -ex
+
+main() {
+ curl https://sh.rustup.rs -sSf | \
+ sh -s -- -y --default-toolchain $TRAVIS_RUST_VERSION
+
+ local target=
+ if [ $TRAVIS_OS_NAME = linux ]; then
+ target=x86_64-unknown-linux-gnu
+ else
+ target=x86_64-apple-darwin
+ fi
+
+ # TODO At some point you'll probably want to use a newer release of `cross`,
+ # simply change the argument to `--tag`.
+ curl -LSfs https://japaric.github.io/trust/install.sh | \
+ sh -s -- \
+ --force \
+ --git japaric/cross \
+ --tag v0.1.4 \
+ --target $target
+}
+
+main
diff --git a/ci/run-all.sh b/ci/run-all.sh
deleted file mode 100755
index a7d1ece9..00000000
--- a/ci/run-all.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-#
-# Build nix and all tests for as many versions and platforms as can be
-# managed. This requires docker.
-#
-
-set -e
-
-BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-RUN_DOCKER="${BASE_DIR}/ci/run-docker.sh"
-
-export RUST_VERSION=1.7.0
-
-export DOCKER_IMAGE=posborne/rust-cross:x86
-RUST_TARGET=i686-unknown-linux-gnu ${RUN_DOCKER}
-RUST_TARGET=x86_64-unknown-linux-gnu ${RUN_DOCKER}
-RUST_TARGET=x86_64-unknown-linux-musl ${RUN_DOCKER}
-
-export DOCKER_IMAGE=posborne/rust-cross:arm
-RUST_TARGET=aarch64-unknown-linux-gnu ${RUN_DOCKER}
-RUST_TARGET=arm-linux-gnueabi ${RUN_DOCKER}
-RUST_TARGET=arm-linux-gnueabihf ${RUN_DOCKER}
-
-export DOCKER_IMAGE=posborne/rust-cross:mips
-RUST_TARGET=mips-unknown-linux-gnu ${RUN_DOCKER}
-RUST_TARGET=mipsel-unknown-linux-gnu ${RUN_DOCKER}
-
-export DOCKER_IMAGE=posborne/rust-cross:android ${RUN_DOCKER}
-RUST_TARGET=arm-linux-androideabi ${RUN_DOCKER}
diff --git a/ci/run-docker.sh b/ci/run-docker.sh
deleted file mode 100755
index 3ef831c3..00000000
--- a/ci/run-docker.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-#
-# Run the nix tests in a docker container. This script expects the following
-# environment variables to be set:
-# - DOCKER_IMAGE : Docker image to use for testing (e.g. posborne/rust-cross:arm)
-# - RUST_VERSION : Rust Version to test against (e.g. 1.7.0)
-# - RUST_TARGET : Target Triple to test
-
-BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-
-docker run -i -t \
- -v ${BASE_DIR}:/source \
- -e CARGO_TARGET_DIR=/build \
- ${DOCKER_IMAGE} \
- /source/ci/run.sh ${RUST_VERSION} ${RUST_TARGET}
diff --git a/ci/run-travis.sh b/ci/run-travis.sh
deleted file mode 100644
index 5be6372e..00000000
--- a/ci/run-travis.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-#
-# Entry point for all travis builds, this will set up the Travis environment by
-# downloading any dependencies. It will then execute the `run.sh` script to
-# build and execute all tests.
-#
-# Much of this script was liberally stolen from rust-lang/libc
-#
-# Key variables that may be set from Travis:
-# - TRAVIS_RUST_VERSION: 1.1.0 ... stable/nightly/beta
-# - TRAVIS_OS_NAME: linux/osx
-# - DOCKER_IMAGE: posborne/rust-cross:arm
-# - TARGET: e.g. arm-unknown-linux-gnueabihf
-
-set -ex
-
-BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-
-if [ "$TRAVIS_OS_NAME" = "linux" ]; then
- OS=unknown-linux-gnu
-elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
- OS=apple-darwin
-else
- echo "Unexpected TRAVIS_OS_NAME: $TRAVIS_OS_NAME"
- exit 1
-fi
-
-export HOST=$ARCH-$OS
-if [ "$TARGET" = "" ]; then
- TARGET=$HOST
-fi
-
-if [ "$DOCKER_IMAGE" = "" ]; then
- export RUST_TEST_THREADS=1
- curl -sSL "https://raw.githubusercontent.com/carllerche/travis-rust-matrix/master/test" | bash
-else
- export RUST_VERSION=${TRAVIS_RUST_VERSION}
- export RUST_TARGET=${TARGET}
- export DOCKER_IMAGE=${DOCKER_IMAGE}
- ${BASE_DIR}/ci/run-docker.sh
-fi
diff --git a/ci/run.sh b/ci/run.sh
deleted file mode 100755
index 770f5aa7..00000000
--- a/ci/run.sh
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/bin/bash
-
-# Builds and runs tests for a particular target passed as an argument to this
-# script.
-
-set -e
-
-# This should only be run in a docker container, so verify that
-if [ ! $(pidof $0) = "1" ]; then
- echo "run.sh should only be executed in a docker container"
- echo "and that does not appear to be the case. Maybe you meant"
- echo "to execute the tests via run-all.sh or run-docker.sh."
- echo ""
- echo "For more instructions, please refer to ci/README.md"
- exit 1
-fi
-
-BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-MANIFEST_PATH="${BASE_DIR}/Cargo.toml"
-BUILD_DIR="."
-
-VERSION="$1"
-TARGET="$2"
-
-export DOCKER_ENVIRONMENT=1
-export RUST_TEST_THREADS=1
-export RUST_BACKTRACE=1
-
-#
-# Tell cargo what linker to use and whatever else is required
-#
-configure_cargo() {
- mkdir -p .cargo
- cp -b "${BASE_DIR}/ci/cargo-config" .cargo/config
-}
-
-#
-# We need to export CC for the tests to build properly (some C code is
-# compiled) to work. We already tell Cargo about the compiler in the
-# cargo config, so we just parse that info out of the cargo config
-#
-cc_for_target() {
- awk "/\[target\.${TARGET}\]/{getline; print}" .cargo/config |
- cut -d '=' -f2 | \
- tr -d '"' | tr -d ' '
-}
-
-cross_compile_tests() {
- case "$TARGET" in
- *-apple-ios)
- cargo test --no-run --manifest-path="${MANIFEST_PATH}" --target "$TARGET" -- \
- -C link-args=-mios-simulator-version-min=7.0
- ;;
-
- *)
- cargo test --no-run --verbose \
- --manifest-path="${MANIFEST_PATH}" \
- --target "$TARGET"
- ;;
- esac
-}
-
-# This is a hack as we cannot currently
-# ask cargo what test files it generated:
-# https://github.com/rust-lang/cargo/issues/1924
-find_binaries() {
- target_base_dir="${BUILD_DIR}/${TARGET}/debug"
-
- # find [[test]] sections and print the first line and
- # hack it to what we want from there. Also "nix" for
- # tests that are implicitly prsent
- for test_base in $( awk '/\[\[test\]\]/{getline; print}' "${MANIFEST_PATH}" | \
- cut -d '=' -f2 | \
- tr -d '"' | \
- tr '-' '_' | \
- tr -d ' '; echo "nix" ); do
- for path in ${target_base_dir}/${test_base}-* ; do
- echo "${path} "
- done
- done
-}
-
-test_binary() {
- binary=$1
-
- case "$TARGET" in
- arm-linux-gnueabi-gcc)
- qemu-arm -L /usr/arm-linux-gnueabihf "$binary"
- ;;
-
- arm-unknown-linux-gnueabihf)
- qemu-arm -L /usr/arm-linux-gnueabihf "$binary"
- ;;
-
- mips-unknown-linux-gnu)
- qemu-mips -L /usr/mips-linux-gnu "$binary"
- ;;
-
- aarch64-unknown-linux-gnu)
- qemu-aarch64 -L /usr/aarch64-linux-gnu "$binary"
- ;;
-
- *-rumprun-netbsd)
- rumprun-bake hw_virtio /tmp/nix-test.img "${binary}"
- qemu-system-x86_64 -nographic -vga none -m 64 \
- -kernel /tmp/nix-test.img 2>&1 | tee /tmp/out &
- sleep 5
- grep "^PASSED .* tests" /tmp/out
- ;;
-
- *)
- echo "Running binary: ${binary}"
- ${binary}
- ;;
- esac
-}
-
-echo "======================================================="
-echo "TESTING VERSION: ${VERSION}, TARGET: ${TARGET}"
-echo "======================================================="
-
-configure_cargo
-export CC="$(cc_for_target)"
-if [ "${CC}" = "" ]; then
- unset CC
-fi
-
-# select the proper version
-multirust override ${VERSION}
-
-# build the tests
-cross_compile_tests
-
-# and run the tests
-for bin in $(find_binaries); do
- test_binary "${bin}"
-done
diff --git a/ci/script.sh b/ci/script.sh
new file mode 100644
index 00000000..39c3aeec
--- /dev/null
+++ b/ci/script.sh
@@ -0,0 +1,22 @@
+# This script takes care of testing your crate
+
+set -ex
+
+main() {
+ # Build debug and release targets
+ cross build --target $TARGET
+ cross build --target $TARGET --release
+
+ if [ ! -z $DISABLE_TESTS ]; then
+ return
+ fi
+
+ # Run tests on debug and release targets.
+ cross test --target $TARGET
+ cross test --target $TARGET --release
+}
+
+# we don't run the "test phase" when doing deploys
+if [ -z $TRAVIS_TAG ]; then
+ main
+fi