|
| 1 | +name: Test Logzio Monitoring Helm Chart on EKS Kubernetes Environments |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'charts/logzio-monitoring/**' |
| 9 | +jobs: |
| 10 | + test-helm-chart: |
| 11 | + name: Test Helm Chart |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + environment: [eks-fargate, eks-linux, eks-windows] |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Set up Go |
| 22 | + uses: actions/setup-go@v5 |
| 23 | + with: |
| 24 | + go-version: '1.20' |
| 25 | + |
| 26 | + - name: Set up Helm |
| 27 | + |
| 28 | + |
| 29 | + - name: Set up kubectl |
| 30 | + uses: azure/setup-kubectl@v3 |
| 31 | + |
| 32 | + - name: Set up eksctl |
| 33 | + run: | |
| 34 | + ARCH=amd64 |
| 35 | + PLATFORM=$(uname -s)_$ARCH |
| 36 | + curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz" |
| 37 | + # (Optional) Verify checksum |
| 38 | + curl -sL "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check |
| 39 | + tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz |
| 40 | + sudo mv /tmp/eksctl /usr/local/bin |
| 41 | +
|
| 42 | + - name: Provision Cluster |
| 43 | + id: provision |
| 44 | + env: |
| 45 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 46 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 47 | + NUMBER_OF_NODES: 2 |
| 48 | + AWS_REGION: us-east-1 |
| 49 | + run: | |
| 50 | + case ${{ matrix.environment }} in |
| 51 | + eks-linux) |
| 52 | + eksctl create cluster --name ${{ github.run_id }}-${{ matrix.environment }} --region $AWS_REGION --nodes $NUMBER_OF_NODES |
| 53 | + aws eks --region $AWS_REGION update-kubeconfig --name ${{ github.run_id }}-${{ matrix.environment }} |
| 54 | + ;; |
| 55 | + eks-windows) |
| 56 | + eksctl create cluster --name ${{ github.run_id }}-${{ matrix.environment }} --region $AWS_REGION --nodes $NUMBER_OF_NODES --node-ami-family WindowsServer2019FullContainer |
| 57 | + aws eks --region $AWS_REGION update-kubeconfig --name ${{ github.run_id }}-${{ matrix.environment }} |
| 58 | + ;; |
| 59 | + eks-fargate) |
| 60 | + eksctl create cluster --name ${{ github.run_id }}-${{ matrix.environment }} --region $AWS_REGION --fargate |
| 61 | + aws eks --region $AWS_REGION update-kubeconfig --name ${{ github.run_id }}-${{ matrix.environment }} |
| 62 | + ;; |
| 63 | + esac |
| 64 | +
|
| 65 | + - name: Deploy Helm Chart |
| 66 | + run: | |
| 67 | + cd charts/logzio-monitoring |
| 68 | + helm upgrade --install \ |
| 69 | + logzio-monitoring-${{ github.run_id }} . |
| 70 | +
|
| 71 | + - name: Run Go Tests |
| 72 | + env: |
| 73 | + KUBERNETES_ENV: ${{ matrix.environment }} |
| 74 | + ENV_ID: ${{ github.run_id }}-${{ matrix.environment }} |
| 75 | + run: | |
| 76 | + go test -v ./tests |
| 77 | + - name: Cleanup Environment |
| 78 | + run: | |
| 79 | + helm uninstall my-release |
| 80 | +
|
| 81 | + - name: Delete Cluster |
| 82 | + if: always() |
| 83 | + run: | |
| 84 | + case ${{ matrix.environment }} in |
| 85 | + eks-linux) |
| 86 | + eksctl delete cluster --name ${{ github.run_id }}-${{ matrix.environment }} |
| 87 | + ;; |
| 88 | + eks-windows) |
| 89 | + eksctl delete cluster --name ${{ github.run_id }}-${{ matrix.environment }} |
| 90 | + ;; |
| 91 | + eks-fargate) |
| 92 | + eksctl delete cluster --name ${{ github.run_id }}-${{ matrix.environment }} |
| 93 | + ;; |
| 94 | + esac |
0 commit comments