Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teams/integration tests #1361

Merged
merged 13 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/actions/setup-go-mod-private/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Go modules setup for e2e tests
description: Download botkube-cloud private repository

inputs:
username:
description: GitHub username used for cloning private repositories
required: true
access_token:
description: GitHub personal access token used for cloning private repositories
required: true

runs:
using: "composite"
steps:
- name: Download Go modules with private repository
shell: bash
run: |
go env -w GOPRIVATE=github.com/kubeshop/botkube-cloud
git config --global url."https://${{ inputs.username }}:${{ inputs.access_token }}@github.com".insteadOf "https://github.com"
go mod download
50 changes: 38 additions & 12 deletions .github/workflows/branch-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ env:
K3D_VERSION: v5.4.6
IMAGE_REGISTRY: "ghcr.io"
IMAGE_REPOSITORY: "kubeshop/botkube"
CFG_EXPORTER_IMAGE_REPOSITORY: "kubeshop/botkube-config-exporter"
IMAGE_TAG: v9.99.9-dev # TODO: Use commit hash tag to make the predictable builds for each commit on branch
GIT_USER: botkube-dev

jobs:
extract-metadata:
if: github.event_name != 'repository_dispatch' # skip if triggered by repository_dispatch
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.extract-version.outputs.versions }}
Expand All @@ -31,6 +32,7 @@ jobs:
IMAGE_VERSION=$(git rev-parse --short HEAD)
echo "versions={\"image-version\":[\"v9.99.9-dev\",\"0.0.0-${IMAGE_VERSION}\"]}" >> $GITHUB_OUTPUT
build:
if: github.event_name != 'repository_dispatch' # skip if triggered by repository_dispatch
needs: [extract-metadata]
strategy:
matrix: ${{ fromJson(needs.extract-metadata.outputs.versions) }}
Expand Down Expand Up @@ -68,16 +70,13 @@ jobs:
ANALYTICS_API_KEY: ${{ secrets.ANALYTICS_API_KEY }}
GORELEASER_CURRENT_TAG: ${{ matrix.image-version }}
IMAGE_TAG: ${{ matrix.image-version }}
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: ${{ env.HELM_VERSION }}


integration-tests:
if: github.event_name != 'repository_dispatch' # skip if triggered by repository_dispatch
name: Integration tests
runs-on: ubuntu-latest
needs: [ build ]
if: github.event_name != 'repository_dispatch' # skip if triggered by repository_dispatch
permissions:
contents: read
packages: read
Expand All @@ -90,6 +89,7 @@ jobs:
integration:
- slack
- discord
- teams

steps:
- name: Checkout code
Expand All @@ -103,6 +103,18 @@ jobs:
go-version-file: 'go.mod'
cache: true

- name: Setup Go modules
uses: ./.github/actions/setup-go-mod-private
with:
access_token: ${{ secrets.E2E_TEST_GH_DEV_ACCOUNT_PAT }}
username: ${{ env.GIT_USER }}

- name: Pub/Sub auth
uses: 'google-github-actions/auth@v1'
if: matrix.integration == 'teams'
with:
credentials_json: ${{ secrets.E2E_TEST_GCP_PUB_SUB_CREDENTIALS }}

- name: Install Helm
uses: azure/setup-helm@v3
with:
Expand All @@ -114,15 +126,14 @@ jobs:
- name: Create cluster to test ${{ matrix.integration }}
run: "k3d cluster create ${{ matrix.integration }}-test-cluster --wait --timeout=5m"

- name: Install Botkube to test ${{ matrix.integration }}
- name: Install Botkube locally via helm
if: matrix.integration == 'discord'
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_BOT_ID: ${{ secrets.DISCORD_BOT_ID }}
run: |
helm install botkube --namespace botkube ./helm/botkube --wait --create-namespace \
-f ./helm/botkube/e2e-test-values.yaml \
--set communications.default-group.slack.token="${SLACK_BOT_TOKEN}" \
--set communications.default-group.discord.token="${DISCORD_BOT_TOKEN}" \
--set communications.default-group.discord.botID="${DISCORD_BOT_ID}" \
--set image.registry="${IMAGE_REGISTRY}" \
Expand Down Expand Up @@ -166,9 +177,17 @@ jobs:
SLACK_TESTER_APP_TOKEN: ${{ secrets.SLACK_TESTER_APP_TOKEN }}
SLACK_CLOUD_TESTER_APP_TOKEN: ${{ secrets.SLACK_CLOUD_TESTER_APP_TOKEN }}
SLACK_ADDITIONAL_CONTEXT_MESSAGE: "Branch test - commit SHA: ${{github.sha}} - https://github.com/kubeshop/botkube/commit/${{github.sha}}"

DISCORD_TESTER_APP_TOKEN: ${{ secrets.DISCORD_TESTER_APP_TOKEN }}
DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }}
DISCORD_ADDITIONAL_CONTEXT_MESSAGE: "Branch test - commit SHA: ${{github.sha}} - https://github.com/kubeshop/botkube/commit/${{github.sha}}"

TEAMS_BOT_TESTER_APP_ID: ${{ secrets.TEAMS_BOT_TESTER_APP_ID }}
TEAMS_BOT_TESTER_APP_PASSWORD: ${{ secrets.TEAMS_BOT_TESTER_APP_PASSWORD }}
TEAMS_ORGANIZATION_TEAM_ID: ${{ secrets.TEAMS_ORGANIZATION_TEAM_ID }}
TEAMS_ORGANIZATION_TENANT_ID: ${{ secrets.TEAMS_ORGANIZATION_TENANT_ID }}
TEAMS_ADDITIONAL_CONTEXT_MESSAGE: "Branch test - commit SHA: ${{github.sha}} - https://github.com/kubeshop/botkube/commit/${{github.sha}}"

PLUGINS_BINARIES_DIRECTORY: ${{ github.workspace }}/plugin-dist
CONFIG_PROVIDER_API_KEY: ${{ secrets.CONFIG_PROVIDER_API_KEY }}
CONFIG_PROVIDER_ENDPOINT: ${{ secrets.CONFIG_PROVIDER_ENDPOINT }}
Expand All @@ -192,9 +211,6 @@ jobs:
cancel-in-progress: false
strategy:
fail-fast: false
matrix:
e2e:
- discord
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -210,6 +226,11 @@ jobs:
with:
go-version-file: 'go.mod'
cache: true
- name: Setup Go modules
uses: ./.github/actions/setup-go-mod-private
with:
access_token: ${{ secrets.E2E_TEST_GH_DEV_ACCOUNT_PAT }}
username: ${{ env.GIT_USER }}
- name: Run GoReleaser
run: make release-snapshot-cli
- name: Add botkube alias
Expand Down Expand Up @@ -271,6 +292,11 @@ jobs:
group: cloud-slack-dev-e2e
cancel-in-progress: false
steps:
- name: Setup Go modules
uses: ./.github/actions/setup-go-mod-private
with:
access_token: ${{ secrets.E2E_TEST_GH_DEV_ACCOUNT_PAT }}
username: ${{ env.GIT_USER }}
- name: Checkout
uses: actions/checkout@v3

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
HELM_VERSION: v3.9.0
GOLANGCI_LINT_VERSION: v1.54.2
GOLANGCI_LINT_TIMEOUT: 10m
GIT_USER: botkube-dev

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || 'branch' }} # scope to for the current workflow
Expand All @@ -27,6 +28,11 @@ jobs:
- name: Verify Go modules
run: go mod verify
if: always()
- name: Setup Go modules
uses: ./.github/actions/setup-go-mod-private
with:
access_token: ${{ secrets.E2E_TEST_GH_DEV_ACCOUNT_PAT }}
username: ${{ env.GIT_USER }}
- name: Run Go import formatting
run: make go-import-fmt
if: always()
Expand Down
30 changes: 23 additions & 7 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ env:
PR_NUMBER: ${{ github.event.pull_request.number }}
IMAGE_REGISTRY: "ghcr.io"
IMAGE_REPOSITORY: "kubeshop/pr/botkube"
CFG_EXPORTER_IMAGE_REPOSITORY: "kubeshop/pr/botkube-config-exporter"
IMAGE_TAG: ${{ github.event.pull_request.number }}-PR
IMAGE_SAVE_LOAD_DIR: /tmp/botkube-images
GIT_USER: botkube-dev

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || 'branch' }} # scope to for the current workflow
Expand Down Expand Up @@ -195,6 +195,7 @@ jobs:
integration:
- slack
- discord
- teams

steps:
- name: Checkout code
Expand All @@ -209,6 +210,18 @@ jobs:
go-version-file: 'go.mod'
cache: true

- name: Setup Go modules
uses: ./.github/actions/setup-go-mod-private
with:
access_token: ${{ secrets.E2E_TEST_GH_DEV_ACCOUNT_PAT }}
username: ${{ env.GIT_USER }}

- name: Pub/Sub auth
uses: 'google-github-actions/auth@v1'
if: matrix.integration == 'teams'
with:
credentials_json: ${{ secrets.E2E_TEST_GCP_PUB_SUB_CREDENTIALS }}

- name: Install Helm
uses: azure/setup-helm@v3
with:
Expand All @@ -221,14 +234,13 @@ jobs:
run: "k3d cluster create ${{ matrix.integration }}-test-cluster --wait --timeout=5m"

- name: Install Botkube to test ${{ matrix.integration }}
if: matrix.integration == 'discord'
mszostok marked this conversation as resolved.
Show resolved Hide resolved
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_BOT_ID: ${{ secrets.DISCORD_BOT_ID }}
run: |
helm install botkube --namespace botkube ./helm/botkube --wait --create-namespace \
-f ./helm/botkube/e2e-test-values.yaml \
--set communications.default-group.slack.token="${SLACK_BOT_TOKEN}" \
--set communications.default-group.discord.token="${DISCORD_BOT_TOKEN}" \
--set communications.default-group.discord.botID="${DISCORD_BOT_ID}" \
--set image.registry="${IMAGE_REGISTRY}" \
Expand Down Expand Up @@ -272,9 +284,17 @@ jobs:
SLACK_TESTER_APP_TOKEN: ${{ secrets.SLACK_TESTER_APP_TOKEN }}
SLACK_CLOUD_TESTER_APP_TOKEN: ${{ secrets.SLACK_CLOUD_TESTER_APP_TOKEN }}
SLACK_ADDITIONAL_CONTEXT_MESSAGE: "Pull request: ${{ github.event.pull_request.number }} - https://github.com/kubeshop/botkube/pull/${{ github.event.pull_request.number }}"

DISCORD_TESTER_APP_TOKEN: ${{ secrets.DISCORD_TESTER_APP_TOKEN }}
DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }}
DISCORD_ADDITIONAL_CONTEXT_MESSAGE: "Pull request: ${{ github.event.pull_request.number }} - https://github.com/kubeshop/botkube/pull/${{ github.event.pull_request.number }}"

TEAMS_BOT_TESTER_APP_ID: ${{ secrets.TEAMS_BOT_TESTER_APP_ID }}
TEAMS_BOT_TESTER_APP_PASSWORD: ${{ secrets.TEAMS_BOT_TESTER_APP_PASSWORD }}
TEAMS_ORGANIZATION_TEAM_ID: ${{ secrets.TEAMS_ORGANIZATION_TEAM_ID }}
TEAMS_ORGANIZATION_TENANT_ID: ${{ secrets.TEAMS_ORGANIZATION_TENANT_ID }}
TEAMS_ADDITIONAL_CONTEXT_MESSAGE: "Branch test - commit SHA: ${{github.sha}} - https://github.com/kubeshop/botkube/commit/${{github.sha}}"

PLUGINS_BINARIES_DIRECTORY: ${{ github.workspace }}/plugin-dist
CONFIG_PROVIDER_API_KEY: ${{ secrets.CONFIG_PROVIDER_API_KEY }}
CONFIG_PROVIDER_ENDPOINT: ${{ secrets.CONFIG_PROVIDER_ENDPOINT }}
Expand All @@ -284,7 +304,3 @@ jobs:
run: |
KUBECONFIG=$(k3d kubeconfig write ${{ matrix.integration }}-test-cluster) \
make test-integration-${{ matrix.integration }}

- name: Dump cluster
if: ${{ failure() }}
uses: ./.github/actions/dump-cluster
1 change: 0 additions & 1 deletion .github/workflows/prod-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ env:
K3D_VERSION: v5.4.6
IMAGE_REGISTRY: "ghcr.io"
IMAGE_REPOSITORY: "kubeshop/botkube"
CFG_EXPORTER_IMAGE_REPOSITORY: "kubeshop/botkube-config-exporter"
IMAGE_TAG: v9.99.9-dev # TODO: Use commit hash tag to make the predictable builds for each commit on branch

jobs:
Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ test: system-check
@go test -v -race ./...

test-integration-slack: system-check
@go test -timeout=20m -v -tags=integration -race -count=1 ./test/e2e/... -run "TestSlack"
@cd ./test; go test -timeout=20m -v -tags=integration -race -count=1 ./e2e/... -run "TestSlack"

test-integration-discord: system-check
@go test -timeout=20m -v -tags=integration -race -count=1 ./test/e2e/... -run "TestDiscord"
@cd ./test; go test -timeout=20m -v -tags=integration -race -count=1 ./e2e/... -run "TestDiscord"

test-integration-teams: system-check

@cd ./test; go test -timeout=20m -v -tags=integration -race -count=1 ./e2e/... -run "TestTeams"

test-cli-migration-e2e: system-check
@go test -v -tags=migration -race -count=1 ./test/e2e/...
@cd ./test; go test -v -tags=migration -race -count=1 ./e2e/...

test-cloud-slack-dev-e2e: system-check
@go test -tags=cloud_slack_dev_e2e -race -p 1 -v -timeout 30m ./test/cloud-slack-dev-e2e/...
@cd ./test; go test -tags=cloud_slack_dev_e2e -race -p 1 -v -timeout 30m ./cloud-slack-dev-e2e/...

test-cloud-slack-dev-e2e-show-browser: system-check
@go test -tags=cloud_slack_dev_e2e -race -p 1 -v -timeout 30m -rod=show ./test/cloud-slack-dev-e2e/...
@cd ./test; go test -tags=cloud_slack_dev_e2e -race -p 1 -v -timeout 30m -rod=show ./cloud-slack-dev-e2e/...

# Build Botkube official plugins for all supported platforms.
build-plugins: pre-build gen-plugins-goreleaser
Expand Down
4 changes: 2 additions & 2 deletions cmd/botkube-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ import (
"github.com/kubeshop/botkube/internal/config/remote"
"github.com/kubeshop/botkube/internal/health"
"github.com/kubeshop/botkube/internal/heartbeat"
"github.com/kubeshop/botkube/internal/httpx"
"github.com/kubeshop/botkube/internal/insights"
"github.com/kubeshop/botkube/internal/kubex"
"github.com/kubeshop/botkube/internal/loggerx"
"github.com/kubeshop/botkube/internal/plugin"
"github.com/kubeshop/botkube/internal/source"
"github.com/kubeshop/botkube/internal/status"
Expand All @@ -44,6 +42,8 @@ import (
"github.com/kubeshop/botkube/pkg/config"
"github.com/kubeshop/botkube/pkg/controller"
"github.com/kubeshop/botkube/pkg/execute"
"github.com/kubeshop/botkube/pkg/httpx"
"github.com/kubeshop/botkube/pkg/loggerx"
"github.com/kubeshop/botkube/pkg/maputil"
"github.com/kubeshop/botkube/pkg/multierror"
"github.com/kubeshop/botkube/pkg/notifier"
Expand Down
12 changes: 6 additions & 6 deletions cmd/executor/exec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"github.com/kubeshop/botkube/internal/executor/x/getter"
"github.com/kubeshop/botkube/internal/executor/x/output"
"github.com/kubeshop/botkube/internal/executor/x/state"
"github.com/kubeshop/botkube/internal/loggerx"
"github.com/kubeshop/botkube/pkg/api"
"github.com/kubeshop/botkube/pkg/api/executor"
"github.com/kubeshop/botkube/pkg/formatx"
"github.com/kubeshop/botkube/pkg/loggerx"
"github.com/kubeshop/botkube/pkg/pluginx"
)

Expand All @@ -34,16 +34,16 @@ func (i *XExecutor) Help(_ context.Context) (api.Message, error) {
Usage:
exec run [COMMAND] [FLAGS] Run a specified command with optional flags
exec install [SOURCE] Install a binary using the https://github.com/zyedidia/eget syntax.

Usage Examples:
# Install the Helm CLI

exec install https://get.helm.sh/helm-v3.10.3-linux-amd64.tar.gz --file helm
exec install https://get.helm.sh/helm-v3.10.3-linux-amd64.tar.gz --file helm

# Run the 'helm list -A' command.

exec run helm list -A
exec run helm list -A

Options:
-h, --help Show this help message`)
return api.NewCodeBlockMessage(help, true), nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/executor/flux/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/hashicorp/go-plugin"

"github.com/kubeshop/botkube/internal/executor/flux"
"github.com/kubeshop/botkube/internal/loggerx"
"github.com/kubeshop/botkube/pkg/api/executor"
"github.com/kubeshop/botkube/pkg/loggerx"
)

// version is set via ldflags by GoReleaser.
Expand Down
2 changes: 1 addition & 1 deletion cmd/executor/gh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

"github.com/hashicorp/go-plugin"

"github.com/kubeshop/botkube/internal/loggerx"
"github.com/kubeshop/botkube/pkg/api"
"github.com/kubeshop/botkube/pkg/api/executor"
"github.com/kubeshop/botkube/pkg/config"
"github.com/kubeshop/botkube/pkg/loggerx"
"github.com/kubeshop/botkube/pkg/pluginx"
)

Expand Down
Loading
Loading