From d349ab2eae26b17c75adcd6cbc82b85a9c5d033d Mon Sep 17 00:00:00 2001 From: Amit Lichtenberg Date: Mon, 17 Jun 2024 14:33:17 +0300 Subject: [PATCH 1/7] Create new tag on bump-version & publish helm charts only on tags --- .github/workflows/bump-version.yaml | 10 +++++++++- .github/workflows/{build.yaml => release.yaml} | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-) rename .github/workflows/{build.yaml => release.yaml} (89%) diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version.yaml index f091acdb..79be21a4 100644 --- a/.github/workflows/bump-version.yaml +++ b/.github/workflows/bump-version.yaml @@ -8,7 +8,7 @@ jobs: bump-chart-versions: name: Bump chart versions runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, 'nobump')" + if: "!contains(github.event.head_commit.message, '[nobump]')" steps: - name: Checkout uses: actions/checkout@v4 @@ -28,6 +28,7 @@ jobs: run: echo '${{ steps.changed-files.outputs.all_changed_files }}' - name: Bump operators helm chart versions + id: bump-versions env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | @@ -54,6 +55,7 @@ jobs: patch_version=$((${BASH_REMATCH[3]} + 1)) new_version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${patch_version}" sed -i "s#^version:.*#version: ${new_version}#g" "${chart_path}" + echo "otterize-kubernetes-version=${new_version}" >> "$GITHUB_OUTPUT" fi - name: Setup git config @@ -66,3 +68,9 @@ jobs: git add . git commit -m 'Bump chart versions [nobump]' git push origin + + - name: Tag version + run: | + tag="v${{ steps.bump-versions.outputs.otterize-kubernetes-version }}" + git tag -a ${tag} + git push origin ${tag} \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/release.yaml similarity index 89% rename from .github/workflows/build.yaml rename to .github/workflows/release.yaml index 728d0d4a..5c093556 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/release.yaml @@ -1,8 +1,8 @@ -name: Build & Release +name: release on: push: - branches: - - main + tags: + - v* jobs: release: @@ -10,6 +10,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Publish Helm charts uses: stefanprodan/helm-gh-pages@master with: From 839c74ea43a45e55b2557d339fedefc6085ea72c Mon Sep 17 00:00:00 2001 From: Amit Lichtenberg Date: Mon, 17 Jun 2024 14:58:22 +0300 Subject: [PATCH 2/7] Merge E2E tests into a single workflow --- .github/workflows/e2e-test-azure-iam.yaml | 74 --------------- .../e2e-test-database-integrations.yaml | 36 -------- .github/workflows/e2e-test.yaml | 91 ++++++++++++++++++- 3 files changed, 90 insertions(+), 111 deletions(-) delete mode 100644 .github/workflows/e2e-test-azure-iam.yaml delete mode 100644 .github/workflows/e2e-test-database-integrations.yaml diff --git a/.github/workflows/e2e-test-azure-iam.yaml b/.github/workflows/e2e-test-azure-iam.yaml deleted file mode 100644 index 0e116cf9..00000000 --- a/.github/workflows/e2e-test-azure-iam.yaml +++ /dev/null @@ -1,74 +0,0 @@ -name: E2E Tests for Azure IAM Integration -on: - pull_request: - types: - - opened - - synchronize - - reopened - - ready_for_review - - labeled - push: - branches: - - main - -concurrency: - group: ${{ github.workflow }} # do not allow concurrent runs of this workflow - cancel-in-progress: false - -jobs: - run-e2e-tests: - if: contains(github.event.pull_request.labels.*.name, 'run-azure-e2e-tests') || (github.event_name == 'push' && github.ref == 'refs/heads/main') - timeout-minutes: 5 - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Log in with Azure - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - name: Azure CLI script - uses: azure/CLI@v1 - with: - azcliversion: 2.0.72 - inlineScript: | - az account show - - - name: Set AKS context - uses: azure/aks-set-context@v3 - with: - resource-group: 'otterizeGitHubActionsResourceGroup' - cluster-name: 'otterizeAzureIAME2EAKSCluster' - - - name: Setup kubectl - uses: azure/setup-kubectl@v3 - - - name: Set up Helm - uses: azure/setup-helm@v3 - - - name: Setup go - uses: actions/setup-go@v4 - with: - go-version: 1.22.1 - cache-dependency-path: tests/go.sum - - - name: Set up gotestfmt - uses: GoTestTools/gotestfmt-action@v2 - with: - # Optional: pass GITHUB_TOKEN to avoid rate limiting. - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Helm dependency update - run: helm dep up ./otterize-kubernetes - - - name: Cleanup test namespaces - run: | - kubectl delete namespace otterize-tutorial-azure-iam --ignore-not-found=true --wait - kubectl delete namespace otterize-system --ignore-not-found=true --wait - - - name: Run tests - run: | - cd tests - go test -v -json ./azureiam/... | tee gotest.log | gotestfmt \ No newline at end of file diff --git a/.github/workflows/e2e-test-database-integrations.yaml b/.github/workflows/e2e-test-database-integrations.yaml deleted file mode 100644 index 5396f6eb..00000000 --- a/.github/workflows/e2e-test-database-integrations.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: E2E Test for Database Integrations -on: - pull_request: - types: - - opened - - synchronize - push: - branches: - - main - -jobs: - run-e2e-tests: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Start minikube - uses: medyagh/setup-minikube@master - - - name: Set up Helm - uses: azure/setup-helm@v3 - - - name: Set up gotestfmt - uses: GoTestTools/gotestfmt-action@v2 - with: - # Optional: pass GITHUB_TOKEN to avoid rate limiting. - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Helm dependency update - run: helm dep up ./otterize-kubernetes - - - name: Run E2E tests - run: | - cd tests - go test -v -json ./databases/... | tee gotest.log | gotestfmt \ No newline at end of file diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml index 1918a2f3..1dc985b8 100644 --- a/.github/workflows/e2e-test.yaml +++ b/.github/workflows/e2e-test.yaml @@ -4,6 +4,9 @@ on: types: - opened - synchronize + - reopened + - ready_for_review + - labeled push: branches: - main @@ -39,4 +42,90 @@ jobs: kubectl delete namespace otterize-system # clean up # installation - helm install otterize ./otterize-kubernetes -n otterize-system --wait --create-namespace --set global.telemetry.enabled=false \ No newline at end of file + helm install otterize ./otterize-kubernetes -n otterize-system --wait --create-namespace --set global.telemetry.enabled=false + + test-database-integrations: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Start minikube + uses: medyagh/setup-minikube@master + + - name: Set up Helm + uses: azure/setup-helm@v3 + + - name: Set up gotestfmt + uses: GoTestTools/gotestfmt-action@v2 + with: + # Optional: pass GITHUB_TOKEN to avoid rate limiting. + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Helm dependency update + run: helm dep up ./otterize-kubernetes + + - name: Run E2E tests - database integrations + run: | + cd tests + go test -v -json ./databases/... | tee gotest.log | gotestfmt + + test-azure-integration: + if: contains(github.event.pull_request.labels.*.name, 'run-azure-e2e-tests') || (github.event_name == 'push' && github.ref == 'refs/heads/main') + timeout-minutes: 5 + runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }} # do not allow concurrent runs of this job + cancel-in-progress: false + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in with Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Azure CLI script + uses: azure/CLI@v1 + with: + azcliversion: 2.0.72 + inlineScript: | + az account show + + - name: Set AKS context + uses: azure/aks-set-context@v3 + with: + resource-group: 'otterizeGitHubActionsResourceGroup' + cluster-name: 'otterizeAzureIAME2EAKSCluster' + + - name: Setup kubectl + uses: azure/setup-kubectl@v3 + + - name: Set up Helm + uses: azure/setup-helm@v3 + + - name: Setup go + uses: actions/setup-go@v4 + with: + go-version: 1.22.1 + cache-dependency-path: tests/go.sum + + - name: Set up gotestfmt + uses: GoTestTools/gotestfmt-action@v2 + with: + # Optional: pass GITHUB_TOKEN to avoid rate limiting. + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Helm dependency update + run: helm dep up ./otterize-kubernetes + + - name: Cleanup test namespaces + run: | + kubectl delete namespace otterize-tutorial-azure-iam --ignore-not-found=true --wait + kubectl delete namespace otterize-system --ignore-not-found=true --wait + + - name: Run tests + run: | + cd tests + go test -v -json ./azureiam/... | tee gotest.log | gotestfmt \ No newline at end of file From 501d5e061dc50610506b9abb8a2cc32494f8b613 Mon Sep 17 00:00:00 2001 From: Amit Lichtenberg Date: Mon, 17 Jun 2024 15:09:43 +0300 Subject: [PATCH 3/7] Bump setup-helm action version --- .github/workflows/e2e-test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml index 1dc985b8..7af57297 100644 --- a/.github/workflows/e2e-test.yaml +++ b/.github/workflows/e2e-test.yaml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Helm - uses: azure/setup-helm@v3 + uses: azure/setup-helm@v4.2.0 - name: Start minikube uses: medyagh/setup-minikube@master @@ -54,7 +54,7 @@ jobs: uses: medyagh/setup-minikube@master - name: Set up Helm - uses: azure/setup-helm@v3 + uses: azure/setup-helm@v4.2.0 - name: Set up gotestfmt uses: GoTestTools/gotestfmt-action@v2 @@ -103,7 +103,7 @@ jobs: uses: azure/setup-kubectl@v3 - name: Set up Helm - uses: azure/setup-helm@v3 + uses: azure/setup-helm@v4.2.0 - name: Setup go uses: actions/setup-go@v4 From a80fe1b35356757f4187a02928ebff9bffd18015 Mon Sep 17 00:00:00 2001 From: Amit Lichtenberg Date: Mon, 17 Jun 2024 15:19:02 +0300 Subject: [PATCH 4/7] Bump azure gh actions versions --- .github/workflows/e2e-test.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml index 7af57297..43f80675 100644 --- a/.github/workflows/e2e-test.yaml +++ b/.github/workflows/e2e-test.yaml @@ -82,25 +82,24 @@ jobs: uses: actions/checkout@v4 - name: Log in with Azure - uses: azure/login@v1 + uses: azure/login@v2 with: creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Azure CLI script - uses: azure/CLI@v1 + uses: azure/CLI@v2 with: - azcliversion: 2.0.72 inlineScript: | az account show - name: Set AKS context - uses: azure/aks-set-context@v3 + uses: azure/aks-set-context@v4 with: resource-group: 'otterizeGitHubActionsResourceGroup' cluster-name: 'otterizeAzureIAME2EAKSCluster' - name: Setup kubectl - uses: azure/setup-kubectl@v3 + uses: azure/setup-kubectl@v4 - name: Set up Helm uses: azure/setup-helm@v4.2.0 @@ -125,7 +124,7 @@ jobs: kubectl delete namespace otterize-tutorial-azure-iam --ignore-not-found=true --wait kubectl delete namespace otterize-system --ignore-not-found=true --wait - - name: Run tests + - name: Run E2E tests - azure integrations run: | cd tests go test -v -json ./azureiam/... | tee gotest.log | gotestfmt \ No newline at end of file From 28d46f96921d2c727371be85848784adc81429bd Mon Sep 17 00:00:00 2001 From: Amit Lichtenberg Date: Mon, 17 Jun 2024 15:24:41 +0300 Subject: [PATCH 5/7] Bump setup-go gh action version --- .github/workflows/e2e-test.yaml | 2 +- .github/workflows/lint.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml index 43f80675..89534e72 100644 --- a/.github/workflows/e2e-test.yaml +++ b/.github/workflows/e2e-test.yaml @@ -105,7 +105,7 @@ jobs: uses: azure/setup-helm@v4.2.0 - name: Setup go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.22.1 cache-dependency-path: tests/go.sum diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 74b6047c..b27f8954 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v4 - name: Setup go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.22.1 cache-dependency-path: tests/go.sum From d480f38bf52a549565cb818c246e9423c276a931 Mon Sep 17 00:00:00 2001 From: Amit Lichtenberg Date: Mon, 17 Jun 2024 15:30:52 +0300 Subject: [PATCH 6/7] Require e2e tests before publishing helm charts --- .github/workflows/release.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5c093556..da7782ce 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,8 +5,15 @@ on: - v* jobs: + e2e-tests: + uses: ./.github/workflows/e2e-tests.yaml + name: Trigger e2e tests + release: runs-on: ubuntu-latest + needs: + - e2e-tests + steps: - name: Checkout uses: actions/checkout@v4 From 3b8e0a0a9f527aa5477413d8fa7c96703417b406 Mon Sep 17 00:00:00 2001 From: Amit Lichtenberg Date: Mon, 17 Jun 2024 15:55:37 +0300 Subject: [PATCH 7/7] Disable telemetry on E2E tests --- tests/azureiam/azureiam_test.go | 3 +++ tests/databases/postgres/postgres_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/azureiam/azureiam_test.go b/tests/azureiam/azureiam_test.go index d1538295..90cd5015 100644 --- a/tests/azureiam/azureiam_test.go +++ b/tests/azureiam/azureiam_test.go @@ -141,6 +141,9 @@ func (s *AzureIAMTestSuite) installOtterizeForAzureIAM() { "deployment": map[string]any{ "networkMapper": false, }, + "telemetry": map[string]interface{}{ + "enabled": false, + }, }, } diff --git a/tests/databases/postgres/postgres_test.go b/tests/databases/postgres/postgres_test.go index 0512dc6e..8d0b3647 100644 --- a/tests/databases/postgres/postgres_test.go +++ b/tests/databases/postgres/postgres_test.go @@ -60,6 +60,9 @@ func (s *PostgresTestSuite) installOtterizeNetworkMapperDisabled() { "deployment": map[string]interface{}{ "networkMapper": false, }, + "telemetry": map[string]interface{}{ + "enabled": false, + }, }, } s.InstallOtterizeHelmChart(values)