Skip to content

Commit

Permalink
Github Actions deploy workflow (pytorch#684)
Browse files Browse the repository at this point in the history
Summary:
Adds automated testing and deployment of python and conda packages as well as the stable website build.
This workflow is triggered upon creating a new tag.

Pull Request resolved: pytorch#684

Reviewed By: ldworkin

Differential Revision: D26461738

Pulled By: Balandat

fbshipit-source-id: 845e7a03ba0ea7f8a2fdb88b02ed5850151418a8
  • Loading branch information
Balandat authored and facebook-github-bot committed Feb 18, 2021
1 parent 3bd3ec7 commit 33034ea
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 8 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/deploy_on_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Deploy On Release

on:
release:
types: [created]

jobs:

tests-and-coverage-pip:
name: Tests and coverage (pip, Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install git+https://github.com/cornellius-gp/gpytorch.git
pip install .[test]
- name: Unit tests and coverage
run: |
pytest -ra --cov=. --cov-report term-missing
- name: Upload coverage
if: ${{ runner.os == 'Linux' && matrix.python-version == 3.7 }}
run: |
bash <(curl -s https://codecov.io/bash)
package-deploy-pypi:
name: Package and deploy to pypi.org
runs-on: ubuntu-latest
needs: tests-and-coverage-pip
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
pip install git+https://github.com/cornellius-gp/gpytorch.git
pip install .[test]
pip install --upgrade setuptools wheel
- name: Build packages (wheel and source distribution)
run: |
python setup.py sdist bdist_wheel
- name: Verify packages
run: |
./scripts/build_and_verify_py_packages.sh
- name: Deploy to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: mbalandat
password: ${{ secrets.PYPI_PASSWORD }}
verbose: true

package-deploy-conda:
name: Package conda and deploy to anaconda.org
runs-on: ubuntu-latest
needs: tests-and-coverage-pip
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
activate-environment: test
python-version: "3.7"
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Install dependencies
shell: bash -l {0}
run: |
conda install -y -c pytorch-nightly pytorch cpuonly
conda install -y scipy sphinx pytest flake8
conda install -y -c gpytorch gpytorch
conda install -y conda-build anaconda-client
conda config --set anaconda_upload no
- name: Build and verify conda package
shell: bash -l {0}
run: |
./scripts/build_and_verify_conda_package.sh
- name: Deploy to anaconda.org
run: |
botorch_version=$(python setup.py --version)
build_dir="$(pwd)/.conda/conda_build/noarch"
pkg_file="${build_dir}/botorch-${botorch_version}-0.tar.bz2"
anaconda -t ${{ secrets.ANACONDA_UPLOAD_TOKEN }} upload -u pytorch $pkg_file
publish-versioned-website:
name: Publish versioned website
runs-on: ubuntu-latest
needs: [package-deploy-pypi, package-deploy-conda]
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
pip install git+https://github.com/cornellius-gp/gpytorch.git
pip install -e .[dev]
pip install git+https://github.com/facebook/Ax.git
pip install -e .[tutorials]
pip install beautifulsoup4 ipython "nbconvert<6.0"
- name: Publish latest website
run: |
./scripts/publish_site.sh -d -v ${{ github.event.release.tag_name }}
13 changes: 7 additions & 6 deletions scripts/build_and_verify_conda_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cd .conda || exit

# Get version number (created dynamically via setuptools-scm)
BOTORCH_VERSION=$(python ../setup.py --version)
# Export env var (this is used in .conda/meta.yaml)
export BOTORCH_VERSION

# build package
Expand All @@ -22,11 +23,11 @@ path="${build_dir}/noarch/botorch-${BOTORCH_VERSION}-0.tar.bz2"
# verify that package installs correctly
conda install --offline "${path}"

# # verify import works and version is correct
# conda_version=$(python -c "import botorch; print(botorch.__version__)")
# if [[ $conda_version != $BOTORCH_VERSION ]]; then
# echo "Incorrect version. Expected: ${version}, Actual: ${conda_version}"
# exit 1
# fi
# verify import works and version is correct
conda_version=$(python -c "import botorch; print(botorch.__version__)" | tail -n 1)
if [[ $conda_version != "$BOTORCH_VERSION" ]]; then
echo "Incorrect version. Expected: ${BOTORCH_VERSION}, Actual: ${conda_version}"
exit 1
fi

cd .. || exit
4 changes: 2 additions & 2 deletions scripts/build_and_verify_py_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ path="${cur_dir}/dist/botorch-${version}"
# install wheel and verify import works and version is correct
pip uninstall -y botorch
pip install "${path}-py3-none-any.whl"
wheel_version=$(python -c "import botorch; print(botorch.__version__)")
wheel_version=$(python -c "import botorch; print(botorch.__version__)" | tail -n 1)
if [[ $wheel_version != "$version" ]]; then
echo "Incorrect wheel version. Expected: ${version}, Actual: ${wheel_version}"
exit 1
Expand All @@ -27,7 +27,7 @@ fi
# do the same for the source dist
pip uninstall -y botorch
pip install "${path}.tar.gz"
src_version=$(python -c "import botorch; print(botorch.__version__)")
src_version=$(python -c "import botorch; print(botorch.__version__)" | tail -n 1)
if [[ $src_version != "$version" ]]; then
echo "Incorrect source dist version. Expected: ${version}, Actual: ${src_version}"
exit 1
Expand Down

0 comments on commit 33034ea

Please sign in to comment.