1+ # SPDX-FileCopyrightText: (C) 2025 Intel Corporation
2+ # SPDX-License-Identifier: Apache-2.0
3+
4+ name : Component Tests
5+
6+ on :
7+ push :
8+ branches : [ main ]
9+ pull_request :
10+ branches : [ main ]
11+
12+ env :
13+ # Test environment configuration
14+ HARBOR_SERVER : https://harbor.kind.internal
15+ HARBOR_NAMESPACE : harbor
16+ HARBOR_ADMIN_CREDENTIAL : admin-secret
17+ KEYCLOAK_SERVER : https://keycloak.kind.internal
18+ KEYCLOAK_NAMESPACE : keycloak
19+ KEYCLOAK_SECRET : keycloak-secret
20+ VAULT_SERVER : https://vault.kind.internal
21+ CATALOG_SERVER : https://catalog.kind.internal
22+ ADM_SERVER : https://adm.kind.internal
23+ RS_ROOT_URL : oci://registry.kind.internal
24+ RS_PROXY_ROOT_URL : https://registry.kind.internal
25+ MANIFEST_PATH : /manifests
26+ MANIFEST_TAG : latest
27+ REGISTRY_HOST_EXTERNAL : https://harbor.kind.internal
28+ SERVICE_ACCOUNT : default
29+
30+ jobs :
31+ component-tests :
32+ runs-on : ubuntu-latest
33+ timeout-minutes : 45
34+
35+ strategy :
36+ matrix :
37+ go-version : ['1.21', '1.22']
38+
39+ steps :
40+ - name : Checkout code
41+ uses : actions/checkout@v4
42+
43+ - name : Set up Go ${{ matrix.go-version }}
44+ uses : actions/setup-go@v5
45+ with :
46+ go-version : ${{ matrix.go-version }}
47+
48+ - name : Cache Go modules
49+ uses : actions/cache@v4
50+ with :
51+ path : |
52+ ~/.cache/go-build
53+ ~/go/pkg/mod
54+ key : ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
55+ restore-keys : |
56+ ${{ runner.os }}-go-${{ matrix.go-version }}-
57+
58+ - name : Create KinD cluster
59+ 60+ with :
61+ cluster_name : kind
62+ config : .github/workflows/kind-config.yaml
63+
64+ - name : Install kubectl
65+ uses : azure/setup-kubectl@v4
66+ with :
67+ version : ' v1.29.0'
68+
69+ - name : Install Helm
70+ uses : azure/setup-helm@v4
71+ with :
72+ version : ' 3.13.0'
73+
74+ - name : Set up test infrastructure
75+ run : |
76+ # Install required CRDs and services for testing
77+ kubectl create namespace harbor --dry-run=client -o yaml | kubectl apply -f -
78+ kubectl create namespace keycloak --dry-run=client -o yaml | kubectl apply -f -
79+ kubectl create namespace orch-app --dry-run=client -o yaml | kubectl apply -f -
80+
81+ # Create mock services for testing
82+ kubectl apply -f .github/workflows/test-services.yaml
83+
84+ - name : Wait for test infrastructure
85+ run : |
86+ # Wait for mock services to be ready
87+ kubectl wait --for=condition=available --timeout=300s deployment/mock-harbor -n harbor
88+ kubectl wait --for=condition=available --timeout=300s deployment/mock-keycloak -n keycloak
89+ kubectl wait --for=condition=available --timeout=300s deployment/mock-catalog -n orch-app
90+
91+ - name : Set up port forwarding
92+ run : |
93+ # Set up port forwarding for test services
94+ kubectl port-forward -n harbor svc/mock-harbor 8080:80 &
95+ kubectl port-forward -n keycloak svc/mock-keycloak 8081:80 &
96+ kubectl port-forward -n orch-app svc/mock-catalog 8082:80 &
97+ sleep 10 # Give port forwarding time to establish
98+
99+ - name : Download dependencies
100+ run : |
101+ go mod download
102+ go mod vendor
103+
104+ - name : Build application
105+ run : |
106+ make go-build
107+
108+ - name : Run unit tests
109+ run : |
110+ make go-test
111+
112+ - name : Run component tests
113+ run : |
114+ make component-test
115+
116+ - name : Run component tests with coverage
117+ run : |
118+ make component-test-coverage
119+
120+ - name : Upload coverage reports
121+ uses : codecov/codecov-action@v4
122+ with :
123+ files : ./coverage.xml,./component-coverage.xml
124+ flags : component-tests
125+ name : component-coverage
126+ fail_ci_if_error : false
127+
128+ - name : Archive test results
129+ uses : actions/upload-artifact@v4
130+ if : always()
131+ with :
132+ name : component-test-results-go${{ matrix.go-version }}
133+ path : |
134+ coverage.xml
135+ component-coverage.xml
136+ *.log
137+
138+ - name : Cleanup
139+ if : always()
140+ run : |
141+ # Kill port forwarding processes
142+ pkill -f "kubectl port-forward" || true
143+ # Additional cleanup if needed
144+ kubectl delete namespace harbor keycloak orch-app --ignore-not-found=true
0 commit comments