Skip to content

Commit 7894e87

Browse files
committed
refactor: move testing to CI pipeline, keep only build/publish in release workflow
1 parent 4e1f58f commit 7894e87

2 files changed

Lines changed: 97 additions & 116 deletions

File tree

.github/workflows/build-publish.yml

Lines changed: 8 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -3,129 +3,26 @@ name: Build, Test and Publish ITL ControlPlane SDK
33
on:
44
workflow_dispatch:
55
inputs:
6-
environment:
7-
description: 'Environment to deploy to'
8-
required: false
9-
default: 'staging'
10-
type: choice
11-
options:
12-
- staging
13-
- production
14-
force_rebuild:
15-
description: 'Force rebuild package (ignore cache)'
16-
required: false
17-
default: false
18-
type: boolean
19-
skip_tests:
20-
description: 'Skip package tests'
21-
required: false
22-
default: false
23-
type: boolean
246
publish_pypi:
25-
description: 'Publish to PyPI (production only)'
7+
description: 'Publish to PyPI'
268
required: false
279
default: true
2810
type: boolean
2911
push:
30-
branches:
31-
- main
32-
- develop
33-
- 'feature/**'
3412
tags:
3513
- "v*"
3614
paths:
3715
- 'src/**'
3816
- 'pyproject.toml'
3917
- 'README.md'
4018
- 'LICENSE'
41-
- 'examples/**'
42-
- 'providers/**'
4319
- '.github/workflows/**'
44-
pull_request:
45-
branches: [ main, develop ]
46-
paths:
47-
- 'src/**'
48-
- 'pyproject.toml'
49-
- 'README.md'
50-
- 'LICENSE'
51-
- 'examples/**'
52-
- 'providers/**'
5320

5421
env:
5522
PACKAGE_NAME: itl-controlplane-sdk
5623
PYTHON_VERSION: '3.11'
5724

5825
jobs:
59-
# Test and validate package
60-
test:
61-
runs-on: ubuntu-latest
62-
if: ${{ !inputs.skip_tests }}
63-
strategy:
64-
matrix:
65-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
66-
67-
steps:
68-
- name: Checkout repository
69-
uses: actions/checkout@v4
70-
71-
- name: Set up Python ${{ matrix.python-version }}
72-
uses: actions/setup-python@v4
73-
with:
74-
python-version: ${{ matrix.python-version }}
75-
76-
- name: Cache Python dependencies
77-
uses: actions/cache@v3
78-
with:
79-
path: ~/.cache/pip
80-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
81-
restore-keys: |
82-
${{ runner.os }}-pip-${{ matrix.python-version }}-
83-
${{ runner.os }}-pip-
84-
85-
- name: Install package and dependencies
86-
run: |
87-
python -m pip install --upgrade pip
88-
pip install -e ".[dev]"
89-
90-
- name: Run SDK validation tests
91-
run: |
92-
python test_sdk.py
93-
94-
- name: Run pytest (if tests exist)
95-
run: |
96-
if [ -d "tests" ]; then
97-
pytest tests/ -v
98-
else
99-
echo "No pytest directory found, skipping pytest"
100-
fi
101-
102-
- name: Run type checking with mypy
103-
run: |
104-
mypy src/itl_controlplane_sdk --ignore-missing-imports
105-
106-
- name: Run code formatting check
107-
run: |
108-
black --check src/ examples/ providers/
109-
110-
- name: Test import and basic functionality
111-
run: |
112-
python -c "
113-
from itl_controlplane_sdk import ResourceProviderRegistry, ResourceProvider
114-
from itl_controlplane_sdk.models import ResourceRequest, ProvisioningState
115-
print('✅ All imports successful')
116-
117-
# Test basic functionality
118-
registry = ResourceProviderRegistry()
119-
print('✅ Registry creation successful')
120-
121-
print('🎉 SDK basic functionality test passed')
122-
"
123-
124-
- name: Test example scripts
125-
run: |
126-
cd examples
127-
python quickstart.py
128-
12926
# Lint and security checks
13027
lint-and-security:
13128
runs-on: ubuntu-latest
@@ -177,7 +74,7 @@ jobs:
17774
build:
17875
needs: [lint-and-security]
17976
runs-on: ubuntu-latest
180-
if: ${{ always() && (needs.lint-and-security.result == 'success') && (!inputs.skip_tests || needs.test.result == 'success' || needs.test.result == 'skipped') }}
77+
if: ${{ always() && (needs.lint-and-security.result == 'success') }}
18178

18279
outputs:
18380
package-version: ${{ steps.version.outputs.version }}
@@ -374,9 +271,9 @@ jobs:
374271

375272
# Publish to PyPI (Test)
376273
publish-test:
377-
needs: [build, test]
274+
needs: [build]
378275
runs-on: ubuntu-latest
379-
if: ${{ always() && needs.build.result == 'success' && needs.test.result == 'success' }}
276+
if: ${{ always() && needs.build.result == 'success' }}
380277
environment: staging
381278

382279
steps:
@@ -575,14 +472,12 @@ jobs:
575472

576473
# Auto-create release tags on push to main/develop
577474
auto-tag:
578-
needs: [test, build]
475+
needs: [build]
579476
runs-on: ubuntu-latest
580477
if: |
581478
github.event_name == 'push' &&
582479
!startsWith(github.ref, 'refs/tags/') &&
583-
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') &&
584-
needs.test.result == 'success' &&
585-
needs.build.result == 'success'
480+
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
586481
permissions:
587482
contents: write
588483

@@ -723,13 +618,13 @@ jobs:
723618
724619
# Notify on completion
725620
notify:
726-
needs: [test, build, publish-test, publish-production, create-release, auto-tag]
621+
needs: [build, publish-test, publish-production, create-release, auto-tag]
727622
runs-on: ubuntu-latest
728623
if: always()
729624
steps:
730625
- name: Determine notification status
731626
run: |
732-
if [[ "${{ needs.test.result }}" == "success" && "${{ needs.build.result }}" == "success" ]]; then
627+
if [[ "${{ needs.build.result }}" == "success" ]]; then
733628
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
734629
if [[ "${{ needs.publish-production.result }}" == "success" ]]; then
735630
echo "STATUS=✅ PRODUCTION RELEASE SUCCESSFUL" >> $GITHUB_ENV

.github/workflows/ci.yml

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@ name: CI - Test and Validate
33
on:
44
pull_request:
55
branches: [ main, develop ]
6+
paths:
7+
- 'src/**'
8+
- 'pyproject.toml'
9+
- 'test_sdk.py'
10+
- 'tests/**'
11+
- 'examples/**'
12+
- '.github/workflows/ci.yml'
613
push:
7-
branches: [ main, develop ]
14+
branches: [ main, develop, 'feature/**' ]
815
paths:
916
- 'src/**'
1017
- 'pyproject.toml'
1118
- 'test_sdk.py'
19+
- 'tests/**'
1220
- 'examples/**'
21+
- '.github/workflows/ci.yml'
1322

1423
jobs:
1524
test:
@@ -26,20 +35,51 @@ jobs:
2635
with:
2736
python-version: ${{ matrix.python-version }}
2837

38+
- name: Cache Python dependencies
39+
uses: actions/cache@v3
40+
with:
41+
path: ~/.cache/pip
42+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
43+
restore-keys: |
44+
${{ runner.os }}-pip-${{ matrix.python-version }}-
45+
${{ runner.os }}-pip-
46+
2947
- name: Install dependencies
3048
run: |
3149
python -m pip install --upgrade pip
3250
pip install -e ".[dev]"
3351
34-
- name: Run validation tests
52+
- name: Run SDK validation tests
3553
run: python test_sdk.py
3654

55+
- name: Run pytest (if tests exist)
56+
run: |
57+
if [ -d "tests" ]; then
58+
pytest tests/ -v
59+
else
60+
echo "No pytest directory found, skipping pytest"
61+
fi
62+
3763
- name: Run type checking
3864
run: mypy src/itl_controlplane_sdk --ignore-missing-imports
3965

4066
- name: Check code formatting
4167
run: black --check src/ examples/
4268

69+
- name: Test import and basic functionality
70+
run: |
71+
python -c "
72+
from itl_controlplane_sdk import ResourceProviderRegistry, ResourceProvider
73+
from itl_controlplane_sdk.models import ResourceRequest, ProvisioningState
74+
print('✅ All imports successful')
75+
76+
# Test basic functionality
77+
registry = ResourceProviderRegistry()
78+
print('✅ Registry creation successful')
79+
80+
print('🎉 SDK basic functionality test passed')
81+
"
82+
4383
- name: Test examples
4484
run: |
4585
cd examples
@@ -66,4 +106,50 @@ jobs:
66106
source test-env/bin/activate
67107
pip install dist/*.whl
68108
python -c "from itl_controlplane_sdk import ResourceProviderRegistry; print('✅ Package test successful')"
69-
deactivate
109+
deactivate
110+
111+
lint-and-security:
112+
runs-on: ubuntu-latest
113+
steps:
114+
- name: Checkout repository
115+
uses: actions/checkout@v4
116+
117+
- name: Set up Python
118+
uses: actions/setup-python@v4
119+
with:
120+
python-version: '3.11'
121+
122+
- name: Install security tools
123+
run: |
124+
python -m pip install --upgrade pip
125+
pip install bandit safety pip-audit
126+
127+
- name: Install package
128+
run: |
129+
pip install -e ".[dev]"
130+
131+
- name: Run bandit security linter
132+
run: |
133+
bandit -r src/ -f json -o bandit-report.json || true
134+
bandit -r src/
135+
136+
- name: Run safety check for dependencies
137+
run: |
138+
safety check --json --output safety-report.json || true
139+
safety check
140+
141+
- name: Run pip-audit for vulnerability scanning
142+
run: |
143+
pip-audit --format=json --output=audit-report.json || true
144+
pip-audit
145+
146+
- name: Upload security reports
147+
uses: actions/upload-artifact@v4
148+
if: always()
149+
with:
150+
name: security-reports
151+
path: |
152+
bandit-report.json
153+
safety-report.json
154+
audit-report.json
155+
retention-days: 30

0 commit comments

Comments
 (0)