apply Lightning-AI/tutorials@a5d840d #1
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 internal | |
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows | |
on: # Trigger the workflow on push or pull request, but only for the main branch | |
push: {} | |
pull_request: | |
branches: [main] | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
pytest-internal: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-20.04 ] | |
python-version: ["3.8", "3.10"] | |
# Timeout: https://stackoverflow.com/a/59076067/4521646 | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # fetch all history for all branches and tags | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# Note: This uses an internal pip API and may not always work | |
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow | |
- name: Get pip cache dir | |
id: pip-cache | |
run: echo "::set-output name=dir::$(pip cache dir)" | |
- name: pip cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ hashFiles('.actions/requires.txt') }}-${{ hashFiles('requirements/default.txt') }} | |
restore-keys: ${{ runner.os }}-pip-py${{ matrix.python-version }}- | |
- name: Install requirements | |
run: | | |
pip --version | |
pip install -q -r .actions/requires.txt -r _requirements/test.txt | |
# this is needed to be able to run package version parsing test | |
pip install -q -r _requirements/default.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html | |
- name: Prepare dummy inputs | |
run: | | |
jupytext --set-formats ipynb,py:percent templates/simple/template.py | |
jupytext --set-formats ipynb,py:percent templates/titanic/tutorial.py | |
# mv templates/simple/template.ipynb templates/simple.ipynb | |
git diff --name-only HEAD~3 > master-diff.txt | |
python .actions/assistant.py list_dirs "" > dirs-b1.txt | |
python .actions/assistant.py list_dirs --include_file_ext=".ipynb" > dirs-b2.txt | |
- name: Testing | |
run: | | |
coverage run -m pytest .actions -v | |
- name: Statistics | |
if: success() | |
run: | | |
coverage report | |
coverage xml | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
if: always() | |
# see: https://github.com/actions/toolkit/issues/399 | |
continue-on-error: true | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: coverage.xml | |
flags: pytest,${{ runner.os }} | |
name: CLI-coverage | |
fail_ci_if_error: false |