Release/v0.2.0 #490
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 | |
pull_request: | |
branches: | |
- main | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.10'] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# Clean python cache files | |
- name: Clean cache files | |
run: | | |
find . -type f -name "*.pyc" -delete | |
find . -type d -name "__pycache__" -delete | |
rm -f .coverage* coverage.xml | |
# Cache Poetry dependencies | |
# - name: Cache dependencies | |
# uses: actions/cache@v2 | |
# with: | |
# path: ~/.cache/pypoetry | |
# key: ${{ runner.os }}-poetry-${{ hashFiles('**/pyproject.toml') }}-cpu | |
# restore-keys: | | |
# ${{ runner.os }}-poetry- | |
- name: Install poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python - | |
- name: Configure poetry | |
run: | | |
poetry config virtualenvs.create false | |
- name: Switch to CPU version of PyTorch | |
run: | | |
poetry remove torch | |
poetry source add -p explicit pytorch https://download.pytorch.org/whl/cpu | |
poetry add --source pytorch torch | |
- name: Install dependencies | |
run: | | |
poetry install | |
- name: Verify PyTorch installation | |
run: | | |
poetry run python -c "import torch; print(torch.__version__); print('CUDA available:', torch.cuda.is_available())" | |
- name: Debug Coverage Config | |
run: | | |
cat pyproject.toml | |
poetry run coverage debug config | |
- name: Run Tests with Coverage | |
run: | | |
poetry run coverage run --source=. -m pytest | |
poetry run coverage xml -i -o coverage.xml | |
env: | |
COVERAGE_FILE: ".coverage.${{ matrix.python-version }}" | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} # Required for private repos | |
file: ./coverage.xml # Specify the coverage report file | |
fail_ci_if_error: true | |
verbose: true | |
- name: Store coverage file | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage | |
path: .coverage.${{ matrix.python-version }} | |
include-hidden-files: true | |
# Coverage job to comment on PRs and update README badge | |
coverage: | |
runs-on: ubuntu-latest | |
needs: tests | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download coverage artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage | |
# Comment coverage details on PR | |
- name: Coverage comment | |
id: coverage_comment | |
uses: py-cov-action/python-coverage-comment-action@v3 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
MERGE_COVERAGE_FILES: true | |
# Store comment to be posted if written | |
- name: Store Pull Request comment to be posted | |
uses: actions/upload-artifact@v3 | |
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | |
with: | |
name: python-coverage-comment-action | |
path: python-coverage-comment-action.txt |