Skip to content

Commit

Permalink
chore: add continous integration
Browse files Browse the repository at this point in the history
  • Loading branch information
darfink committed Jun 13, 2017
1 parent 0afcba9 commit f9a24d6
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 2 deletions.
55 changes: 55 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Based on the "trust" template v0.1.1
# https://github.com/japaric/trust/tree/v0.1.1

dist: trusty
language: rust
services: docker
sudo: required

env:
global:
- CRATE_NAME=detour

matrix:
include:
# Linux
- env: TARGET=i686-unknown-linux-gnu
rust: nightly
- env: TARGET=x86_64-unknown-linux-gnu
rust: nightly

# OSX
- env: TARGET=i686-apple-darwin
os: osx
rust: nightly
- env: TARGET=x86_64-apple-darwin
os: osx
rust: nightly

before_install: set -e

install:
- sh ci/install.sh
- source ~/.cargo/env || true

script:
- bash ci/script.sh

after_script: set +e

deploy: off

cache: cargo
before_cache:
# Travis can't cache files that are not readable by "others"
- chmod -R a+r $HOME/.cargo

branches:
only:
# release tags
- /^v\d+\.\d+\.\d+.*$/
- master

notifications:
email:
on_success: never
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn basics() {
// nop
// ...
```
*Functions such as this one (lacking a hot-patching area), and too small to
*Functions such as this one, lacking a hot-patching area, and too small to
be hooked with a 5-byte `jmp`, are supported thanks to the detection of
code padding (`NOP/INT3` instructions). Therefore the required amount of
`NOP` instructions will be replaced, to make room for the detour.*
trailing `NOP` instructions will be replaced, to make room for the detour.*
57 changes: 57 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Based on the "trust" template v0.1.1
# https://github.com/japaric/trust/tree/v0.1.1

environment:
global:
RUST_VERSION: nightly
CRATE_NAME: region
matrix:
# MinGW
- TARGET: i686-pc-windows-gnu
- TARGET: x86_64-pc-windows-gnu

# MSVC
- TARGET: i686-pc-windows-msvc
- TARGET: x86_64-pc-windows-msvc

install:
- ps: >-
If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw64\bin'
} ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw32\bin'
}
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
- rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -Vv
- cargo -V

# This is the "test phase"
test_script:
# Don't run the "test phase" when doing deploys
- if [%APPVEYOR_REPO_TAG%]==[false] (
cargo build --target %TARGET% &&
cargo build --target %TARGET% --release &&
cargo test --target %TARGET% &&
cargo test --target %TARGET% --release
)

deploy: off

cache:
- C:\Users\appveyor\.cargo\registry
- target

branches:
only:
# Release tags
- /^v\d+\.\d+\.\d+.*$/
- master

notifications:
- provider: Email
on_build_success: false

# Building is done in the test phase, so we disable Appveyor's build phase.
build: false
27 changes: 27 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set -ex

main() {
local target=
if [ $TRAVIS_OS_NAME = linux ]; then
target=x86_64-unknown-linux-musl
sort=sort
else
target=x86_64-apple-darwin
sort=gsort # for `sort --sort-version`, from brew's coreutils.
fi

# This fetches latest stable release
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
| cut -d/ -f3 \
| grep -E '^v[0.1.0-9.]+$' \
| $sort --version-sort \
| tail -n1)
curl -LSfs https://japaric.github.io/trust/install.sh | \
sh -s -- \
--force \
--git japaric/cross \
--tag $tag \
--target $target
}

main
20 changes: 20 additions & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This script takes care of testing your crate

set -ex

main() {
cross build --target $TARGET
cross build --target $TARGET --release

if [ ! -z $DISABLE_TESTS ]; then
return
fi

cross test --target $TARGET
cross test --target $TARGET --release
}

# Don't run the "test phase" when doing deploys
if [ -z $TRAVIS_TAG ]; then
main
fi

0 comments on commit f9a24d6

Please sign in to comment.