1- name : Test
2-
3- on :
4- push :
5- branches : [ main, develop ]
6- tags :
7- - ' v*.*.*'
8- paths-ignore :
9- - ' **.md'
10- - ' docs/**'
11- - ' .github/ISSUE_TEMPLATE/**'
12-
13- pull_request :
14- branches : [ main, develop ]
15- paths-ignore :
16- - ' **.md'
17- - ' docs/**'
18- - ' .github/ISSUE_TEMPLATE/**'
19-
20- workflow_dispatch :
21- inputs :
22- debug :
23- description : ' Enable debug mode'
24- type : boolean
25- default : false
26-
27- permissions :
28- contents : read
29- pull-requests : write
30-
31- env :
32- DOCKER_BUILDKIT : 1
33- COMPOSE_DOCKER_CLI_BUILD : 1
34- DOCKER_IMAGE_TAG : " eks-helm-client:test"
35-
36- jobs :
37- unit-tests :
38- name : Unit Tests
39- runs-on : ubuntu-latest
40-
41- steps :
42- - name : Checkout
43- uses : actions/checkout@v4
44-
45- - name : Make scripts executable
46- run : |
47- chmod +x .github/scripts/testing/*.sh
48- chmod +x scripts/*.sh
49- chmod +x tests/unit/*.sh
50-
51- - name : Run Unit Tests
52- run : bash .github/scripts/testing/run-unit-tests.sh
53-
54- - name : Run Script Unit Tests
55- run : |
56- for test_script in tests/unit/test-*.sh; do
57- if [[ -f "$test_script" ]]; then
58- echo "Running $test_script"
59- bash "$test_script" || echo "Test $test_script failed but continuing..."
60- fi
61- done
62-
63- - name : Upload Test Results
64- if : always()
65- uses : actions/upload-artifact@v4
66- with :
67- name : unit-test-results
68- path : |
69- /tmp/eks-helm-test-*/test-results.txt
70- /tmp/template-test-*/
71- if-no-files-found : ignore
72-
73- integration-tests :
74- name : Integration Tests
75- runs-on : ubuntu-latest
76- needs : unit-tests
77-
78- steps :
79- - name : Checkout
80- uses : actions/checkout@v4
81-
82- - name : Set up Docker Buildx
83- uses : docker/setup-buildx-action@v3
84-
85- - name : Make scripts executable
86- run : |
87- chmod +x .github/scripts/testing/*.sh
88- chmod +x scripts/*.sh
89-
90- - name : Run Integration Tests
91- run : bash .github/scripts/testing/run-integration-tests.sh
92-
93- - name : Upload Docker Build Logs
94- if : failure()
95- uses : actions/upload-artifact@v4
96- with :
97- name : docker-build-logs
98- path : /tmp/docker-build-*.log
99- if-no-files-found : ignore
100-
101- action-validation :
102- name : Validate Action
103- runs-on : ubuntu-latest
104-
105- steps :
106- - name : Checkout
107- uses : actions/checkout@v4
108-
109- - name : Make validation script executable
110- run : chmod +x .github/scripts/testing/*.sh
111-
112- - name : Validate Action Configuration
113- run : bash .github/scripts/testing/validate-action.sh
114-
115- - name : Upload Validation Report
116- if : always()
117- uses : actions/upload-artifact@v4
118- with :
119- name : validation-report
120- path : validation-report.txt
121- if-no-files-found : ignore
122-
123- docker-test :
124- name : Docker Functionality Test
125- runs-on : ubuntu-latest
126- needs : integration-tests
127-
128- steps :
129- - name : Checkout
130- uses : actions/checkout@v4
131-
132- - name : Build Docker Image
133- uses : docker/build-push-action@v5
134- with :
135- context : .
136- push : false
137- load : true
138- tags : ${{ env.DOCKER_IMAGE_TAG }}
139-
140- test-summary :
141- name : Test Summary
142- runs-on : ubuntu-latest
143- needs : [unit-tests, integration-tests, action-validation, docker-test]
144- if : always()
145-
146- steps :
147- - name : Generate Job Summary
148- id : summary
149- run : |
150- echo "## 🧪 Test Summary" >> $GITHUB_STEP_SUMMARY
151- echo "| Test Suite | Status |" >> $GITHUB_STEP_SUMMARY
152- echo "|------------|--------|" >> $GITHUB_STEP_SUMMARY
153- echo "| Unit Tests | ${{ needs.unit-tests.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
154- echo "| Integration Tests | ${{ needs.integration-tests.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
155- echo "| Action Validation | ${{ needs.action-validation.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
156- echo "| Docker Tests | ${{ needs.docker-test.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
157-
158- # Determine overall status
159- if [[ "${{ needs.unit-tests.result }}" != "success" || \
160- "${{ needs.integration-tests.result }}" != "success" || \
161- "${{ needs.action-validation.result }}" != "success" || \
162- "${{ needs.docker-test.result }}" != "success" ]]; then
163- echo "status=failure" >> $GITHUB_OUTPUT
164- echo "" >> $GITHUB_STEP_SUMMARY
165- echo "❌ **Some tests failed!**" >> $GITHUB_STEP_SUMMARY
166- echo "" >> $GITHUB_STEP_SUMMARY
167- echo "### Failed Tests" >> $GITHUB_STEP_SUMMARY
168- [[ "${{ needs.unit-tests.result }}" != "success" ]] && echo "- Unit Tests" >> $GITHUB_STEP_SUMMARY
169- [[ "${{ needs.integration-tests.result }}" != "success" ]] && echo "- Integration Tests" >> $GITHUB_STEP_SUMMARY
170- [[ "${{ needs.action-validation.result }}" != "success" ]] && echo "- Action Validation" >> $GITHUB_STEP_SUMMARY
171- [[ "${{ needs.docker-test.result }}" != "success" ]] && echo "- Docker Tests" >> $GITHUB_STEP_SUMMARY
172- else
173- echo "status=success" >> $GITHUB_OUTPUT
174- echo "" >> $GITHUB_STEP_SUMMARY
175- echo "✅ **All tests passed!**" >> $GITHUB_STEP_SUMMARY
176-
177- - name : Fail workflow on test failure
178- if : steps.summary.outputs.status == 'failure'
179- run : |
180- echo "::error::One or more test suites failed. Check the job summary for details."
181- exit 1
182-
183- - name : Success notification
184- if : steps.summary.outputs.status == 'success'
185- run : |
186- echo "::notice::All tests passed successfully! 🎉"
0 commit comments