diff --git a/.travis.yml b/.travis.yml index 3ec694db1..8a1105cd4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,154 +1,167 @@ +# Based on the "trust" template v0.1.1 +# https://github.com/japaric/trust/tree/v0.1.1 + +dist: trusty language: rust -cache: cargo +services: docker +sudo: required + +# TODO Rust builds on stable by default, this can be +# overridden on a case by case basis down below. env: global: - - PROJECT_NAME=tokei + - CRATE_NAME=tokei - MAKE_DEB=yes - DEB_MAINTAINER="Aaron Power " - DEB_DESCRIPTION="A utility that allows you to count code, quickly." -# AFAICT There are a few ways to set up the build jobs. This one is not the -# DRYest but I feel is the easiest to reason about. -# TODO Feel free to remove the channels/targets you don't need -# NOTE Make *sure* you don't remove a reference (&foo) if you are going to dereference it (*foo) matrix: + # TODO These are all the build jobs. Adjust as necessary. Comment out what you + # don't need include: - # Stable channel - - os: osx - rust: stable - env: TARGET=i686-apple-darwin - - os: linux - rust: stable - env: TARGET=i686-unknown-linux-gnu - addons: - apt: - packages: &i686_unknown_linux_gnu - # Cross compiler and cross compiled C libraries - - gcc-multilib - - os: linux - rust: stable - env: TARGET=i686-unknown-linux-musl - dist: trusty - sudo: required - addons: - apt: - packages: &musl_packages - - musl - - musl-dev - - musl-tools - - os: osx - rust: stable - env: TARGET=x86_64-apple-darwin - - os: linux - rust: stable - env: TARGET=x86_64-unknown-linux-gnu - - os: linux - rust: stable - env: TARGET=x86_64-unknown-linux-musl - dist: trusty - sudo: required - addons: - apt: - packages: *musl_packages + # 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 # Beta channel - - os: osx + - env: TARGET=i686-apple-darwin + os: osx rust: beta - env: TARGET=i686-apple-darwin - - os: linux + - env: TARGET=i686-unknown-linux-gnu + os: linux rust: beta - env: TARGET=i686-unknown-linux-gnu addons: apt: packages: *i686_unknown_linux_gnu - - os: linux + - env: TARGET=i686-unknown-linux-musl + os: linux rust: beta - env: TARGET=i686-unknown-linux-musl dist: trusty sudo: required addons: apt: packages: *musl_packages - - os: osx + - env: TARGET=x86_64-apple-darwin + os: osx rust: beta - env: TARGET=x86_64-apple-darwin - - os: linux + - env: TARGET=x86_64-unknown-linux-gnu + os: linux rust: beta - env: TARGET=x86_64-unknown-linux-gnu - - os: linux + - env: TARGET=x86_64-unknown-linux-musl + os: linux rust: beta - env: TARGET=x86_64-unknown-linux-musl dist: trusty sudo: required addons: apt: packages: *musl_packages # Nightly channel - - os: osx + - env: TARGET=i686-apple-darwin + os: osx rust: nightly - env: TARGET=i686-apple-darwin - - os: linux + - env: TARGET=i686-unknown-linux-gnu + os: linux rust: nightly - env: TARGET=i686-unknown-linux-gnu addons: apt: packages: *i686_unknown_linux_gnu - - os: linux + - env: TARGET=i686-unknown-linux-musl + os: linux rust: nightly - env: TARGET=i686-unknown-linux-musl dist: trusty sudo: required addons: apt: packages: *musl_packages - - os: osx + - env: TARGET=x86_64-apple-darwin + os: osx rust: nightly - env: TARGET=x86_64-apple-darwin - - os: linux + - env: TARGET=x86_64-unknown-linux-gnu + os: linux rust: nightly - env: TARGET=x86_64-unknown-linux-gnu - - os: linux + - env: TARGET=x86_64-unknown-linux-musl + os: linux rust: nightly - env: TARGET=x86_64-unknown-linux-musl dist: trusty sudo: required addons: apt: packages: *musl_packages + + allow_failures: - - rust: nightly -before_install: - - export PATH="$PATH:$HOME/.cargo/bin" + - rust: nightly + +before_install: set -e install: - - bash ci/install.sh + - sh ci/install.sh + - source ~/.cargo/env || true script: - bash ci/script.sh +after_script: set +e + before_deploy: - - bash ci/before_deploy.sh + - sh ci/before_deploy.sh deploy: - provider: releases + # TODO update `api_key.secure` + # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new + # - Encrypt it: `travis encrypt 0123456789012345678901234567890123456789 + # - Paste the output down here api_key: secure: JAWZDa7izxqh/013aqxwSxhu4wndJfvQWngA/DMutC5J5ZTUEmA0UJG+VGCVcMVZOBu/IUy6tRmz3IgEqgW74FLc4UuBRH3RdInp+dpjUc2yTuUltOuT+skn5LGQXi+m8VeIxRS0PXCsN5twpOfSi0uuKu+UzMN9ZOX9wEy1svRlAUJdcT37LfvlS/lnxHoF+WuakZfFsP0QCrgI7uBY83X+wT6YAixiywzadKMqXDSNlJ7m0t9pJ1FsR0BgnoYiTI/L/3P3FDJCDzShujlU9P3xLvirV4/HB9NPG+IhuhTSCpBE8UIzCourAi6AgG3wdQGiR9S9QdwEuF3Y5Ya5l2tkJpqrk8FkBMVkH57m9iGV0j4mHDOvaRzMiPyYeuTTPKgbSWAvLOGouVRDP0SrZGjjcCvKSN4LVgO83uLjsg2XtdFoA89s/pNLsY2e07trT6jVm12P9uKdLWqkHdLJdGG4448aL8cIXntlCIHujpSmSikGtlGZZB6cvfkZQn/ZLhBxiGyk8n2V5hpqFml/tk6QDxyY04gSd1t/9aebOZmAGFYP0aufJpQe1GW13PQSdIQL6MZPtsk88OgP6EqUOSBCIAWuBd0cLds1SE+TELPyAPHWx5Z/y+mUEx4NoxRWWzNbQxOaMfXtLhE+xp7gdJYH7QtldagYz79UX/8wYbo= file_glob: true - file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.* - # don't delete the artifacts from previous phases - skip_cleanup: true - # deploy when a new tag is pushed + 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: - # Pushes and PR to the master branch - - master - # IMPORTANT Ruby regex to match tags. Required, or travis won't trigger deploys when a new tag - # is pushed. This regex matches semantic versions like v1.2.3-rc4+2016.02.22 + # release tags - /^v\d+\.\d+\.\d+.*$/ + - master notifications: email: diff --git a/appveyor.yml b/appveyor.yml index 9ec65145e..0af96d27c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,66 +1,114 @@ +# Based on the "trust" template v0.1.1 +# https://github.com/japaric/trust/tree/v0.1.1 + environment: global: - PROJECT_NAME: tokei + # 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: tokei + + # TODO These are all the build jobs. Adjust as necessary. Comment out what you + # don't need matrix: - # Stable channel + # MinGW - TARGET: i686-pc-windows-gnu - CHANNEL: stable + - TARGET: x86_64-pc-windows-gnu + + # MSVC - TARGET: i686-pc-windows-msvc - CHANNEL: stable + - TARGET: x86_64-pc-windows-msvc + + # Testing other channels + # Beta channel + - TARGET: i686-pc-windows-gnu + RUST_VERSION: beta - TARGET: x86_64-pc-windows-gnu - CHANNEL: stable + RUST_VERSION: beta + + - TARGET: i686-pc-windows-msvc + RUST_VERSION: beta - TARGET: x86_64-pc-windows-msvc - CHANNEL: stable + RUST_VERSION: beta + + # Nightly channel + - TARGET: i686-pc-windows-gnu + RUST_VERSION: nightly + - TARGET: x86_64-pc-windows-gnu + RUST_VERSION: nightly + + - TARGET: i686-pc-windows-msvc + RUST_VERSION: nightly + - TARGET: x86_64-pc-windows-msvc + RUST_VERSION: nightly + +matrix: + allow_failures: + - RUST_VERSION: nightly -# Install Rust and Cargo -# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml) install: - - curl -sSf -o rustup-init.exe https://win.rustup.rs - - rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y + - 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 -# 'cargo test' takes care of building for us, so disable Appveyor's build stage. -# This prevents -# the "directory does not contain a project or solution file" error. -# source: https://github.com/starkat99/appveyor-rust/blob/master/appveyor.yml#L113 -build: false - -# Equivalent to Travis' `script` phase +# TODO This is the "test phase", tweak it as you see fit test_script: - - cargo build --verbose - - cargo test - - cargo build --verbose --features=all - - cargo test --features=all + # we 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 && + cargo run --target %TARGET% && + cargo run --target %TARGET% --release + ) before_deploy: - # Generate artifacts for release - - cargo build --release --features=all - - mkdir staging - - copy target\release\tokei.exe staging - - cd staging - # release zipfile will look like 'rust-everywhere-v1.2.3-x86_64-pc-windows-msvc' - - 7z a ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip * - - appveyor PushArtifact ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip + # TODO Update this to build the artifacts that matter to you + - cargo rustc --target %TARGET% --release --bin tokei -- -C lto + - ps: ci\before_deploy.ps1 deploy: - description: 'Automatically deployed release' - # All the zipped artifacts will be deployed 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: BFuC1XGTw6ZIBQijzOLnKcYQPUdRuB+OfumTR9Hkosc5XOw1TvIYxlbR0hIS58RK - provider: GitHub - # deploy when a new tag is pushed and only on the stable channel + description: '' on: - # channel to use to produce the release artifacts - # NOTE make sure you only release *once* per target - CHANNEL: stable + # 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: - - master - # IMPORTANT Regex to match tags. Required, or appveyor may not trigger deploys when a new tag - # is pushed. This regex matches semantic versions like v1.2.3-rc4+2016.02.22 + # 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 diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 new file mode 100644 index 000000000..64ca6aa8a --- /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\tokei.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 index aae775b26..969257e65 100644 --- a/ci/before_deploy.sh +++ b/ci/before_deploy.sh @@ -1,65 +1,33 @@ -# `before_deploy` phase: here we package the build artifacts +# This script takes care of building your crate and packaging it for release set -ex -. $(dirname $0)/utils.sh - -# Generate artifacts for release -mk_artifacts() { - cargo build --target $TARGET --release --features all -} - -mk_tarball() { - # create a "staging" directory - local td=$(mktempd) - local out_dir=$(pwd) - - cp target/$TARGET/release/tokei $td - - pushd $td - - # release tarball will look like 'rust-everywhere-v1.2.3-x86_64-unknown-linux-gnu.tar.gz' - tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz * +main() { + local src=$(pwd) \ + stage= - popd - rm -r $td -} + case $TRAVIS_OS_NAME in + linux) + stage=$(mktemp -d) + ;; + osx) + stage=$(mktemp -d -t tmp) + ;; + esac -# Package your artifacts in a .deb file -# NOTE right now you can only package binaries using the `dobin` command. Simply call -# `dobin [file..]` to include one or more binaries in your .deb package. I'll add more commands to -# install other things like manpages (`doman`) as the needs arise. -# XXX This .deb packaging is minimal -- just to make your app installable via `dpkg` -- and doesn't -# fully conform to Debian packaging guideliens (`lintian` raises a few warnings/errors) -mk_deb() { - dobin target/$TARGET/release/tokei -} - -main() { - mk_artifacts - mk_tarball + test -f Cargo.lock || cargo generate-lockfile - if [ $TRAVIS_OS_NAME = linux ]; then - if [ ! -z $MAKE_DEB ]; then - dtd=$(mktempd) - mkdir -p $dtd/debian/usr/bin + # TODO Update this to build the artifacts that matter to you + cross rustc --bin tokei --target $TARGET --release -- -C lto - mk_deb + # TODO Update this to package the right artifacts + cp target/$TARGET/release/tokei $stage/ - mkdir -p $dtd/debian/DEBIAN - cat >$dtd/debian/DEBIAN/control <>.cargo/config </dev/null || mktemp -d -t tmp) -} - -host() { - case "$TRAVIS_OS_NAME" in - linux) - echo x86_64-unknown-linux-gnu - ;; - osx) - echo x86_64-apple-darwin - ;; - esac -} - -gcc_prefix() { - case "$TARGET" in - aarch64-unknown-linux-gnu) - echo aarch64-linux-gnu- - ;; - arm*-gnueabihf) - echo arm-linux-gnueabihf- - ;; - *-musl) - echo musl- - ;; - *) - return - ;; - esac -} - -dobin() { - [ -z $MAKE_DEB ] && die 'dobin: $MAKE_DEB not set' - [ $# -lt 1 ] && die "dobin: at least one argument needed" - - local f prefix=$(gcc_prefix) - for f in "$@"; do - install -m0755 $f $dtd/debian/usr/bin/ - strip -s $dtd/debian/usr/bin/$(basename $f) - done -} - -architecture() { - case $1 in - x86_64-unknown-linux-gnu|x86_64-unknown-linux-musl) - echo amd64 - ;; - i686-unknown-linux-gnu|i686-unknown-linux-musl) - echo i386 - ;; - arm*-unknown-linux-gnueabihf) - echo armhf - ;; - *) - die "architecture: unexpected target $TARGET" - ;; - esac -}