Skip to content

Commit

Permalink
Fix deploy (#89)
Browse files Browse the repository at this point in the history
* Fix deploy

* Double check master

* Fix get_tox_envs.py

* Fix deploy
  • Loading branch information
henryre committed Aug 14, 2019
1 parent ddd20f1 commit c66adfc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ jobs:
python: 3.6
env: ALL_ENVS=--all JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
- if: type != pull_request
name: "Python 3.7: all tutorial tests"
name: "Python 3.7: all tutorial tests + web build"
python: 3.7
env: ALL_ENVS=--all JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
env: BUILD_WEB=true ALL_ENVS=--all JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

# Install JDK8 for PySpark tests
before_install:
- sudo add-apt-repository -y ppa:openjdk-r/ppa
- sudo apt-get -qq update
- sudo apt-get install -y openjdk-8-jdk --no-install-recommends
- sudo update-java-alternatives -s java-1.8.0-openjdk-amd64
- sudo apt-get install -y coreutils --no-install-recommends

install:
- pip install -U pip setuptools
- pip install -U tox==3.13.0
- python scripts/get_tox_envs.py --travis-strict --plan $ALL_ENVS
- tox --notest -e $(python scripts/get_tox_envs.py --travis-strict $ALL_ENVS)
- python scripts/get_tox_envs.py --plan $ALL_ENVS
- tox --notest -e $(python scripts/get_tox_envs.py $ALL_ENVS)

script:
- tox -e $(python scripts/get_tox_envs.py --travis-strict $ALL_ENVS)
- tox -e $(python scripts/get_tox_envs.py $ALL_ENVS)

after_success:
- test $TRAVIS_BRANCH = "master" && \
test $TRAVIS_PULL_REQUEST = "false" && \
bash ./scripts/push-tutorials.sh
- if [[ ${BUILD_WEB} == "true" ]] && [[ ${TRAVIS_BRANCH} == "master" ]]; then
echo "Deploying tutorials";
bash ./scripts/push-tutorials.sh;
fi
12 changes: 6 additions & 6 deletions scripts/get_tox_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
EXTRA_ENVIRONMENTS = ["style"]


def get_modified_paths(travis_strict: bool) -> List[str]:
def get_modified_paths(no_travis_strict: bool) -> List[str]:
# Call git diff --name-only HEAD $(git merge-base HEAD $TRAVIS_BRANCH)
# to get paths affected by patch
base_branch = os.environ.get("TRAVIS_BRANCH")
if base_branch is None:
if travis_strict:
if not no_travis_strict:
raise ValueError("No environment variable $TRAVIS_BRANCH")
base_branch = "master"
merge_base = subprocess.run(
Expand All @@ -30,7 +30,7 @@ def get_default_environments() -> List[str]:
return [str(s, "utf-8") for s in cp.stdout.splitlines()]


def get_changed_tox_envs(all_envs: bool, travis_strict: bool, plan: bool) -> None:
def get_changed_tox_envs(all_envs: bool, no_travis_strict: bool, plan: bool) -> None:
# Check we're in the right place, otherwise git paths are messed up
if os.path.split(os.getcwd())[1] != "snorkel-tutorials":
raise ValueError("Execute this script from the snorkel-tutorials directory")
Expand All @@ -42,7 +42,7 @@ def get_changed_tox_envs(all_envs: bool, travis_strict: bool, plan: bool) -> Non
print(",".join(default_environments))
return
# Find paths modified in patch
modified_paths = get_modified_paths(travis_strict)
modified_paths = get_modified_paths(no_travis_strict)
if plan:
print(f"Modified paths: {','.join(modified_paths)}")
# Find unique snorkel-tutorial subdirectories affected by patch
Expand Down Expand Up @@ -76,10 +76,10 @@ def get_changed_tox_envs(all_envs: bool, travis_strict: bool, plan: bool) -> Non
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--travis-strict",
"--no-travis-strict",
action="store_true",
default=False,
help="Fail if not in Travis?",
help="Don't fail if not in Travis?",
)
parser.add_argument(
"--plan",
Expand Down
5 changes: 4 additions & 1 deletion scripts/push-tutorials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ push_tutorials() {
git push https://$GITHUB_TOKEN@github.com/snorkel-team/website.git master -f > /dev/null 2>&1
}

echo "Deploying tutorials"
echo "Setting up git"
setup_git
echo "Checking out website"
checkout_website
echo "Building tutorial web pages"
build_tutorials
echo "Pushing tutorial web pages"
push_tutorials

0 comments on commit c66adfc

Please sign in to comment.