CI Python #1522
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: ["ml_wrappers"] | |
operatingSystem: [ubuntu-latest, macos-latest, windows-latest] | |
pythonVersion: ['3.9', '3.10'] | |
openaiVersion: ['0.28.1', 'openai-latest'] | |
exclude: | |
- openaiVersion: '0.28.1' | |
pythonVersion: '3.9' | |
- openaiVersion: '0.28.1' | |
pythonVersion: '3.10' | |
- openaiVersion: '0.28.1' | |
operatingSystem: 'macos-latest' | |
- openaiVersion: '0.28.1' | |
operatingSystem: 'windows-latest' | |
runs-on: ${{ matrix.operatingSystem }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: ${{ matrix.pythonVersion }} | |
- if: ${{ matrix.operatingSystem == 'macos-latest' }} | |
name: Use Homebrew to install libomp on MacOS | |
shell: bash -l {0} | |
run: | | |
brew install libomp | |
- if: ${{ matrix.operatingSystem == 'windows-latest' }} | |
name: Install pytorch on windows for python 3.8 to 3.10 | |
shell: bash -l {0} | |
run: | | |
conda install --yes --quiet "pytorch<2.0.0" torchvision captum cpuonly "libtiff<4.5.0" -c pytorch -c conda-forge --strict-channel-priority | |
- if: ${{ matrix.operatingSystem == 'ubuntu-latest' }} | |
name: Install pytorch on ubuntu for python 3.8 to 3.10 | |
shell: bash -l {0} | |
run: | | |
conda install --yes --quiet "pytorch<2.0.0" torchvision captum cpuonly -c pytorch -c conda-forge --strict-channel-priority | |
- if: ${{ matrix.operatingSystem == 'macos-latest' }} | |
name: Install pytorch on MacOS for python 3.8 to 3.10 | |
shell: bash -l {0} | |
run: | | |
conda install --yes --quiet "pytorch<2.0.0" torchvision captum -c pytorch -c conda-forge --strict-channel-priority | |
- 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 backwards-compatible tf-keras for transformers | |
shell: bash -l {0} | |
run: | | |
pip install tf-keras | |
- 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 test dependencies | |
shell: bash -l {0} | |
run: | | |
pip install -r requirements-test.txt | |
- if: ${{ matrix.openaiVersion != 'openai-latest' }} | |
name: Install openai version ${{ matrix.openaiVersion }} | |
shell: bash -l {0} | |
run: | | |
pip install openai==${{ matrix.openaiVersion }} | |
- name: Test with pytest | |
shell: bash -l {0} | |
run: | | |
pytest ./tests/main -s -v --durations=10 --cov='ml_wrappers' --cov-report=xml --cov-report=html | |
- name: Upload code coverage results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.packageDirectory }}-code-coverage-results | |
path: htmlcov | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} | |
- if: ${{ (matrix.operatingSystem == 'windows-latest') && (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 | |
verbose: true | |
- if: ${{ (steps.codecovupload1.outcome == 'failure') && (matrix.pythonVersion == '3.8') && (matrix.operatingSystem == 'windows-latest') }} | |
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 | |
verbose: true | |
- name: Set codecov status | |
if: ${{ (matrix.pythonVersion == '3.8') && (matrix.operatingSystem == 'windows-latest') }} | |
shell: bash | |
run: | | |
if ${{ (steps.codecovupload1.outcome == 'success') || (steps.codecovupload2.outcome == 'success') }} ; then | |
echo fine | |
else | |
exit 1 | |
fi |