-
Notifications
You must be signed in to change notification settings - Fork 14
191 lines (166 loc) · 5.92 KB
/
tests.yml
File metadata and controls
191 lines (166 loc) · 5.92 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
# RushTI Test Workflow
#
# Runs tests on pull requests and pushes to main branches.
# Only triggers when Python/application code changes.
#
# Unit tests and linting run on every push and PR.
# Integration tests only run on PRs to master (expensive, ~7 min).
#
# Required configuration for integration tests:
#
# Variable (non-sensitive connection details):
# RUSHTI_TEST_TM1_CONFIG - config.ini content WITHOUT passwords.
# Example:
# [tm1srv01]
# base_url = https://your-server/tm1/api/tm1
# user = your_user
# namespace = LDAP
# ssl = true
# verify = true
# async_requests_mode = true
#
# Secret (sensitive credentials only):
# RUSHTI_TEST_TM1_PASSWORD - The password for tm1srv01.
#
# Legacy (still supported):
# Secret: RUSHTI_TEST_TM1_CONFIG - Full config.ini content including password.
# If the variable + secret pair is configured, it takes precedence over the legacy secret.
name: Tests
on:
push:
branches: [master, main]
paths:
- 'src/**'
- 'tests/**'
- 'pyproject.toml'
- '*.py'
- '*.spec'
- 'config/**'
- '.github/workflows/tests.yml'
pull_request:
branches: [master, main]
paths:
- 'src/**'
- 'tests/**'
- 'pyproject.toml'
- '*.py'
- '*.spec'
- 'config/**'
- '.github/workflows/tests.yml'
workflow_dispatch: # Allow manual triggering
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.13"]
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest pytest-asyncio pytest-cov
- name: Run unit tests
run: |
pytest tests/unit/ -v --tb=short
- name: Run unit tests with coverage (Python 3.11 only)
if: matrix.python-version == '3.11'
run: |
pytest tests/unit/ -v --cov=src/rushti --cov-report=xml --cov-report=term
- name: Upload coverage reports
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v6
with:
file: ./coverage.xml
fail_ci_if_error: false
continue-on-error: true
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 15
# Only run on PRs (expensive ~7 min) and manual dispatch, not on every push
# Also requires TM1 secrets to be configured (checked in steps below)
if: >
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
github.event_name == 'workflow_dispatch'
needs: unit-tests
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest pytest-asyncio
- name: Check TM1 configuration
id: check-tm1
run: |
if [ -n "${{ vars.RUSHTI_TEST_TM1_CONFIG }}" ] && [ -n "${{ secrets.RUSHTI_TEST_TM1_PASSWORD }}" ]; then
echo "tm1_configured=true" >> $GITHUB_OUTPUT
echo "config_source=variable" >> $GITHUB_OUTPUT
elif [ -n "${{ secrets.RUSHTI_TEST_TM1_CONFIG }}" ]; then
echo "tm1_configured=true" >> $GITHUB_OUTPUT
echo "config_source=legacy_secret" >> $GITHUB_OUTPUT
else
echo "tm1_configured=false" >> $GITHUB_OUTPUT
echo "::warning::TM1 config not configured. Integration tests will be skipped."
fi
- name: Create TM1 config file (from variable + secret)
if: steps.check-tm1.outputs.config_source == 'variable'
run: |
echo "${{ vars.RUSHTI_TEST_TM1_CONFIG }}" > tests/config.ini
echo "password = ${{ secrets.RUSHTI_TEST_TM1_PASSWORD }}" >> tests/config.ini
- name: Create TM1 config file (legacy - full secret)
if: steps.check-tm1.outputs.config_source == 'legacy_secret'
run: |
echo "${{ secrets.RUSHTI_TEST_TM1_CONFIG }}" > tests/config.ini
- name: Run integration tests (v11 - required)
if: steps.check-tm1.outputs.tm1_configured == 'true'
run: |
pytest tests/integration/ -v --tb=short -m "requires_tm1 and not v12"
- name: Run integration tests (v12 - optional)
if: steps.check-tm1.outputs.tm1_configured == 'true'
continue-on-error: true
run: |
pytest tests/integration/ -v --tb=short -m "v12"
- name: Skip message
if: steps.check-tm1.outputs.tm1_configured != 'true'
run: |
echo "Integration tests skipped - TM1 config not configured"
echo ""
echo "To enable (recommended):"
echo " 1. Add variable RUSHTI_TEST_TM1_CONFIG with connection details (no password)"
echo " 2. Add secret RUSHTI_TEST_TM1_PASSWORD with the TM1 password"
echo ""
echo "Legacy (still supported):"
echo " Add secret RUSHTI_TEST_TM1_CONFIG with the full config.ini content"
echo ""
echo "See tests/config.ini.template for the expected format."
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install linters
run: |
python -m pip install --upgrade pip
pip install ruff black
- name: Run ruff
run: |
ruff check src/ tests/
- name: Check Black formatting
run: |
black --check src/ tests/