-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (100 loc) · 3.27 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Lint and Test
on:
pull_request:
branches:
- main
push:
branches:
- main
release:
types:
- published
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
torch-version: ["^1.13.0", "2.0.0"]
# v2.0.1 is currently buggy: https://github.com/pytorch/pytorch/issues/100974
# torch-version: ["^1.13.0", "^2.0.1"]
steps:
# check-out repo and setup python
- name: Check out repository
uses: actions/checkout@v3
# setup Python
- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
# install & configure poetry
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
# load cached venv if cache exists
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ matrix.torch-version }}-${{ hashFiles('**/poetry.lock') }}
# install dependencies if cache does not exist
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
# install torch
- name: Install torch
run: poetry add torch=${{ matrix.torch-version }} --no-interaction
# install the root project, if required
- name: Install library
run: poetry install --no-interaction
# run pre-commit hooks
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit hooks
run: poetry run pre-commit run --all-files --show-diff-on-failure --color=always
# run test suite with coverage
- name: Run tests
run: |
poetry run pytest --cov=torchcache/ --cov-report=xml --cov-report=term-missing --cov-fail-under=50 --cov-branch --color=yes
# upload coverage report to codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: true
publish:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
steps:
# check-out repo and setup python
- name: Check out repository
uses: actions/checkout@v3
# setup Python
- name: Set up python 3.8
id: setup-python
uses: actions/setup-python@v3
with:
python-version: "3.8"
# install & configure poetry
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Publish package
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build