Skip to content

Commit 9497931

Browse files
committed
wip
1 parent 548bd4e commit 9497931

File tree

1 file changed

+185
-0
lines changed

1 file changed

+185
-0
lines changed
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
name: Cross-Cloud Chainsaw Tests
2+
3+
on:
4+
workflow_call: # Workflow trigger
5+
workflow_dispatch: # Manual trigger
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
11+
jobs:
12+
build-images:
13+
uses: ./.github/workflows/build-dev-images.yml
14+
15+
test:
16+
runs-on: warp-ubuntu-latest-x64-8x-spot
17+
18+
strategy:
19+
matrix:
20+
cloud-provider: [eks] # Add or remove providers as needed [TODO: later add -> gke]
21+
test-scenario: [helm-chart] # Add or remove scenarios as needed
22+
fail-fast: false # In case 1 matrix job fails, the other matrix jobs will continue to run
23+
24+
steps:
25+
- name: Checkout Code
26+
uses: actions/checkout@v4
27+
28+
- name: Set Environment Variables for Terraform
29+
run: |
30+
CLUSTER_NAME="${{ matrix.test-scenario }}-${{ github.run_id }}"
31+
echo "CLUSTER_NAME=${CLUSTER_NAME}" >> $GITHUB_ENV
32+
if [ "${{ matrix.cloud-provider }}" = "eks" ]; then
33+
echo "TF_VAR_region=us-east-1" >> $GITHUB_ENV
34+
fi
35+
echo "TF_VAR_cluster_name=${CLUSTER_NAME}" >> $GITHUB_ENV
36+
echo "TF_VAR_resource_group_name=${CLUSTER_NAME}" >> $GITHUB_ENV
37+
echo "TF_VAR_test_scenario=${{ matrix.test-scenario }}" >> $GITHUB_ENV
38+
echo "TF_VAR_run_id=${{ github.run_id }}" >> $GITHUB_ENV
39+
40+
- name: Configure AWS Credentials for EKS
41+
if: ${{ matrix.cloud-provider == 'eks' }}
42+
uses: aws-actions/configure-aws-credentials@v4
43+
with:
44+
role-to-assume: arn:aws:iam::061717858829:role/GitHubActionsEKSCreatorRole
45+
aws-region: us-east-1
46+
47+
- name: Configure Cloud Provider
48+
run: |
49+
if [ "${{ matrix.cloud-provider }}" = "aks" ]; then
50+
echo "Configuring for AKS"
51+
52+
# Set environment variables for Azure provider
53+
echo "ARM_CLIENT_ID=${{ secrets.AZURE_CLIENT_ID }}" >> $GITHUB_ENV
54+
echo "ARM_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }}" >> $GITHUB_ENV
55+
echo "ARM_TENANT_ID=${{ secrets.AZURE_TENANT_ID }}" >> $GITHUB_ENV
56+
echo "ARM_SUBSCRIPTION_ID=${{ secrets.AZURE_SUBSCRIPTION_ID }}" >> $GITHUB_ENV
57+
58+
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
59+
az account set --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}
60+
61+
elif [ "${{ matrix.cloud-provider }}" = "eks" ]; then
62+
echo "Configuring for EKS"
63+
aws sts get-caller-identity
64+
65+
elif [ "${{ matrix.cloud-provider }}" = "gke" ]; then
66+
echo "Configuring for GKE"
67+
echo "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" | base64 --decode > gcp-key.json
68+
gcloud auth activate-service-account --key-file=gcp-key.json
69+
gcloud config set project ${{ secrets.GCP_PROJECT_ID }}
70+
71+
else
72+
echo "Unknown cloud provider: ${{ matrix.cloud-provider }}"
73+
exit 1
74+
fi
75+
76+
- uses: opentofu/setup-opentofu@v1
77+
78+
- name: Set Terraform Directory Based on Cloud Provider
79+
run: |
80+
if [ "${{ matrix.cloud-provider }}" == "aks" ]; then
81+
echo "TF_DIR=./tests-infrastructure/terraform/aks" >> $GITHUB_ENV
82+
elif [ "${{ matrix.cloud-provider }}" == "eks" ]; then
83+
echo "TF_DIR=./tests-infrastructure/terraform/eks" >> $GITHUB_ENV
84+
elif [ "${{ matrix.cloud-provider }}" == "gke" ]; then
85+
echo "TF_DIR=./tests-infrastructure/terraform/gke" >> $GITHUB_ENV
86+
else
87+
echo "Unknown cloud provider"
88+
exit 1
89+
fi
90+
91+
- name: Initialize OpenTofu
92+
run: tofu -chdir=$TF_DIR init
93+
94+
- name: Plan OpenTofu
95+
run: tofu -chdir=$TF_DIR plan
96+
97+
- name: Apply OpenTofu Configuration
98+
run: |
99+
tofu -chdir=$TF_DIR apply -auto-approve
100+
101+
- name: Get kubeconfig for AKS/EKS/GKE
102+
run: |
103+
if [ "${{ matrix.cloud-provider }}" == "aks" ]; then
104+
echo "Fetching AKS kubeconfig..."
105+
az aks get-credentials --resource-group $CLUSTER_NAME --name $CLUSTER_NAME
106+
elif [ "${{ matrix.cloud-provider }}" == "eks" ]; then
107+
echo "Fetching EKS kubeconfig..."
108+
aws eks update-kubeconfig --region us-east-1 --name $CLUSTER_NAME
109+
elif [ "${{ matrix.cloud-provider }}" == "gke" ]; then
110+
echo "Fetching GKE kubeconfig..."
111+
else
112+
echo "Unknown cloud provider"
113+
exit 1
114+
fi
115+
116+
- name: Verify cluster Access
117+
run: |
118+
kubectl get nodes || exit 1
119+
120+
- name: Install Chainsaw
121+
uses: kyverno/action-install-chainsaw@v0.2.12
122+
123+
- name: Build Odigos CLI
124+
uses: ./.github/actions/odigos/build/cli
125+
126+
- name: Install FE
127+
# this is used for cypress tests which are not run in every scenario
128+
if: matrix.test-scenario == 'multi-apps' || matrix.test-scenario == 'helm-chart'
129+
run: |
130+
cd frontend/webapp
131+
yarn install
132+
133+
- name: Run E2E Tests
134+
run: |
135+
136+
# This uses in chainsaw to split e2e tests from cross cloud tests
137+
export MODE=cross-cloud-tests
138+
139+
# This uses in chainsaw to verify the odigos version is equal to the commit version
140+
export COMMIT_HASH=${{ github.sha }}
141+
142+
chainsaw test tests/e2e/${{ matrix.test-scenario }}
143+
144+
- name: Run diagnose command
145+
if: always()
146+
run: |
147+
./cli/odigos diagnose
148+
continue-on-error: true
149+
150+
- name: Upload run details artifact
151+
if: always()
152+
uses: actions/upload-artifact@v4
153+
with:
154+
name: run-details-${{ matrix.cloud-provider }}-${{ matrix.test-scenario }}
155+
path: odigos_debug*.tar.gz
156+
continue-on-error: true
157+
158+
- name: Destroy Resources
159+
if: always()
160+
run: |
161+
tofu -chdir=$TF_DIR destroy -auto-approve
162+
163+
- name: Extract Tag
164+
id: extract_tag
165+
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
166+
167+
# Notify Slack on Failure
168+
- name: Notify Slack on Failure or Cancellation
169+
if: ${{ failure() }}
170+
env:
171+
SLACK_WEBHOOK_URL: ${{ secrets.CLOUD_PROVIDERS_TESTS_WEBHOOK_URL }}
172+
GITHUB_REPOSITORY: ${{ github.repository }}
173+
GITHUB_RUN_ID: ${{ github.run_id }}
174+
run: |
175+
curl -X POST -H 'Content-type: application/json' --data '{"blocks":[{"type":"section","text":{"type":"mrkdwn","text":"*ERROR*: Providers tests fail > `${{ matrix.cloud-provider }} - ${{ matrix.test-scenario }}`"}},{"type":"section","fields":[{"type":"mrkdwn","text":"*Link:*\n<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|View the GitHub Run>"},{"type":"mrkdwn","text":"*Tag:*\n`${{ steps.extract_tag.outputs.tag }}`"}]}]}' ${{ env.SLACK_WEBHOOK_URL }}
176+
177+
# Notify Slack on Success
178+
- name: Notify Slack on Success
179+
if: ${{ success() }}
180+
env:
181+
SLACK_WEBHOOK_URL: ${{ secrets.CLOUD_PROVIDERS_TESTS_WEBHOOK_URL }}
182+
GITHUB_REPOSITORY: ${{ github.repository }}
183+
GITHUB_RUN_ID: ${{ github.run_id }}
184+
run: |
185+
curl -X POST -H 'Content-type: application/json' --data '{"blocks":[{"type":"section","text":{"type":"mrkdwn","text":"*SUCCESS*: Providers tests succeed > `${{ matrix.cloud-provider }} - ${{ matrix.test-scenario }}`"}},{"type":"section","fields":[{"type":"mrkdwn","text":"*Link:*\n<https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}|View the GitHub Run>"},{"type":"mrkdwn","text":"*Tag:*\n`${{ steps.extract_tag.outputs.tag }}`"}]}]}' ${{ env.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)