Files
OpenLLM/.github/workflows/ci.yml
2023-06-25 22:38:53 -04:00

110 lines
3.5 KiB
YAML

# Copyright 2023 BentoML Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
LINES: 120
COLUMNS: 120
OPENLLM_DO_NOT_TRACK: True
PYTHONUNBUFFERED: '1'
STABLE_PYTHON_VERSION: '3.11'
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
defaults:
run:
shell: bash --noprofile --norc -exo pipefail {0}
jobs:
tests:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
name: tests-${{ matrix.os }}-${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup CI
uses: ./.github/actions/setup-repo
with:
python-version: ${{ matrix.python-version }}
- name: Run tests
run: hatch run full
- name: Disambiguate coverage filename
run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}"
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage.*
coverage:
name: report-coverage
runs-on: ubuntu-latest
needs:
- tests
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup CI
uses: ./.github/actions/setup-repo
with:
python-version: ${{ env.STABLE_PYTHON_VERSION }}
- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: coverage-data
- name: Combine coverage data
run: hatch run coverage:combine
- name: Export coverage reports
run: |
hatch run coverage:report-xml
hatch run coverage:report-uncovered-html
- name: Upload uncovered HTML report
uses: actions/upload-artifact@v3
with:
name: uncovered-html-report
path: htmlcov
- name: Generate coverage summary
run: hatch run coverage:generate-summary
- name: Write coverage summary report
if: github.event_name == 'pull_request'
run: hatch run coverage:write-summary-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: always()
needs:
- coverage
- tests
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: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true