Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: use a script travis-ci.sh to simplify .travis.yml #1063

Merged
merged 2 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 5 additions & 66 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,10 @@
language: c
env:
- TO_TEST=changes
- TO_TEST=build OCAML_VERSION=4.07.1
- TO_TEST=build OCAML_VERSION=4.08.1
- TO_TEST=tests OCAML_VERSION=4.09.0
- CI_KIND=changes
- CI_KIND=build OCAML_VERSION=4.07.1
- CI_KIND=build OCAML_VERSION=4.08.1
- CI_KIND=build-and-tests OCAML_VERSION=4.09.0
cache:
directories:
- ${HOME}/.opam
before_install:
- |
case "$TO_TEST" in
build|tests)
wget -O ${HOME}/opam https://github.com/ocaml/opam/releases/download/2.0.5/opam-2.0.5-x86_64-linux
chmod +x ${HOME}/opam
export PATH=${HOME}:${PATH}
export OPAMYES=1
export OPAMJOBS=2
opam init --bare --disable-sandboxing
opam switch --dry-run ${OCAML_VERSION} 2>/dev/null || opam switch create ${OCAML_VERSION}
;;
changes)
;;
*)
echo "unknown CI kind"
exit 1
;;
esac
install:
- |
case "$TO_TEST" in
build|tests)
opam switch ${OCAML_VERSION}
opam update --upgrade
opam pin add --no-action ocamlformat .
opam install --deps-only ocamlformat
;;
changes)
;;
*)
echo "unknown CI kind"
exit 1
;;
esac
script:
- |
case "$TO_TEST" in
changes)
if [ "$TRAVIS_PULL_REQUEST" != false ] && [ "$TRAVIS_BRANCH" = master ]; then
! git diff --exit-code "$TRAVIS_BRANCH...$TRAVIS_COMMIT" -- CHANGES.md >/dev/null;
fi
;;
build)
opam pin add --no-action ocamlformat .
opam install --deps-only ocamlformat
opam switch ${OCAML_VERSION}
opam exec -- make
opam install ocamlformat
;;
tests)
opam pin add --no-action ocamlformat .
opam install --deps-only ocamlformat
opam switch ${OCAML_VERSION}
opam exec -- make test
opam install ocamlformat
;;
*)
echo "unknown CI kind"
exit 1
;;
esac
script: tools/travis-ci.sh
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### (master)

+ CI: use a script travis-ci.sh to simplify .travis.yml (#1063) (Guillaume Petiot)
+ Improve: allow both values of boolean options (#1062) (Jules Aguillon)
+ Improve: auto mode for break-string-literals instead of {wrap,newlines,newlines-and-wrap} (#1057) (Guillaume Petiot)
+ Improve: remove utility functions from Fmt_ast (#1059) (Guillaume Petiot)
Expand Down
78 changes: 78 additions & 0 deletions tools/travis-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash

######################################################################
# #
# OCamlFormat #
# #
# Copyright (c) 2019-present, Facebook, Inc. All rights reserved. #
# #
# This source code is licensed under the MIT license found in the #
# LICENSE file in the root directory of this source tree. #
# #
######################################################################

# Warning: this script should only be called from .travis.yml

set -e

CheckBuild () {
# before_install
wget -O ${HOME}/opam https://github.com/ocaml/opam/releases/download/2.0.5/opam-2.0.5-x86_64-linux
chmod +x ${HOME}/opam
export PATH=${HOME}:${PATH}
export OPAMYES=1
export OPAMJOBS=2
opam init --bare --disable-sandboxing
opam switch --dry-run ${OCAML_VERSION} 2>/dev/null || opam switch create ${OCAML_VERSION}
# install
opam switch ${OCAML_VERSION}
opam update --upgrade
opam pin add --no-action ocamlformat .
opam install --deps-only ocamlformat
# script
opam exec -- make
opam install ocamlformat
}

CheckBuildAndTests () {
# before_install
wget -O ${HOME}/opam https://github.com/ocaml/opam/releases/download/2.0.5/opam-2.0.5-x86_64-linux
chmod +x ${HOME}/opam
export PATH=${HOME}:${PATH}
export OPAMYES=1
export OPAMJOBS=2
opam init --bare --disable-sandboxing
opam switch --dry-run ${OCAML_VERSION} 2>/dev/null || opam switch create ${OCAML_VERSION}
# install
opam switch ${OCAML_VERSION}
opam update --upgrade
opam pin add --no-action ocamlformat .
opam install --deps-only ocamlformat
# script
opam exec -- make test
opam install ocamlformat
}

CheckChangesModified () {
if [ "$TRAVIS_PULL_REQUEST" != false ] && [ "$TRAVIS_BRANCH" = master ]
then
git diff --exit-code "$TRAVIS_BRANCH...$TRAVIS_COMMIT" -- CHANGES.md \
> /dev/null && exit 1 || echo pass
fi
}

case $CI_KIND in
build)
CheckBuild
;;
build-and-tests)
CheckBuildAndTests
;;
changes)
CheckChangesModified
;;
*)
echo unknown CI kind
exit 1
;;
esac