diff --git a/.github/workflows/logzio-monitoring-multi-env-test.yaml b/.github/workflows/logzio-monitoring-multi-env-test.yaml new file mode 100644 index 00000000..bc03441e --- /dev/null +++ b/.github/workflows/logzio-monitoring-multi-env-test.yaml @@ -0,0 +1,94 @@ +name: Test Logzio Monitoring Helm Chart on EKS Kubernetes Environments + +on: + pull_request: + branches: + - main + paths: + - 'charts/logzio-monitoring/**' +jobs: + test-helm-chart: + name: Test Helm Chart + runs-on: ubuntu-latest + strategy: + matrix: + environment: [eks-fargate, eks-linux, eks-windows] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.20' + + - name: Set up Helm + uses: azure/setup-helm@v4.2.0 + + - name: Set up kubectl + uses: azure/setup-kubectl@v3 + + - name: Set up eksctl + run: | + ARCH=amd64 + PLATFORM=$(uname -s)_$ARCH + curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz" + # (Optional) Verify checksum + curl -sL "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check + tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz + sudo mv /tmp/eksctl /usr/local/bin + + - name: Provision Cluster + id: provision + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + NUMBER_OF_NODES: 2 + AWS_REGION: us-east-1 + run: | + case ${{ matrix.environment }} in + eks-linux) + eksctl create cluster --name ${{ github.run_id }}-${{ matrix.environment }} --region $AWS_REGION --nodes $NUMBER_OF_NODES + aws eks --region $AWS_REGION update-kubeconfig --name ${{ github.run_id }}-${{ matrix.environment }} + ;; + eks-windows) + eksctl create cluster --name ${{ github.run_id }}-${{ matrix.environment }} --region $AWS_REGION --nodes $NUMBER_OF_NODES --node-ami-family WindowsServer2019FullContainer + aws eks --region $AWS_REGION update-kubeconfig --name ${{ github.run_id }}-${{ matrix.environment }} + ;; + eks-fargate) + eksctl create cluster --name ${{ github.run_id }}-${{ matrix.environment }} --region $AWS_REGION --fargate + aws eks --region $AWS_REGION update-kubeconfig --name ${{ github.run_id }}-${{ matrix.environment }} + ;; + esac + + - name: Deploy Helm Chart + run: | + cd charts/logzio-monitoring + helm upgrade --install \ + logzio-monitoring-${{ github.run_id }} . + + - name: Run Go Tests + env: + KUBERNETES_ENV: ${{ matrix.environment }} + ENV_ID: ${{ github.run_id }}-${{ matrix.environment }} + run: | + go test -v ./tests + - name: Cleanup Environment + run: | + helm uninstall my-release + + - name: Delete Cluster + if: always() + run: | + case ${{ matrix.environment }} in + eks-linux) + eksctl delete cluster --name ${{ github.run_id }}-${{ matrix.environment }} + ;; + eks-windows) + eksctl delete cluster --name ${{ github.run_id }}-${{ matrix.environment }} + ;; + eks-fargate) + eksctl delete cluster --name ${{ github.run_id }}-${{ matrix.environment }} + ;; + esac