1+ name : PR Checks
2+
3+ on :
4+ pull_request :
5+ branches : [main]
6+
7+ jobs :
8+ # =========================
9+ # CODE QUALITY CHECKS (REQUIRED)
10+ # =========================
11+ lint :
12+ name : Lint & Format Check
13+ runs-on : ubuntu-latest
14+ steps :
15+ - uses : actions/checkout@v4
16+
17+ - name : Set up Python
18+ uses : actions/setup-python@v5
19+ with :
20+ python-version : " 3.11"
21+
22+ - name : Install dependencies
23+ run : |
24+ python -m pip install --upgrade pip
25+ pip install ruff black
26+
27+ - name : Run Ruff
28+ run : ruff check cleancloud/
29+
30+ - name : Check formatting with Black
31+ run : black --check cleancloud/
32+
33+ # =========================
34+ # UNIT TESTS (REQUIRED)
35+ # =========================
36+ test :
37+ name : Test Python ${{ matrix.python-version }}
38+ runs-on : ubuntu-latest
39+ environment : cleancloud-test
40+ strategy :
41+ fail-fast : false
42+ matrix :
43+ python-version : ["3.10", "3.11", "3.12"]
44+
45+ steps :
46+ - uses : actions/checkout@v4
47+
48+ - name : Set up Python ${{ matrix.python-version }}
49+ uses : actions/setup-python@v5
50+ with :
51+ python-version : ${{ matrix.python-version }}
52+
53+ - name : Install dependencies
54+ run : |
55+ python -m pip install --upgrade pip
56+ pip install -e ".[dev,aws,azure]"
57+
58+ - name : Run tests
59+ env :
60+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
61+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
62+ AWS_DEFAULT_REGION : us-east-1
63+ AZURE_CLIENT_ID : ${{ secrets.AZURE_CLIENT_ID }}
64+ AZURE_TENANT_ID : ${{ secrets.AZURE_TENANT_ID }}
65+ AZURE_CLIENT_SECRET : ${{ secrets.AZURE_CLIENT_SECRET }}
66+ AZURE_SUBSCRIPTION_ID : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
67+ run : pytest tests/ -v --cov=cleancloud --cov-report=xml
68+
69+ - name : Upload coverage
70+ if : matrix.python-version == '3.11'
71+ uses : codecov/codecov-action@v4
72+ with :
73+ file : ./coverage.xml
74+ fail_ci_if_error : false
75+
76+ # =========================
77+ # BUILD PACKAGE (REQUIRED)
78+ # =========================
79+ build :
80+ name : Build Distribution
81+ runs-on : ubuntu-latest
82+ needs : [lint, test]
83+
84+ steps :
85+ - uses : actions/checkout@v4
86+
87+ - name : Set up Python
88+ uses : actions/setup-python@v5
89+ with :
90+ python-version : " 3.11"
91+
92+ - name : Install build tools
93+ run : |
94+ python -m pip install --upgrade pip
95+ pip install build twine
96+
97+ - name : Build package
98+ run : python -m build
99+
100+ - name : Check package
101+ run : twine check dist/*
102+
103+ - name : Upload distributions
104+ uses : actions/upload-artifact@v4
105+ with :
106+ name : distributions
107+ path : dist/
108+
109+ # =========================
110+ # INTEGRATION TESTS (OPTIONAL - Don't block PR)
111+ # =========================
112+ integration-test-aws :
113+ name : Integration Test - AWS (Optional)
114+ runs-on : ubuntu-latest
115+ continue-on-error : true # ✅ Informational only
116+ environment : cleancloud-it-test
117+
118+ steps :
119+ - uses : actions/checkout@v4
120+
121+ - name : Set up Python
122+ uses : actions/setup-python@v5
123+ with :
124+ python-version : " 3.11"
125+
126+ - name : Install CleanCloud
127+ run : |
128+ python -m pip install --upgrade pip
129+ pip install -e ".[dev,aws,azure]"
130+
131+ - name : Test AWS doctor command
132+ env :
133+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
134+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
135+ AWS_DEFAULT_REGION : us-east-1
136+ run : |
137+ cleancloud doctor --provider aws --region us-east-1
138+
139+ - name : Test AWS scan
140+ env :
141+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
142+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
143+ AWS_DEFAULT_REGION : us-east-1
144+ run : |
145+ cleancloud scan --provider aws --region us-east-1 --output json --output-file test-results.json
146+
147+ - name : Upload test results
148+ if : always()
149+ uses : actions/upload-artifact@v4
150+ with :
151+ name : aws-integration-test-results
152+ path : test-results.json
153+
154+ integration-test-azure :
155+ name : Integration Test - Azure (Optional)
156+ runs-on : ubuntu-latest
157+ continue-on-error : true # ✅ Informational only
158+ environment : cleancloud-it-test
159+
160+ steps :
161+ - uses : actions/checkout@v4
162+
163+ - name : Set up Python
164+ uses : actions/setup-python@v5
165+ with :
166+ python-version : " 3.11"
167+
168+ - name : Install CleanCloud
169+ run : |
170+ python -m pip install --upgrade pip
171+ pip install -e ".[dev,aws,azure]"
172+
173+ - name : Test Azure doctor command (with retry)
174+ uses : nick-fields/retry-action@v3
175+ with :
176+ timeout_minutes : 3
177+ max_attempts : 3
178+ retry_wait_seconds : 30
179+ command : cleancloud doctor --provider azure
180+ env :
181+ AZURE_CLIENT_ID : ${{ secrets.AZURE_CLIENT_ID }}
182+ AZURE_TENANT_ID : ${{ secrets.AZURE_TENANT_ID }}
183+ # AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
184+ AZURE_SUBSCRIPTION_ID : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
185+
186+ - name : Test Azure scan (with retry)
187+ uses : nick-fields/retry-action@v3
188+ with :
189+ timeout_minutes : 5
190+ max_attempts : 3
191+ retry_wait_seconds : 30
192+ command : cleancloud scan --provider azure --output json --output-file test-results.json
193+ env :
194+ AZURE_CLIENT_ID : ${{ secrets.AZURE_CLIENT_ID }}
195+ AZURE_TENANT_ID : ${{ secrets.AZURE_TENANT_ID }}
196+ # AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
197+ AZURE_SUBSCRIPTION_ID : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
198+
199+ - name : Upload test results
200+ if : always()
201+ uses : actions/upload-artifact@v4
202+ with :
203+ name : azure-integration-test-results
204+ path : test-results.json
0 commit comments