Skip to content

Commit

Permalink
Update .travis.yml and bin/ci to match definitions in master. Related…
Browse files Browse the repository at this point in the history
… to #2944
  • Loading branch information
Ary Borenszweig committed Jul 3, 2016
1 parent 6d21db7 commit 68783f1
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 9 deletions.
20 changes: 12 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ matrix:
include:
- env: ARCH=i386 ARCH_CMD=linux32
os: linux
- env: ARCH=x86_64 ARCH_CMD=linux64
- env: ARCH=x86_64 ARCH_CMD=linux64 DEPLOY=true
os: linux
- os: osx
- os: osx
osx_image: xcode7.3
before_install: bin/ci prepare_system
install: bin/ci prepare_build
before_install:
- bin/ci prepare_system
install:
- bin/ci prepare_build
script:
- bin/ci with_build_env 'make std_spec clean'
- bin/ci with_build_env 'make crystal std_spec compiler_spec doc'
- bin/ci with_build_env 'find samples -name "*.cr" | xargs -L 1 ./bin/crystal build --no-codegen'
- bin/ci with_build_env './bin/crystal tool format --check'
- bin/ci build
after_success:
- bin/ci deploy
branches:
only:
- master
- gh-pages
- /\Arelease\/.+\z/
notifications:
irc:
Expand All @@ -34,3 +34,7 @@ notifications:
- "%{repository_slug}#%{commit} (%{branch} - %{commit_subject}): %{message} %{build_url}"
slack:
secure: Ng3nTqGWY+9p1pS6yjGqDhmRvdgbIZgTNpMWbO/ngwpCyicmD3jafZkShqqXbULZTJJr3OxIGzi6GHGusT0Ic/Pi9JCM3X3v/xuBruKIR+EnNyPo7IL4ZYAlwnXyJHlCHHDBq0gSHGvGJwsXn6IgZBPRfeIq+CCyQHVPyvc9EHE=
env:
global:
- AWS_ACCESS_KEY_ID=AKIAIRL4BWFPN7P54TBQ
- secure: Zd/tZVmV2dRMao9z+ky5BywSKuWOF3MiKsZetwd1upZ+uj9qzfbOZMnWFW9dlA+Co4MyYqP/I6ADzRpoKLINUqEIPcAPNYQB1qG79SafrRAvTqcjtEHTn2wXh2ZGu3f1T+SCK0ZD3xx1ML8502ENzXjvq+dEmi4kknqmPudkb6k=
95 changes: 94 additions & 1 deletion bin/ci
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ fail() {
exit 1
}

on_deploy() {
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
if [ "${DEPLOY}" = "true" ]; then
echo "${@}"
eval "${@}"
return $?
else
return 0
fi
fi
}

on_tag() {
if [ -n "$CURRENT_TAG" ]; then
echo "${@}"
eval "${@}"
return $?
else
return 0
fi
}

fail_on_error() {
"${@}"

Expand Down Expand Up @@ -57,6 +79,69 @@ on_osx() {

prepare_system() {
on_osx brew update
on_deploy sudo pip install awscli
}

build() {
with_build_env 'make std_spec clean'
with_build_env 'make crystal std_spec compiler_spec doc'
with_build_env 'find samples -name "*.cr" | xargs -L 1 ./bin/crystal compile --no-codegen'
with_build_env './bin/crystal tool format --check'
}

deploy() {
export CURRENT_TAG=`git describe --tags --exact-match 2> /dev/null`
export GIT_VERSION=`git describe --tags --long --always 2>/dev/null`
on_deploy 'echo $GIT_VERSION > doc/revision.txt'

on_deploy aws s3 sync doc/ s3://crystal-api/api/$TRAVIS_BRANCH

on_deploy on_tag aws s3 sync doc/ s3://crystal-api/api/$CURRENT_TAG
cat - > .aws-config <<EOF
{
"IndexDocument": {
"Suffix": "index.html"
},
"RoutingRules": [
{
"Condition": {
"KeyPrefixEquals": "api/latest/${CURRENT_TAG}/"
},
"Redirect": {
"HttpRedirectCode": "302",
"ReplaceKeyWith": "404",
"Protocol": "https",
"HostName": "crystal-lang.org"
}
},
{
"Condition": {
"KeyPrefixEquals": "api/latest/"
},
"Redirect": {
"HttpRedirectCode": "302",
"ReplaceKeyPrefixWith": "api/${CURRENT_TAG}/",
"Protocol": "https",
"HostName": "crystal-lang.org"
}
},
{
"Condition": {
"KeyPrefixEquals": "api/",
"HttpErrorCodeReturnedEquals": "404"
},
"Redirect": {
"HttpRedirectCode": "301",
"ReplaceKeyPrefixWith": "api/latest/",
"Protocol": "https",
"HostName": "crystal-lang.org"
}
}
]
}
EOF
on_deploy on_tag cat .aws-config
on_deploy on_tag aws s3api put-bucket-website --bucket crystal-api --website-configuration file://.aws-config
}

prepare_build() {
Expand Down Expand Up @@ -98,6 +183,8 @@ usage() {
echo -e "Commands:"
echo -e " prepare_system setup any necessaries repositories etc."
echo -e " prepare_build download and extract any dependencies needed for the build"
echo -e " build run specs, build crystal, run format check, build samples, build the docs"
echo -e " deploy deploy the docs"
echo -e " with_build_env command run command in the build environment"
echo -e " help display this"
echo -e ""
Expand All @@ -116,6 +203,12 @@ case $command in
target_command="${@}"
with_build_env "$target_command"
;;
build)
build
;;
deploy)
deploy
;;
-h|--help|help)
usage
;;
Expand All @@ -127,4 +220,4 @@ case $command in
exit 1
fi
;;
esac
esac

0 comments on commit 68783f1

Please sign in to comment.