CI Python #1060
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Python | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
schedule: | |
- cron: '30 5 * * *' | |
jobs: | |
ci-python: | |
strategy: | |
matrix: | |
packageDirectory: ["interpret_community"] | |
operatingSystem: [ubuntu-latest] | |
pythonVersion: [3.7, 3.8, 3.9] | |
runs-on: ${{ matrix.operatingSystem }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: ${{ matrix.pythonVersion }} | |
- name: Install numpy | |
shell: bash -l {0} | |
run: | | |
conda install --yes --quiet numpy==1.19.5 -c conda-forge | |
- if: ${{ matrix.operatingSystem != 'macos-latest' }} | |
name: Install pytorch on non-MacOS | |
shell: bash -l {0} | |
run: | | |
conda install --yes --quiet pytorch torchvision cpuonly -c pytorch | |
- if: ${{ matrix.operatingSystem == 'macos-latest' }} | |
name: Install Anaconda packages on MacOS, which should not include cpuonly according to official docs | |
shell: bash -l {0} | |
run: | | |
conda install --yes --quiet pytorch torchvision -c pytorch | |
- if: ${{ matrix.operatingSystem == 'macos-latest' }} | |
name: Install lightgbm from conda on MacOS | |
shell: bash -l {0} | |
run: | | |
conda install --yes -c conda-forge lightgbm | |
- name: Install package | |
shell: bash -l {0} | |
run: | | |
pip install -e ./python | |
- name: Install dev dependencies | |
shell: bash -l {0} | |
run: | | |
pip install -r requirements-dev.txt | |
- name: Install visualization dependencies | |
shell: bash -l {0} | |
run: | | |
pip install raiwidgets | |
pip install -r requirements-vis.txt | |
pip install --upgrade "shap<=0.44.0" | |
- if: ${{ matrix.pythonVersion == '3.9' }} | |
name: Install scikit-learn to work around raiwidgets dependency | |
shell: bash -l {0} | |
run: | | |
pip install "scikit-learn==1.4.2" | |
- name: Install test dependencies | |
shell: bash -l {0} | |
run: | | |
pip install -r requirements-test.txt | |
- name: Test with pytest | |
shell: bash -l {0} | |
run: | | |
pytest ./tests -m "not notebooks" -s -v --cov=${{ matrix.packageDirectory }} --cov-report=xml --cov-report=html | |
- if: ${{ matrix.pythonVersion == '3.8' }} | |
name: Upload code coverage results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.packageDirectory }}-code-coverage-results | |
path: htmlcov | |
- if: ${{ matrix.pythonVersion == '3.8' }} | |
name: Upload to codecov | |
id: codecovupload1 | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
directory: . | |
env_vars: OS,PYTHON | |
fail_ci_if_error: false | |
files: ./coverage.xml | |
flags: unittests | |
name: codecov-umbrella | |
path_to_write_report: ./coverage/codecov_report.txt | |
verbose: true | |
- if: ${{ (steps.codecovupload1.outcome == 'failure') && (matrix.pythonVersion == '3.8') }} | |
name: Retry upload to codecov | |
id: codecovupload2 | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
directory: . | |
env_vars: OS,PYTHON | |
fail_ci_if_error: false | |
files: ./coverage.xml | |
flags: unittests | |
name: codecov-umbrella | |
path_to_write_report: ./coverage/codecov_report.txt | |
verbose: true | |
- if: ${{ matrix.pythonVersion == '3.8' }} | |
name: Set codecov status | |
shell: bash | |
run: | | |
if ${{ (steps.codecovupload1.outcome == 'success') || (steps.codecovupload2.outcome == 'success') }} ; then | |
echo fine | |
else | |
exit 1 | |
fi |