-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (87 loc) · 3.31 KB
/
python-package.yml
File metadata and controls
95 lines (87 loc) · 3.31 KB
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
strategy:
fail-fast: false
matrix:
os: ["macos-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- os: "windows-latest"
python-version: "3.8"
- os: "ubuntu-latest"
python-version: "3.8"
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
# TODO:
# We could cache poetry installation, but I don't like
# having to manually manage cache invalidation.
# - name: Load cached Poetry installation
# id: cached-poetry
# uses: actions/cache@v3
# with:
# path: ~/.local # the path depends on the OS
# key: poetry-${{ runner.os }}-py-${{ matrix.python-version }}-0 # increment to reset cache
- name: Install Poetry Action
# if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1.3.4
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-py-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --with main,dev
# poetry export -f requirements.txt --without-hashes --only main,dev -o requirements.txt
# if [ $OS_VAR = 'Linux' ]
# then
# mv requirements.txt requirements-temp.txt
# sed '/nvidia-/d' requirements-temp.txt \
# | sed -r 's/torch==[0-9].[0-9].[0-9]/&+cpu/' \
# | sed '1s/^/--extra-index-url https:\/\/download.pytorch.org\/whl\/cpu\n/' > requirements.txt
# fi
# python -m venv .venv && source $VENV && pip install -r requirements.txt
env:
OS_VAR: ${{ runner.os }}
- name: Install project
run: poetry install --no-interaction --only-root
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Static checks
if: matrix.python-version == '3.10'
run: |
poetry run pre-commit run --all-files
- name: Test with pytest
uses: nick-fields/retry@v2
with:
shell: bash
timeout_minutes: 5
command: poetry run pytest --reruns 5 --reruns-delay 1
new_command_on_retry: poetry run pytest --reruns 5 --reruns-delay 1 --last-failed
max_attempts: 5