Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Jan 25, 2024
1 parent 0829b0b commit fa81694
Show file tree
Hide file tree
Showing 84 changed files with 279 additions and 357 deletions.
115 changes: 58 additions & 57 deletions .github/workflows/branch-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,72 @@ env:
K3D_VERSION: v5.4.6
IMAGE_REGISTRY: "ghcr.io"
IMAGE_REPOSITORY: "kubeshop/botkube"
GIT_USER: botkube-dev
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:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.extract-version.outputs.versions }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version
id: extract-version
run: |
IMAGE_VERSION=$(git rev-parse --short HEAD)
echo "versions={\"image-version\":[\"v9.99.9-dev\",\"0.0.0-${IMAGE_VERSION}\"]}" >> $GITHUB_OUTPUT
build:
needs: [extract-metadata]
strategy:
matrix: ${{ fromJson(needs.extract-metadata.outputs.versions) }}
runs-on: ubuntu-latest
env:
GO111MODULE: on
GOPATH: /home/runner/work/botkube
GOBIN: /home/runner/work/botkube/bin
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
cache: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker Login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: latest
- name: Run GoReleaser
run: |
make release-snapshot
env:
ANALYTICS_API_KEY: ${{ secrets.ANALYTICS_API_KEY }}
GORELEASER_CURRENT_TAG: ${{ matrix.image-version }}
IMAGE_TAG: ${{ matrix.image-version }}
# 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 }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Extract version
# id: extract-version
# run: |
# 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) }}
# runs-on: ubuntu-latest
# env:
# GO111MODULE: on
# GOPATH: /home/runner/work/botkube
# GOBIN: /home/runner/work/botkube/bin
# DOCKER_CLI_EXPERIMENTAL: "enabled"
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Setup Go
# uses: actions/setup-go@v4
# with:
# go-version-file: 'go.mod'
# cache: true
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Docker Login
# uses: docker/login-action@v1
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Install GoReleaser
# uses: goreleaser/goreleaser-action@v5
# with:
# install-only: true
# version: latest
# - name: Run GoReleaser
# run: |
# make release-snapshot
# env:
# ANALYTICS_API_KEY: ${{ secrets.ANALYTICS_API_KEY }}
# GORELEASER_CURRENT_TAG: ${{ matrix.image-version }}
# IMAGE_TAG: ${{ matrix.image-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
# needs: [ build ]
permissions:
contents: read
packages: read
Expand Down Expand Up @@ -127,14 +129,13 @@ jobs:
run: "k3d cluster create ${{ matrix.integration }}-test-cluster --wait --timeout=5m"

- name: Install Botkube to test ${{ matrix.integration }}
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
26 changes: 24 additions & 2 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
types: [ opened, synchronize, reopened ]
branches:
- "main"
- "teams/integration-tests"
paths-ignore:
- 'branding/**'
- 'design/**'
Expand All @@ -29,6 +30,7 @@ env:
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 +197,7 @@ jobs:
integration:
- slack
- discord
- teams

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

- name: Setup Go modules
uses: ./.github/actions/go-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 +236,13 @@ jobs:
run: "k3d cluster create ${{ matrix.integration }}-test-cluster --wait --timeout=5m"

- name: Install Botkube to test ${{ matrix.integration }}
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 @@ -272,9 +286,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 Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +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
@go test -timeout=20m -v -tags=integration -race -count=1 ./test/e2e/... -run "TestTeams"

@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 @@ -4,8 +4,6 @@ import (
"context"
"errors"
"fmt"
"github.com/kubeshop/botkube/pkg/httpx"
"github.com/kubeshop/botkube/pkg/loggerx"
"net/http"
"time"

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion cmd/executor/exec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"github.com/kubeshop/botkube/pkg/loggerx"
"strings"

"github.com/MakeNowJust/heredoc"
Expand All @@ -18,6 +17,7 @@ import (
"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 Down
2 changes: 1 addition & 1 deletion cmd/executor/flux/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package main

import (
"context"
"github.com/kubeshop/botkube/pkg/loggerx"
"time"

"github.com/allegro/bigcache/v3"
"github.com/hashicorp/go-plugin"

"github.com/kubeshop/botkube/internal/executor/flux"
"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 @@ -5,14 +5,14 @@ import (
"context"
_ "embed"
"fmt"
"github.com/kubeshop/botkube/pkg/loggerx"
"text/template"

"github.com/hashicorp/go-plugin"

"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
5 changes: 3 additions & 2 deletions hack/gen-plugin-index.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package main

import (
"flag"
"github.com/kubeshop/botkube/internal/plugin"
"github.com/kubeshop/botkube/pkg/loggerx"
"os"
"path/filepath"

"github.com/kubeshop/botkube/internal/plugin"
"github.com/kubeshop/botkube/pkg/loggerx"

"github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
)
Expand Down
3 changes: 2 additions & 1 deletion hack/target/build-plugins/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package main
import (
"flag"
"fmt"
"github.com/kubeshop/botkube/pkg/loggerx"
"log"
"os"
"os/exec"
"strings"

"github.com/kubeshop/botkube/pkg/loggerx"

"github.com/mattn/go-shellwords"
)

Expand Down
3 changes: 2 additions & 1 deletion hack/target/gen-goreleaser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package main

import (
"fmt"
"github.com/kubeshop/botkube/pkg/loggerx"
"os"
"text/template"

"github.com/kubeshop/botkube/pkg/loggerx"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/analytics/segment_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/kubeshop/botkube/pkg/ptr"
"time"

segment "github.com/segmentio/analytics-go"
Expand All @@ -15,6 +14,7 @@ import (

"github.com/kubeshop/botkube/internal/analytics/batched"
"github.com/kubeshop/botkube/pkg/config"
"github.com/kubeshop/botkube/pkg/ptr"
"github.com/kubeshop/botkube/pkg/version"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/analytics/segment_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/kubeshop/botkube/pkg/loggerx"
"sync"
"testing"
"time"
Expand All @@ -30,6 +29,7 @@ import (
"github.com/kubeshop/botkube/internal/analytics"
"github.com/kubeshop/botkube/pkg/config"
"github.com/kubeshop/botkube/pkg/execute/command"
"github.com/kubeshop/botkube/pkg/loggerx"
"github.com/kubeshop/botkube/pkg/version"
)

Expand Down
Loading

0 comments on commit fa81694

Please sign in to comment.