-
Notifications
You must be signed in to change notification settings - Fork 56
142 lines (139 loc) · 4.61 KB
/
main.yml
File metadata and controls
142 lines (139 loc) · 4.61 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
name: CI
on:
push:
branches: [main]
pull_request_target:
branches: [main]
permissions:
contents: read
actions: read
id-token: write
pull-requests: write
jobs:
ci-approval:
if: ${{ github.event_name != 'push' }}
environment: testing
runs-on: ubuntu-latest
steps:
- name: Log
run: echo 'Running tests was approved'
ci-pre-commit:
needs: [ci-approval]
# run this job if it was approved by ci-approval or ci-approval was skipped and we are in a push event
if: ${{ success() || ( needs.ci-approval.result == 'skipped' && github.event_name == 'push' ) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version-file: pyproject.toml
- name: Install project
run: uv sync --all-groups --all-extras
- name: run pre-commit
run: uv run pre-commit run --all
- name: Check for uncommitted changes
run: |
if [[ -n "$(git status --porcelain --untracked-files=all)" ]]; then
echo "Changed files after pre-commit!"
git status --porcelain --untracked-files=all
exit 1
fi
ci-test:
needs: [ci-approval]
# run this job if we have a PR
if: ${{ github.event_name == 'pull_request_target' }}
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
sqlalchemy-version: [2.0.*]
async-mode: [non-async]
include:
- python-version: '3.14'
sqlalchemy-version: 2.0.*
async-mode: async
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version-file: pyproject.toml
- name: Install project
run: uv sync --all-groups --all-extras
- name: Install sqlalchemy
run: uv pip install sqlalchemy==${{ matrix.sqlalchemy-version }}
- name: run tests (with coverage)
run: |
PYTEST_DBURI=$(uv run --no-sync python -m test.ci_setup setup ${{ secrets.TEST_DBURI }} ${{ matrix.async-mode }})
echo "::add-mask::$PYTEST_DBURI"
export PYTEST_ADDOPTS="--dburi $PYTEST_DBURI"
uv run --no-sync pytest -v --cov sqlalchemy_hana --cov test --cov-report xml --cov-fail-under 0 test/
uv run --no-sync python test/ci_setup.py teardown ${{ secrets.TEST_DBURI }} $PYTEST_DBURI
- name: Rename coverage file
run: |
UUID=$(uuidgen)
echo "UUID=${UUID}" >> $GITHUB_ENV
mv .coverage .coverage.${UUID}
- name: upload coverage file
uses: actions/upload-artifact@v7
with:
name: .coverage.${{ env.UUID }}
path: .coverage.${{ env.UUID }}
if-no-files-found: error
include-hidden-files: true
ci-coverage-reporting:
needs: ci-test
runs-on: ubuntu-latest
# for non-PR events, no tests are executed, so we can skip coverage reporting
if: ${{ github.event_name == 'pull_request_target' }}
steps:
- name: Fail if predecessor jobs failed
if: ${{ needs.ci-test.result != 'success' }}
run: |
echo "Predecessor job(s) failed:"
echo " ci-test: ${{ needs.ci-test.result }}"
exit 1
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version-file: pyproject.toml
- name: Download coverage files
uses: actions/download-artifact@v8
with:
merge-multiple: true
path: coverage_files
- name: Prepare coverage files
run: |
uv sync --all-groups
cd coverage_files
uv run coverage combine
mv .coverage ../.coverage
cd ..
uv run coverage xml
- name: run diff-cover
run: uv run diff-cover --config-file pyproject.toml coverage.xml
- name: Upload to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage.xml