-
Notifications
You must be signed in to change notification settings - Fork 0
214 lines (191 loc) · 7.23 KB
/
Copy pathci.yml
File metadata and controls
214 lines (191 loc) · 7.23 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: CI
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
lint:
name: Lint (black, isort, flake8, mypy, import-linter)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements*.txt
- name: Install lint dependencies
run: pip install -r requirements-lint.txt -e ".[all]"
- run: black --check --line-length 100 db2sql/ installer/
- run: isort --check-only db2sql/ installer/
- run: flake8 db2sql/ installer/
- run: mypy --ignore-missing-imports db2sql/ installer/
- run: lint-imports
tests:
name: Tests (Python ${{ matrix.python }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# PR: 1 version pour feedback rapide. Push main: matrice complète pour
# la crédibilité du support Python 3.9–3.14 claimed dans pyproject.toml.
python: ${{ fromJSON(github.event_name == 'pull_request' && '["3.12"]' || '["3.9","3.10","3.11","3.12","3.13","3.14"]') }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements*.txt
allow-prereleases: true
- name: Install package and test dependencies
run: pip install -e ".[all]" pytest pytest-cov
- name: Run unit + cli tests
run: pytest tests/unit tests/cli --cov=db2sql --cov-report=xml --cov-report=term --cov-fail-under=80
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: false
docs:
name: Build documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
cache-dependency-path: |
pyproject.toml
docs/requirements.txt
- name: Install docs dependencies
run: pip install -e ".[all]" -r docs/requirements.txt
- name: Build HTML docs (warnings → errors)
run: sphinx-build -b html -W --keep-going docs docs/_build/html
functional:
name: Functional tests (MSSQL + MySQL + Postgres, no Oracle)
runs-on: ubuntu-latest
# Light stack (~2-3 min boot). Runs on every push to main, and on PRs
# carrying the `run-functional` label. Oracle is on-demand only — see
# the `functional-oracle` job below.
if: >-
github.event_name == 'push' ||
(github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'run-functional'))
timeout-minutes: 15
env:
MSSQL_HOST: localhost
MSSQL_PORT: "1433"
MSSQL_USER: sa
MSSQL_SA_PASSWORD: "Db2sqlTest!Strong"
MSSQL_PASSWORD: "Db2sqlTest!Strong"
MSSQL_DATABASE: db2sqltest
PG_HOST: localhost
PG_PORT: "5432"
PG_USER: postgres
POSTGRES_PASSWORD: postgres
PG_PASSWORD: postgres
PG_DATABASE: db2sqltarget
MYSQL_HOST: localhost
MYSQL_PORT: "3306"
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: mysqlpw
MYSQL_PASSWORD: mysqlpw
MYSQL_DATABASE: db2sqltest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements*.txt
- name: Install package and test dependencies
run: pip install -e ".[all]" pytest
- name: Start docker stack (mssql + mysql + postgres) and wait until healthy
run: docker compose -f .docker/docker-compose.yml --profile functional up -d --wait mssql mysql postgres
- name: Apply MSSQL init schema
run: docker compose -f .docker/docker-compose.yml --profile functional run --rm mssql-init
- name: Run functional tests (excluding Oracle)
run: pytest -m "functional and not oracle" tests/functional -v
- name: Capture docker stack logs on failure
if: failure()
run: |
mkdir -p artifacts
docker compose -f .docker/docker-compose.yml --profile functional logs --no-color > artifacts/stack.log || true
docker compose -f .docker/docker-compose.yml --profile functional ps > artifacts/stack-ps.log || true
- name: Upload stack logs artifact
if: failure()
uses: actions/upload-artifact@v4
with:
name: docker-stack-logs-functional
path: artifacts/
retention-days: 7
- name: Stop docker stack
if: always()
run: docker compose -f .docker/docker-compose.yml --profile functional down -v
functional-oracle:
name: Functional tests (Oracle, on-demand)
runs-on: ubuntu-latest
# Oracle image is ~10 GB and takes 3-5 min to become healthy. Only run
# when explicitly requested via the `run-oracle` label on a PR. Push
# events do NOT trigger this job — use the label even on hotfix PRs that
# touch the Oracle reader. (If you want a periodic safety run, add a
# `schedule:` trigger here — left out by default to keep CI minutes low.)
if: >-
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'run-oracle')
timeout-minutes: 45
env:
ORACLE_HOST: localhost
ORACLE_PORT: "1521"
ORACLE_SERVICE: FREEPDB1
ORACLE_PASSWORD: oraclepw
ORACLE_APP_USER: apptest
ORACLE_APP_PASSWORD: apptestpw
ORACLE_USER: apptest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements*.txt
- name: Install package and test dependencies
run: pip install -e ".[all]" pytest
- name: Start Oracle container and wait until healthy
run: docker compose -f .docker/docker-compose.yml --profile oracle up -d --wait
- name: Run Oracle functional tests
run: pytest -m oracle tests/functional -v
- name: Capture Oracle container logs on failure
if: failure()
run: |
mkdir -p artifacts
docker compose -f .docker/docker-compose.yml --profile oracle logs --no-color > artifacts/oracle.log || true
docker compose -f .docker/docker-compose.yml --profile oracle ps > artifacts/oracle-ps.log || true
- name: Upload Oracle logs artifact
if: failure()
uses: actions/upload-artifact@v4
with:
name: docker-stack-logs-oracle
path: artifacts/
retention-days: 7
- name: Stop Oracle container
if: always()
run: docker compose -f .docker/docker-compose.yml --profile oracle down -v