Skip to content

Build

Build #2087

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "15 21 * * FRI"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
python-version: ['3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
run: |
python -m pip install --upgrade pip
python -m pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# The GitHub editor is 127 chars wide
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics
# PyTorch CPU for Linux has different pip syntax wrt Win and Mac.
- name: Install torch-2.0.0+cpu if linux
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: python -m pip install torch==2.0.0 --extra-index-url https://download.pytorch.org/whl/cpu
- name: Install torch-2.0.0+cpu if not linux
if: ${{ !startsWith(matrix.os, 'ubuntu') }}
run: python -m pip install torch==2.0.0
- name: Install basic dependencies
run: |
python -m pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html
- name: Test with older SKLearn on Linux with py3.9 to check backward compatibility
if: ${{ matrix.python-version == '3.9' && startsWith(matrix.os, 'ubuntu') == true }}
run: python -m pip install scikit-learn==1.2.1
# Compile (but not push) documentation only for one of the runs (Linux py3.8).
- name: Generate Documentation
if: ${{ matrix.python-version == '3.8' && startsWith(matrix.os, 'ubuntu') }}
run: |
# We're mocking out the torch. So now we also need to sub this on out
find ../. -type f -exec sed -i 's/{torch.__version__}/1.12.0/g' {} +
find ../. -type f -exec sed -i 's/torch.__version__/"1.12.0"/g' {} +
make sphinx-site -C website/
# now refresh the code
git checkout . && python -m pip install -e .[tests] -f https://download.pytorch.org/whl/torch_stable.html
- name: Run basic tests without extra
run: pytest
- name: Coverage on basic tests without extra
run: coverage run -a -m pytest tests/test_no_extra_install.py
- name: If mac, install libomp to facilitate lgbm install
if: ${{ startsWith(matrix.os, 'macos')}}
run: |
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb
brew unlink libomp
brew install ./libomp.rb
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
export CFLAGS="$CFLAGS -I/usr/local/opt/libomp/include"
export CXXFLAGS="$CXXFLAGS -I/usr/local/opt/libomp/include"
export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/opt/libomp/lib -L/usr/local/opt/libomp/lib -lomp"
- name: Install extra dependencies
run: |
python -m pip install .[extra,onnx,sparkml]
python -m pip install pandas
- name: Install TVM from pypi if Ubuntu
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: python -m pip install apache-tvm==0.10.0
- uses: actions/cache@v3
# TVM takes forever, we try to cache it.
if: ${{ startsWith(matrix.os, 'macos')}}
id: cache
env:
CACHE_NUMBER: 9
with:
path: ~/work/hummingbird/tvm
key: ${{ matrix.os }}-${{ env.CACHE_NUMBER }}-${{ matrix.python-version }}-tvm-0.10
# Getting TVM requires: 1) Install LLVM 2) fetching TVM from github, 3) cmake, 4) make, 5) install python dependency.
# 2 to 4 will be retrieved from the cache.
# The pipeline only works for Unix systems. For windows we will have to compile LLVM from source which is a no go.
- name: Install LLVM if Mac
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
brew install llvm@14
- name: Fetch and prepare TVM for compilation if Mac
if: ${{ steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.os, 'macos') }}
run: |
cd ~/work/hummingbird
git clone https://github.com/apache/tvm.git
cd tvm
git checkout tags/v0.10.0
git submodule update --recursive --init
cmake -E make_directory build
- name: CMake TVM if Mac
if: ${{ steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.os, 'macos') }}
working-directory: ../tvm/build
run: >-
MACOSX_DEPLOYMENT_TARGET=10.13 cmake
"-DUSE_RPC=ON"
"-DUSE_GRAPH_RUNTIME=ON"
"-DUSE_LLVM=$(brew --prefix llvm@14)/bin/llvm-config --link-static"
..
- name: Build TVM if Mac
if: ${{ steps.cache.outputs.cache-hit != 'true' && startsWith(matrix.os, 'macos') }}
working-directory: ../tvm/build
run: |
make -j3
- name: Install python TVM if Mac
if: ${{ startsWith(matrix.os, 'macos') }}
working-directory: ../tvm/python
run: |
python -m pip install -U wheel packaging
python -m pip install cython==0.29.34
python setup.py bdist_wheel
python -m pip install dist/tvm-*.whl
# We don't run pytest for Linux py3.8 since we do coverage for that case.
- name: Test with pytest
if: ${{ matrix.python-version != '3.8' || startsWith(matrix.os, 'ubuntu') != true }}
run: pytest
# Run and push coverage only for Linux py3.8
- name: Coverage 3.8 Linux
if: ${{ matrix.python-version == '3.8' && startsWith(matrix.os, 'ubuntu') }}
run: |
coverage run -a -m pytest tests
coverage xml
- name: Upload coverage to Codecov
if: ${{ matrix.python-version == '3.8' && startsWith(matrix.os, 'ubuntu') }}
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
- name: Deploy to GitHub pages 🚀
if: ${{ github.ref == 'refs/heads/main' && matrix.python-version == '3.8' && startsWith(matrix.os, 'ubuntu') }}
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: website/public