1414jobs :
1515 test :
1616 runs-on : ubuntu-latest
17+ strategy :
18+ matrix :
19+ test-scenario : [
20+ ' valid-credentials' ,
21+ ' invalid-api-key' ,
22+ ' invalid-organization' ,
23+ ' non-existent-application' ,
24+ ' feature-branch' ,
25+ ' tag-deployment'
26+ ]
1727 steps :
1828 - uses : actions/checkout@v4
1929
@@ -34,25 +44,181 @@ jobs:
3444 ls -la dist/
3545 cat action.yml
3646
37- - name : Test Quant Cloud Init Action
47+ - name : Test Valid Credentials
48+ if : matrix.test-scenario == 'valid-credentials'
3849 uses : ./
39- id : init
50+ id : init-valid
4051 with :
4152 quant_api_key : ${{ secrets.QUANT_API_KEY }}
4253 quant_organization : ' quant'
4354 base_url : ' https://portal.stage.quantcdn.io/api/v3'
55+ continue-on-error : false
4456
45- - name : Debug Outputs
57+ - name : Test Invalid API Key (Expected Failure)
58+ if : matrix.test-scenario == 'invalid-api-key'
59+ uses : ./
60+ id : init-invalid-key
61+ with :
62+ quant_api_key : ' invalid-key-12345'
63+ quant_organization : ' quant'
64+ base_url : ' https://portal.stage.quantcdn.io/api/v3'
65+ continue-on-error : true
66+
67+ - name : Test Invalid Organization (Expected Failure)
68+ if : matrix.test-scenario == 'invalid-organization'
69+ uses : ./
70+ id : init-invalid-org
71+ with :
72+ quant_api_key : ${{ secrets.QUANT_API_KEY }}
73+ quant_organization : ' non-existent-org-12345'
74+ base_url : ' https://portal.stage.quantcdn.io/api/v3'
75+ continue-on-error : true
76+
77+ - name : Test Non-Existent Application (Expected Warning)
78+ if : matrix.test-scenario == 'non-existent-application'
79+ uses : ./
80+ id : init-no-app
81+ with :
82+ quant_api_key : ${{ secrets.QUANT_API_KEY }}
83+ quant_organization : ' quant'
84+ quant_application : ' non-existent-app-12345'
85+ base_url : ' https://portal.stage.quantcdn.io/api/v3'
86+ continue-on-error : false
87+
88+ - name : Test Feature Branch Detection
89+ if : matrix.test-scenario == 'feature-branch'
90+ uses : ./
91+ id : init-feature
92+ with :
93+ quant_api_key : ${{ secrets.QUANT_API_KEY }}
94+ quant_organization : ' quant'
95+ base_url : ' https://portal.stage.quantcdn.io/api/v3'
96+ env :
97+ GITHUB_REF : ' refs/heads/feature/test-branch'
98+ GITHUB_REPOSITORY : ' quant/test-repo'
99+ continue-on-error : false
100+
101+ - name : Test Tag Deployment Detection
102+ if : matrix.test-scenario == 'tag-deployment'
103+ uses : ./
104+ id : init-tag
105+ with :
106+ quant_api_key : ${{ secrets.QUANT_API_KEY }}
107+ quant_organization : ' quant'
108+ base_url : ' https://portal.stage.quantcdn.io/api/v3'
109+ env :
110+ GITHUB_REF : ' refs/tags/v1.0.0'
111+ GITHUB_REPOSITORY : ' quant/test-repo'
112+ continue-on-error : false
113+
114+ - name : Validate Valid Credentials Outputs
115+ if : matrix.test-scenario == 'valid-credentials'
116+ run : |
117+ echo "=== VALID CREDENTIALS TEST RESULTS ==="
118+ echo "Project exists: ${{ steps.init-valid.outputs.project_exists }}"
119+ echo "Environment exists: ${{ steps.init-valid.outputs.environment_exists }}"
120+ echo "Application: ${{ steps.init-valid.outputs.quant_application }}"
121+ echo "Environment: ${{ steps.init-valid.outputs.environment_name }}"
122+ echo "Is production: ${{ steps.init-valid.outputs.is_production }}"
123+ echo "Stripped endpoint: ${{ steps.init-valid.outputs.stripped_endpoint }}"
124+
125+ # Validate expected values
126+ if [[ "${{ steps.init-valid.outputs.environment_name }}" != "production" ]]; then
127+ echo "❌ Expected environment 'production', got '${{ steps.init-valid.outputs.environment_name }}'"
128+ exit 1
129+ fi
130+ if [[ "${{ steps.init-valid.outputs.is_production }}" != "true" ]]; then
131+ echo "❌ Expected is_production 'true', got '${{ steps.init-valid.outputs.is_production }}'"
132+ exit 1
133+ fi
134+ echo "✅ Valid credentials test passed"
135+
136+ - name : Validate Invalid API Key Failure
137+ if : matrix.test-scenario == 'invalid-api-key'
138+ run : |
139+ echo "=== INVALID API KEY TEST RESULTS ==="
140+ if [[ "${{ steps.init-invalid-key.outcome }}" == "failure" ]]; then
141+ echo "✅ Invalid API key correctly failed as expected"
142+ else
143+ echo "❌ Invalid API key should have failed but didn't"
144+ exit 1
145+ fi
146+
147+ - name : Validate Invalid Organization Failure
148+ if : matrix.test-scenario == 'invalid-organization'
149+ run : |
150+ echo "=== INVALID ORGANIZATION TEST RESULTS ==="
151+ if [[ "${{ steps.init-invalid-org.outcome }}" == "failure" ]]; then
152+ echo "✅ Invalid organization correctly failed as expected"
153+ else
154+ echo "❌ Invalid organization should have failed but didn't"
155+ exit 1
156+ fi
157+
158+ - name : Validate Non-Existent Application Warning
159+ if : matrix.test-scenario == 'non-existent-application'
160+ run : |
161+ echo "=== NON-EXISTENT APPLICATION TEST RESULTS ==="
162+ echo "Project exists: ${{ steps.init-no-app.outputs.project_exists }}"
163+ echo "Application: ${{ steps.init-no-app.outputs.quant_application }}"
164+
165+ if [[ "${{ steps.init-no-app.outputs.project_exists }}" == "false" ]]; then
166+ echo "✅ Non-existent application correctly identified as not existing"
167+ else
168+ echo "❌ Non-existent application should show project_exists=false"
169+ exit 1
170+ fi
171+ if [[ "${{ steps.init-no-app.outputs.quant_application }}" == "non-existent-app-12345" ]]; then
172+ echo "✅ Application name correctly set to provided value"
173+ else
174+ echo "❌ Application name should match provided value"
175+ exit 1
176+ fi
177+ echo "✅ Non-existent application test passed"
178+
179+ - name : Validate Feature Branch Detection
180+ if : matrix.test-scenario == 'feature-branch'
181+ run : |
182+ echo "=== FEATURE BRANCH TEST RESULTS ==="
183+ echo "Environment: ${{ steps.init-feature.outputs.environment_name }}"
184+ echo "Is production: ${{ steps.init-feature.outputs.is_production }}"
185+
186+ if [[ "${{ steps.init-feature.outputs.environment_name }}" != "feature" ]]; then
187+ echo "❌ Expected environment 'feature', got '${{ steps.init-feature.outputs.environment_name }}'"
188+ exit 1
189+ fi
190+ if [[ "${{ steps.init-feature.outputs.is_production }}" != "false" ]]; then
191+ echo "❌ Expected is_production 'false', got '${{ steps.init-feature.outputs.is_production }}'"
192+ exit 1
193+ fi
194+ echo "✅ Feature branch detection test passed"
195+
196+ - name : Validate Tag Deployment Detection
197+ if : matrix.test-scenario == 'tag-deployment'
46198 run : |
47- echo "Project exists: ${{ steps.init.outputs.project_exists }}"
48- echo "Environment exists: ${{ steps.init.outputs.environment_exists }}"
49- echo "Application: ${{ steps.init.outputs.quant_application }}"
50- echo "Environment: ${{ steps.init.outputs.environment_name }}"
51- echo "Is production: ${{ steps.init.outputs.is_production }}"
52- echo "Stripped endpoint: ${{ steps.init.outputs.stripped_endpoint }}"
199+ echo "=== TAG DEPLOYMENT TEST RESULTS ==="
200+ echo "Environment: ${{ steps.init-tag.outputs.environment_name }}"
201+ echo "Is production: ${{ steps.init-tag.outputs.is_production }}"
202+
203+ if [[ "${{ steps.init-tag.outputs.environment_name }}" != "production" ]]; then
204+ echo "❌ Expected environment 'production', got '${{ steps.init-tag.outputs.environment_name }}'"
205+ exit 1
206+ fi
207+ if [[ "${{ steps.init-tag.outputs.is_production }}" != "true" ]]; then
208+ echo "❌ Expected is_production 'true', got '${{ steps.init-tag.outputs.is_production }}'"
209+ exit 1
210+ fi
211+ echo "✅ Tag deployment detection test passed"
53212
54- - name : Verify Docker Login
213+ - name : Test Summary
55214 run : |
56- echo "Testing if Docker is logged into the registry..."
57- docker info
58- echo "✅ Docker login verification completed"
215+ echo "=== TEST SUMMARY ==="
216+ echo "Test scenario: ${{ matrix.test-scenario }}"
217+ echo "Job status: ${{ job.status }}"
218+ echo "Step outcomes:"
219+ echo " - Valid credentials: ${{ steps.init-valid.outcome || 'N/A' }}"
220+ echo " - Invalid API key: ${{ steps.init-invalid-key.outcome || 'N/A' }}"
221+ echo " - Invalid org: ${{ steps.init-invalid-org.outcome || 'N/A' }}"
222+ echo " - Non-existent app: ${{ steps.init-no-app.outcome || 'N/A' }}"
223+ echo " - Feature branch: ${{ steps.init-feature.outcome || 'N/A' }}"
224+ echo " - Tag deployment: ${{ steps.init-tag.outcome || 'N/A' }}"
0 commit comments