-
Notifications
You must be signed in to change notification settings - Fork 77
115 lines (100 loc) · 2.92 KB
/
tests.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
name: pytests
on:
push:
branches:
- master
paths:
- 'adala/**'
- 'tests/**'
- '.github/workflows/tests.yml'
- '**/requirements**'
- 'codecov.yml'
tags-ignore:
- '**'
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- master
- 'release/**'
workflow_dispatch:
env:
OPENAI_API_KEY: test
jobs:
run_black:
name: Code formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Install poetry"
run: pipx install poetry
- name: "Set up Python"
id: setup_python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'
- name: Install Python dependencies
run: poetry install
- name: Run black
run: poetry run pytest --black .
run_pytest:
name: "pytest ${{ matrix.os }} | ${{ matrix.python-version }}"
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
# python-version: ['3.9', '3.10', '3.11']
python-version: ['3.11']
steps:
- uses: actions/checkout@v4
- name: "Install poetry"
run: pipx install poetry
- name: "Set up Python ${{ matrix.python-version }}"
id: setup_python
uses: actions/setup-python@v5
with:
python-version: '${{ matrix.python-version }}'
cache: 'poetry'
- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Install app
run: poetry install --no-interaction
- name: Run tests with coverage
if: matrix.os == 'ubuntu-latest'
run: |
poetry run pytest tests/ -vv ${{ matrix.python-version == '3.11' && '--cov=. --cov-report=xml' || '' }}
- name: Upload to Codecov
if: |
matrix.os == 'ubuntu-latest' &&
matrix.python-version == '3.11' &&
github.event.pull_request.user.login != 'dependabot[bot]'
uses: codecov/[email protected]
with:
files: tests/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
dependabot-auto-merge:
name: "Auto Merge dependabot PR"
if: |
always() &&
needs.run_pytest.result == 'success' &&
github.event_name == 'pull_request' &&
github.event.pull_request.user.login == 'dependabot[bot]' &&
( startsWith(github.head_ref, 'dependabot/npm_and_yarn/') || startsWith(github.head_ref, 'dependabot/pip/') )
runs-on: ubuntu-latest
needs:
- run_pytest
steps:
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --admin --squash "${PR_URL}"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GIT_PAT }}