diff --git a/.travis.yml b/.travis.yml index 9aa2cca1fc..1bb1d86079 100644 --- a/.travis.yml +++ b/.travis.yml @@ -89,7 +89,7 @@ jobs: - sudo /snap/bin/lxd init --auto install: script: - - sudo snapcraft --use-lxd + - ./scripts/build_snap.sh after_failure: - sudo journalctl -u snapd @@ -135,7 +135,7 @@ deploy: stage: build - provider: snap snap: dvc_*.snap - channel: ${TRAVIS_TAG:+stable}${TRAVIS_TAG:-edge} + channel: $SNAP_CHANNEL skip_cleanup: true on: all_branches: true diff --git a/scripts/build_package.sh b/scripts/build_package.sh index 1b95366974..1266ead8bf 100755 --- a/scripts/build_package.sh +++ b/scripts/build_package.sh @@ -4,7 +4,7 @@ set -e set -x if [ ! -d "dvc" ]; then - echo "Please run this script from repository root" + echo "Please run this script from repository root" >&2 exit 1 fi @@ -17,12 +17,12 @@ python setup.py bdist_wheel --universal if [[ -n "$TRAVIS_TAG" ]]; then pip uninstall -y dvc if which dvc; then - echo "ERROR: dvc command still exists! Unable to verify dvc version." + echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 exit 1 fi pip install dist/dvc-*.whl if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then - echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" + echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 exit 1 fi pip uninstall -y dvc diff --git a/scripts/build_posix.sh b/scripts/build_posix.sh index c5e9bb89f2..a3deebdc2d 100755 --- a/scripts/build_posix.sh +++ b/scripts/build_posix.sh @@ -29,7 +29,7 @@ fi print_error() { - echo -e "\e[31m$1\e[0m" + echo -e "\e[31m$1\e[0m" >&2 } if [ ! -d "dvc" ]; then diff --git a/scripts/build_snap.sh b/scripts/build_snap.sh new file mode 100755 index 0000000000..ce78aea583 --- /dev/null +++ b/scripts/build_snap.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e +set -x + +if [ ! -d "dvc" ]; then + echo "Please run this script from repository root" + exit 1 +fi + +sudo snapcraft --use-lxd + +pip uninstall -y dvc +if which dvc; then + echo "ERROR: dvc command still exists! Unable to verify dvc version." >&2 + exit 1 +fi +sudo snap install --dangerous --classic dvc_*.snap +if [[ -n "$TRAVIS_TAG" ]]; then + # Make sure we have a correct version + if [[ "$(dvc --version)" != "$TRAVIS_TAG" ]]; then + echo "ERROR: 'dvc --version'$(dvc -V) doesn't match '$TRAVIS_TAG'" >&2 + exit 1 + fi +fi +# ensure basic commands can run +# N.B.: cannot run `dvc get` on travis (#2956) +dvc version +dvc.git status +dvc.git fetch --all +sudo snap remove dvc diff --git a/scripts/ci/before_install.sh b/scripts/ci/before_install.sh index 27c423b7d2..2e9461be41 100644 --- a/scripts/ci/before_install.sh +++ b/scripts/ci/before_install.sh @@ -50,3 +50,9 @@ elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ln -s -f /usr/local/bin/python3 /usr/local/bin/python ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip fi + +if [[ -n "$TRAVIS_TAG" ]]; then + echo "export SNAP_CHANNEL=stable" >> env.sh +else + echo "export SNAP_CHANNEL=edge" >> env.sh +fi diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index b1e9ed0588..e73da698ef 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -3,7 +3,7 @@ summary: Data Version Control description: Git for Data & Models https://dvc.org adopt-info: dvc grade: stable -confinement: classic # for same reasons as snap `git-ubuntu` +confinement: classic # for `dvc run`ning external binaries base: core18 license: Apache-2.0 layout: