-
Notifications
You must be signed in to change notification settings - Fork 2
129 lines (126 loc) · 4.63 KB
/
ci.yml
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
117
118
119
120
121
122
123
124
125
126
127
128
129
name: CI
on:
push:
branches: [ main ]
pull_request:
merge_group:
workflow_dispatch:
release:
types: [published]
schedule:
- cron: '0 0 1 * *'
jobs:
ci:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
poetry-version: ["1.2.2", "1.7.1"]
os: [ubuntu-latest]
include:
# - python-version: "3.11"
# poetry-version: "1.7.1"
# os: macos-latest
- python-version: "3.11"
poetry-version: "1.7.1"
os: windows-latest
poetry-install-extra-args: "--compile"
- python-version: "3.11"
poetry-version: "1.7.1"
os: ubuntu-latest
annotate-errors: true
- poetry-version: "1.7.1"
os: ubuntu-latest
poetry-install-extra-args: "--compile"
runs-on: ${{ matrix.os }}
concurrency:
group: ${{ github.workflow }}-${{ matrix.python-version }}-${{ matrix.poetry-version }}-${{ matrix.os }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: abatilo/actions-poetry@v3
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Setup a local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v4
name: Define a cache for the virtual environment based
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}-${{ matrix.python-version }}-${{ matrix.poetry-version }}-${{ matrix.os }}-annotate-errors=${{ matrix.annotate-errors }}
- name: Install the project dependencies
run: poetry install ${{ matrix.poetry-install-extra-args }}
- uses: liskin/gh-problem-matcher-wrap@v3
with:
action: add
linters: flake8
if: matrix.annotate-errors
- name: Lint with flake8
run: |
# # < 7 to avoid ./.venv/lib/python3.11/site-packages/sympy/polys/numberfields/resolvent_lookup.py: "pyflakes[F]" failed during execution due to RecursionError('maximum recursion depth exceeded')
# pip install 'flake8<7'
# stop the build if there are Python syntax errors or undefined names
make git-lint
# exit-zero treats all errors as warnings
make git-lint-more FLAKE8_EXTRA_FLAGS=--exit-zero
- uses: liskin/gh-problem-matcher-wrap@v3
with:
action: remove
linters: flake8
if: matrix.annotate-errors
- name: Summarize lint with flake8
run: |
printf '%s\n\n%s\n' '<details><summary><code>make git-lint-more</code></summary>' '```' >> "$GITHUB_STEP_SUMMARY"
make git-lint-more FLAKE8_EXTRA_FLAGS=--exit-zero >> "$GITHUB_STEP_SUMMARY"
printf '\n%s\n%s\n' '```' '</details>' >> "$GITHUB_STEP_SUMMARY"
if: always() && matrix.annotate-errors
- name: Remove annotations for pytest
run: poetry run python -m pip uninstall -y pytest-github-actions-annotate-failures
if: matrix.annotate-errors
- name: Summarize pytest results
run: |
printf '%s\n\n%s\n' '<details><summary><code>poetry run pytest -v</code></summary>' '```' >> "$GITHUB_STEP_SUMMARY"
poetry run pytest -v 2>&1 >> "$GITHUB_STEP_SUMMARY"
printf '\n%s\n%s\n' '```' '</details>' >> "$GITHUB_STEP_SUMMARY"
if: always() && matrix.annotate-errors
- name: Install annotations for pytest
run: poetry run python -m pip install pytest-github-actions-annotate-failures
if: always() && matrix.annotate-errors
- name: Run the automated tests
run: poetry run pytest -v
if: always()
- run: poetry run wandb login --anonymously
if: always()
- run: make test-load-experiments-report
if: always()
black-lint:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-black-lint-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
jupyter: true
version: "~= 24.1.1"
check-all:
runs-on: ubuntu-latest
needs: [ci, black-lint]
if: always()
steps:
- run: echo 'ci passed'
if: ${{ needs.ci.result == 'success' }}
- run: echo 'black-lint passed'
if: ${{ needs.black-lint.result == 'success' }}
- run: echo 'ci failed' && false
if: ${{ needs.ci.result != 'success' }}
- run: echo 'black-lint failed' && false
if: ${{ needs.black-lint.result != 'success' }}