Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
CryZe committed Mar 23, 2017
1 parent ffe5813 commit 91a494a
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 15 deletions.
105 changes: 105 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# 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

# TODO Rust builds on stable by default, this can be
# overridden on a case by case basis down below.
# rust: stable not specified in order to avoid making
# a default job.

env:
global:
# TODO Update this to match the name of your project.
- CRATE_NAME=livesplit-core

matrix:
# TODO These are all the build jobs. Adjust as necessary. Comment out what you
# don't need
include:
# Linux
- env: TARGET=i686-unknown-linux-gnu
- env: TARGET=i686-unknown-linux-musl
- env: TARGET=x86_64-unknown-linux-gnu
- env: TARGET=x86_64-unknown-linux-musl

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

# *BSD
- env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1
- env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
- env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1

# Other architectures
- env: TARGET=aarch64-unknown-linux-gnu
- env: TARGET=armv7-unknown-linux-gnueabihf
- env: TARGET=mips-unknown-linux-gnu
- env: TARGET=mips64-unknown-linux-gnuabi64
- env: TARGET=mips64el-unknown-linux-gnuabi64
- env: TARGET=mipsel-unknown-linux-gnu
- env: TARGET=powerpc-unknown-linux-gnu
- env: TARGET=powerpc64-unknown-linux-gnu
- env: TARGET=powerpc64le-unknown-linux-gnu
- env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1

# Testing other channels
- env: TARGET=x86_64-unknown-linux-gnu
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

before_deploy:
- sh ci/before_deploy.sh

deploy:
# TODO update `api_key.secure`
# - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new
# - Encrypt it: `travis encrypt YOUR_TOKEN`
# - Paste the output down here
api_key:
secure: "pKwa9SjJVenEk2MwFh3pVv6MO+Z//Ng4RG6ZvMxHDsfuElFpU6obMs6dvK0tUFNBQMayXxMhJMKz2ZD+eiOtyOmJY218QxsfkyqazwakvXLasrGtKtyp7pzkNHaiE8o73Mr+9MudUiqWIg8y+X1lTV1A5GN+i1jprGZip0RV+qHeZtpNkYjX/99+Xh5Z/Wp9rCcxO+flyWjbpA151Bqx/QX88usCpIXEH9uJOHjQd/VHuPQoxOw6RiyAleF1EfHfor+/0uHbHNHjulm4U5hCjAoQGm0RppA1rMBg5y36lXLg5Ophz+PREzJl6Xj9rW2ExPRkHYqrkmfUKAjNeJQVNnN1xu84ngND5YRUzsDBk1t3XDvY1DSdqosSsjSZ99XvJrrbTFoF12WpKBKFCaTQHp26Fn5oNh9I/ZNW7I9Jzqga2PubxCiSR9L2DtCaw5Y2nKFn54+VMF4U4pa6fnCsw2o72qTFkpLwba+oFnrUT+dXoUpvPMcBeZSb4HuV0LKfkN2e3WHPZKRbJAFfmjVVJ083HYIpp7lohBKFNMtbrcXNdAtD0y2xb+SlzKo/ZIQnTJw3lW5+n4PCzso1OlIwUiEx0ZN2V3jHC6ZOrqMNdnFn3NZq4aOBzQdi493gPnhIiJlyywEn93UXTyTXirpsNL99GlUo3iX6nbh8LbgAjQY="
file_glob: true
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
on:
# TODO Here you can pick which targets will generate binary releases
# In this example, there are some targets that are tested using the stable
# and nightly channels. This condition makes sure there is only one release
# for such targets and that's generated using the stable channel
condition: $TRAVIS_RUST_VERSION = stable
tags: true
provider: releases
skip_cleanup: true

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
36 changes: 22 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "livesplit-core"
version = "0.1.0"
authors = ["Christopher Serr <[email protected]>"]

[workspace]
members = ["capi"]

[dependencies]
chrono = { version = "0.3.0", features = ["serde"] }
odds = "0.2.25"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# livesplit-core

[![Build Status](https://travis-ci.org/CryZe/livesplit-core.svg?branch=master)](https://travis-ci.org/CryZe/livesplit-core)
[![Build status](https://ci.appveyor.com/api/projects/status/bvv4un099w94kari/branch/master?svg=true)](https://ci.appveyor.com/project/CryZe/livesplit-core/branch/master)

Rust Port of LiveSplit's core logic
87 changes: 87 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Based on the "trust" template v0.1.1
# https://github.com/japaric/trust/tree/v0.1.1

environment:
global:
# TODO This is the Rust channel that build jobs will use by default but can be
# overridden on a case by case basis down below
RUST_VERSION: stable

# TODO Update this to match the name of your project.
CRATE_NAME: livesplit-core

# TODO These are all the build jobs. Adjust as necessary. Comment out what you
# don't need
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

# Testing other channels
- TARGET: x86_64-pc-windows-gnu
RUST_VERSION: nightly
- TARGET: x86_64-pc-windows-msvc
RUST_VERSION: nightly

install:
- ps: >-
choco install curl
- 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

# TODO This is the "test phase", tweak it as you see fit
test_script:
# we don't run the "test phase" when doing deploys
- if [%APPVEYOR_REPO_TAG%]==[false] (
cargo build -p livesplit-core-capi --target %TARGET% &&
cargo build -p livesplit-core-capi --target %TARGET% --release &&
cargo test -p livesplit-core-capi --target %TARGET% &&
cargo test -p livesplit-core-capi --target %TARGET% --release
)

before_deploy:
# TODO Update this to build the artifacts that matter to you
- cargo rustc -p livesplit-core-capi --target %TARGET% --release -- -C lto
- ps: ci\before_deploy.ps1

deploy:
artifact: /.*\.zip/
# TODO update `auth_token.secure`
# - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new
# - Encrypt it. Go to https://ci.appveyor.com/tools/encrypt
# - Paste the output down here
auth_token:
secure: zZGfrpCR/0TmHcXPwar4hOx6pZeq3C9Wwf/g62pvf135tAwJIVpuZHJjB0sAAd2M
description: ''
on:
# TODO Here you can pick which targets will generate binary releases
# In this example, there are some targets that are tested using the stable
# and nightly channels. This condition makes sure there is only one release
# for such targets and that's generated using the stable channel
RUST_VERSION: stable
appveyor_repo_tag: true
provider: GitHub

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

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

notifications:
- provider: Email
on_build_success: false

# disable automatic builds
build: false
2 changes: 1 addition & 1 deletion capi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ livesplit-core = { path = ".." }
libc = "0.2.18"

[lib]
crate-type = ["cdylib", "rlib", "staticlib"]
crate-type = ["cdylib", "staticlib"]

[profile.release]
panic = 'abort'
24 changes: 24 additions & 0 deletions ci/before_deploy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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\livesplit_core_capi.dll" '.\'
Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\livesplit_core_capi.lib" '.\'

7z a "$ZIP" *

Push-AppveyorArtifact "$ZIP"

Remove-Item *.* -Force
Set-Location ..
Remove-Item $STAGE
Set-Location $SRC_DIR
33 changes: 33 additions & 0 deletions ci/before_deploy.sh
Original file line number Diff line number Diff line change
@@ -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 -p livesplit-core-capi --target $TARGET --release -- -C lto

# TODO Update this to package the right artifacts
cp target/$TARGET/release/*livesplit_core_capi* $stage/

cd $stage
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
cd $src

rm -rf $stage
}

main
31 changes: 31 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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
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-9.]+$' \
| $sort --version-sort \
| tail -n1)
echo cross version: $tag
curl -LSfs https://japaric.github.io/trust/install.sh | \
sh -s -- \
--force \
--git japaric/cross \
--tag $tag \
--target $target
}

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

set -ex

# TODO This is the "test phase", tweak it as you see fit
main() {
cross build -p livesplit-core-capi --target $TARGET
cross build -p livesplit-core-capi --target $TARGET --release

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

cross test -p livesplit-core-capi --target $TARGET
cross test -p livesplit-core-capi --target $TARGET --release

# cross run --target $TARGET
# cross run --target $TARGET --release
}

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

0 comments on commit 91a494a

Please sign in to comment.