CI #330
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 | |
on: | |
push: | |
branches: [main] | |
paths-ignore: | |
- 'docs/**' | |
- 'bazel/**' | |
- 'typings/**' | |
pull_request: | |
paths-ignore: | |
- 'docs/**' | |
- 'bazel/**' | |
- 'typings/**' | |
schedule: | |
- cron: '0 0 * * 1/2' | |
env: | |
LINES: 120 | |
COLUMNS: 120 | |
BENTOML_DO_NOT_TRACK: True | |
PYTEST_PLUGINS: bentoml.testing.pytest.plugin | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun | |
defaults: | |
run: | |
shell: bash --noprofile --norc -exo pipefail {0} | |
jobs: | |
unit: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ['3.8', '3.11'] | |
name: unit-tests (python${{ matrix.python-version }}.${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # fetch all tags and branches | |
- name: Set up PDM | |
uses: pdm-project/setup-pdm@v3 | |
with: | |
cache: true | |
python-version: ${{ matrix.python-version }} | |
enable-pep582: false | |
- name: Install dependencies | |
run: | | |
pdm venv create --with-pip --force | |
pdm sync -d -G grpc -G io -G testing -G frameworks | |
pdm run pip install torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cpu | |
pdm run pip install -U tensorflow | |
- name: Unit tests | |
run: pdm run -v unit | |
- name: Disambiguate coverage filename | |
run: mv .coverage ".coverage.unit.${{ matrix.os }}.${{ matrix.python-version }}" | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-unit-data | |
path: .coverage.* | |
integrations: | |
name: framework-integration-tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
framework: | |
- catboost | |
- detectron | |
- diffusers | |
- easyocr | |
- fastai | |
- flax | |
- keras | |
- lightgbm | |
- onnx | |
- picklable_model | |
- pytorch | |
- pytorch_lightning | |
- sklearn | |
- tensorflow | |
- torchscript | |
- transformers | |
- xgboost | |
exclude: | |
- framework: transformers # NOTE: CI runners doesn't have enough space to run all transformers jobs | |
- framework: detectron # NOTE: tested locally and the latest PyPI are to obsolete. | |
timeout-minutes: 90 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # fetch all tags and branches | |
- name: Set up PDM | |
uses: pdm-project/setup-pdm@v3 | |
with: | |
python-version: '3.8' | |
enable-pep582: false | |
- name: Install dependencies | |
run: | | |
pdm venv create --with-pip | |
pdm sync -d -G testing -G frameworks | |
pdm run pip install torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cpu | |
pdm run pip install -U tensorflow onnx onnxruntime "jax[cpu]" | |
- name: Run framework integration tests | |
run: pdm run -v integration "${{ matrix.framework }}" | |
- name: Disambiguate coverage filename | |
run: mv .coverage ".coverage.integrations.ubuntu-latest.3.8.${{ matrix.framework }}" | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-integrations-data | |
path: .coverage.* | |
e2e-monitoring: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ['3.8', '3.11'] | |
name: monitoring-e2e-tests (python${{ matrix.python-version }}.${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 90 | |
env: | |
BENTOML_BUNDLE_LOCAL_BUILD: True | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # fetch all tags and branches | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
- name: Set up Docker Buildx | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set up PDM | |
uses: pdm-project/setup-pdm@v3 | |
with: | |
cache: true | |
python-version: ${{ matrix.python-version }} | |
enable-pep582: false | |
- name: Install dependencies | |
run: pdm sync -d -G io -G testing -G monitor-otlp | |
- name: Run the monitoring tests | |
working-directory: examples/monitoring/task_classification | |
run: mkdir -p monitoring && pdm run -v monitoring | |
- name: Disambiguate coverage filename | |
run: mv .coverage ".coverage.monitoring.${{ matrix.os }}.${{ matrix.python-version }}" | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-monitoring-data | |
path: .coverage.* | |
e2e-bento-server: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ['3.8', '3.11'] | |
server_type: ['http', 'grpc'] | |
exclude: | |
- os: windows-latest | |
server_type: 'grpc' | |
name: ${{ matrix.server_type }}-e2e-tests (python${{ matrix.python-version }}.${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 90 | |
env: | |
BENTOML_BUNDLE_LOCAL_BUILD: True | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # fetch all tags and branches | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
- name: Set up Docker Buildx | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set up PDM | |
uses: pdm-project/setup-pdm@v3 | |
with: | |
cache: true | |
python-version: ${{ matrix.python-version }} | |
enable-pep582: false | |
- name: Install dependencies | |
run: | | |
pdm venv create --with-pip --force | |
pdm run pip install -r tests/e2e/bento_server_${{ matrix.server_type }}/requirements.txt | |
pdm sync -d -G grpc -G io -G testing | |
- name: Run ${{ matrix.server_type }} tests | |
run: pdm run -v tests tests/e2e/bento_server_${{ matrix.server_type }} | |
- name: Disambiguate coverage filename | |
run: mv .coverage ".coverage.e2e.${{ matrix.os }}.${{ matrix.python-version }}" | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-e2e-data | |
path: .coverage.* | |
coverage: | |
name: report-coverage | |
runs-on: ubuntu-latest | |
needs: | |
- e2e-bento-server | |
- e2e-monitoring | |
- unit | |
- integrations | |
if: github.event_name == 'pull_request' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up PDM | |
uses: pdm-project/setup-pdm@v3 | |
with: | |
cache: true | |
python-version: '3.11' | |
enable-pep582: false | |
- name: Download e2e coverage | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-e2e-data | |
- name: Download monitoring coverage | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-monitoring-data | |
- name: Download integrations coverage | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-integrations-data | |
- name: Download unit coverage | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-unit-data | |
- name: Install dependencies | |
run: pdm sync -d -G testing | |
- name: Combine coverage data | |
run: pdm run -v coverage-combine | |
- name: Export coverage reports and generate summary | |
run: pdm run -v coverage-generate-reports | |
- name: Upload uncovered HTML report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: uncovered-html-report | |
path: htmlcov | |
- name: Write coverage summary report | |
if: github.event_name == 'pull_request' | |
run: pdm run -v coverage-write-report | |
- name: Update coverage pull request comment | |
if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
path: coverage-report.md | |
evergreen: # https://github.com/marketplace/actions/alls-green#why | |
if: github.event_name == 'pull_request' | |
needs: | |
- coverage | |
- e2e-bento-server | |
- e2e-monitoring | |
- unit | |
- integrations | |
runs-on: ubuntu-latest | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} | |
concurrency: | |
group: ci-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: true |