Skip to content

Commit

Permalink
Setup CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Jan 25, 2024
1 parent 9bff236 commit 0829b0b
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 1,500 deletions.
20 changes: 20 additions & 0 deletions .github/actions/go-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
327 changes: 177 additions & 150 deletions .github/workflows/branch-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- "teams/integration-tests"
repository_dispatch:
types: [ trigger-e2e-tests ]

Expand All @@ -12,6 +13,7 @@ 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

Expand Down Expand Up @@ -68,10 +70,7 @@ 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:
name: Integration tests
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/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 Down Expand Up @@ -166,9 +178,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 @@ -179,149 +199,156 @@ jobs:
run: |
KUBECONFIG=$(k3d kubeconfig write ${{ matrix.integration }}-test-cluster) \
make test-integration-${{ matrix.integration }}
cli-migration-e2e:
name: CLI Migration E2E tests
runs-on: ubuntu-latest
needs: [ build ]
permissions:
contents: read
packages: read
concurrency:
group: cli-migration-e2e
cancel-in-progress: false
strategy:
fail-fast: false
matrix:
e2e:
- discord
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: latest
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
cache: true
- name: Run GoReleaser
run: make release-snapshot-cli
- name: Add botkube alias
run: |
echo BOTKUBE_BINARY_PATH="$PWD/dist/botkube-cli_linux_amd64_v1/botkube" >> $GITHUB_ENV
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: ${{ env.HELM_VERSION }}
- name: Download k3d
run: "wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${K3D_VERSION} bash"
- name: Create k3d cluster
run: "k3d cluster create cli-migration-e2e-cluster --wait --timeout=5m"
- name: Run e2e tests for botkube client
env:
DISCORD_BOT_ID: ${{ secrets.DISCORD_BOT_ID }}
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }}
DISCORD_TESTER_APP_TOKEN: ${{ secrets.DISCORD_TESTER_APP_TOKEN }}
BOTKUBE_CLOUD_DEV_GQL_ENDPOINT: ${{ secrets.BOTKUBE_CLOUD_DEV_GQL_ENDPOINT }}
BOTKUBE_CLOUD_DEV_REFRESH_TOKEN: ${{ secrets.BOTKUBE_CLOUD_DEV_REFRESH_TOKEN }}
BOTKUBE_CLOUD_DEV_AUTH0_CLIENT_ID: ${{ secrets.BOTKUBE_CLOUD_DEV_AUTH0_CLIENT_ID }}
run: |
KUBECONFIG=$(k3d kubeconfig write cli-migration-e2e-cluster) make test-cli-migration-e2e
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: screenshots_dump_${{github.sha}}
path: ${{ runner.temp }}/screenshots
retention-days: 5

- name: Dump cluster state
if: ${{ failure() }}
uses: ./.github/actions/dump-cluster

- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() }}
env:
SLACK_USERNAME: Botkube Cloud CI
SLACK_COLOR: 'red'
SLACK_TITLE: 'Message'
SLACK_CHANNEL: 'botkube-cloud-ci-alerts'
SLACK_MESSAGE: 'CLI Migration E2E tests failed :scream:'
SLACK_ICON_EMOJI: ':this-is-fine-fire:'
SLACK_FOOTER: "Fingers crossed it's just an outdated/flaky test..."
SLACK_WEBHOOK: ${{ secrets.SLACK_CI_ALERTS_WEBHOOK }}

cloud-slack-dev-e2e:
name: Botkube Cloud Slack Dev E2E
runs-on: ubuntu-latest
needs: [ build ]
permissions:
contents: read
packages: read
concurrency:
group: cloud-slack-dev-e2e
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Helm
uses: azure/setup-helm@v3
with:
version: ${{ env.HELM_VERSION }}

- name: Download k3d
run: "wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${K3D_VERSION} bash"
- name: Create k3d cluster
run: "k3d cluster create cloud-slack-dev-e2e-cluster --wait --timeout=5m"

- name: Run e2e tests
env:
SLACK_WORKSPACE_NAME: ${{ secrets.E2E_DEV_SLACK_WORKSPACE_NAME }}
SLACK_EMAIL: ${{ secrets.E2E_DEV_SLACK_EMAIL }}
SLACK_PASSWORD: ${{ secrets.E2E_DEV_SLACK_USER_PASSWORD }}
SLACK_TESTER_TESTER_BOT_TOKEN: ${{ secrets.E2E_DEV_SLACK_TESTER_BOT_TOKEN }}
SLACK_TESTER_BOT_NAME: botkubedev
SLACK_TESTER_MESSAGE_WAIT_TIMEOUT: 1m
BOTKUBE_CLOUD_EMAIL: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_EMAIL }}
BOTKUBE_CLOUD_PASSWORD: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_PASSWORD }}
BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID }}
BOTKUBE_CLOUD_FREE_ORGANIZATION_ID: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_FREE_ORGANIZATION_ID }}
SCREENSHOTS_DIR: ${{ runner.temp }}/screenshots
DEBUG_MODE: true
run: |
KUBECONFIG=$(k3d kubeconfig write cli-migration-e2e-cluster) make test-cloud-slack-dev-e2e
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: screenshots_dump_${{github.sha}}
path: ${{ runner.temp }}/screenshots
retention-days: 5

- name: Dump cluster state
if: ${{ failure() }}
uses: ./.github/actions/dump-cluster

- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() }}
env:
SLACK_USERNAME: Botkube Cloud CI
SLACK_COLOR: 'red'
SLACK_TITLE: 'Message'
SLACK_CHANNEL: 'botkube-cloud-ci-alerts'
SLACK_MESSAGE: 'Cloud Slack Dev E2E tests failed :scream:'
SLACK_ICON_EMOJI: ':this-is-fine-fire:'
SLACK_FOOTER: "Fingers crossed it's just an outdated/flaky test..."
SLACK_WEBHOOK: ${{ secrets.SLACK_CI_ALERTS_WEBHOOK }}
#
# cli-migration-e2e:
# name: CLI Migration E2E tests
# runs-on: ubuntu-latest
# needs: [ build ]
# permissions:
# contents: read
# packages: read
# concurrency:
# group: cli-migration-e2e
# cancel-in-progress: false
# strategy:
# fail-fast: false
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# persist-credentials: false
# - name: Install GoReleaser
# uses: goreleaser/goreleaser-action@v5
# with:
# install-only: true
# version: latest
# - name: Setup Go
# uses: actions/setup-go@v4
# with:
# 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: Run GoReleaser
# run: make release-snapshot-cli
# - name: Add botkube alias
# run: |
# echo BOTKUBE_BINARY_PATH="$PWD/dist/botkube-cli_linux_amd64_v1/botkube" >> $GITHUB_ENV
# - name: Install Helm
# uses: azure/setup-helm@v3
# with:
# version: ${{ env.HELM_VERSION }}
# - name: Download k3d
# run: "wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${K3D_VERSION} bash"
# - name: Create k3d cluster
# run: "k3d cluster create cli-migration-e2e-cluster --wait --timeout=5m"
# - name: Run e2e tests for botkube client
# env:
# DISCORD_BOT_ID: ${{ secrets.DISCORD_BOT_ID }}
# DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
# DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }}
# DISCORD_TESTER_APP_TOKEN: ${{ secrets.DISCORD_TESTER_APP_TOKEN }}
# BOTKUBE_CLOUD_DEV_GQL_ENDPOINT: ${{ secrets.BOTKUBE_CLOUD_DEV_GQL_ENDPOINT }}
# BOTKUBE_CLOUD_DEV_REFRESH_TOKEN: ${{ secrets.BOTKUBE_CLOUD_DEV_REFRESH_TOKEN }}
# BOTKUBE_CLOUD_DEV_AUTH0_CLIENT_ID: ${{ secrets.BOTKUBE_CLOUD_DEV_AUTH0_CLIENT_ID }}
# run: |
# KUBECONFIG=$(k3d kubeconfig write cli-migration-e2e-cluster) make test-cli-migration-e2e
#
# - name: Upload artifacts
# uses: actions/upload-artifact@v3
# if: ${{ always() }}
# with:
# name: screenshots_dump_${{github.sha}}
# path: ${{ runner.temp }}/screenshots
# retention-days: 5
#
# - name: Dump cluster state
# if: ${{ failure() }}
# uses: ./.github/actions/dump-cluster
#
# - name: Slack Notification
# uses: rtCamp/action-slack-notify@v2
# if: ${{ failure() }}
# env:
# SLACK_USERNAME: Botkube Cloud CI
# SLACK_COLOR: 'red'
# SLACK_TITLE: 'Message'
# SLACK_CHANNEL: 'botkube-cloud-ci-alerts'
# SLACK_MESSAGE: 'CLI Migration E2E tests failed :scream:'
# SLACK_ICON_EMOJI: ':this-is-fine-fire:'
# SLACK_FOOTER: "Fingers crossed it's just an outdated/flaky test..."
# SLACK_WEBHOOK: ${{ secrets.SLACK_CI_ALERTS_WEBHOOK }}
#
# cloud-slack-dev-e2e:
# name: Botkube Cloud Slack Dev E2E
# runs-on: ubuntu-latest
# needs: [ build ]
# permissions:
# contents: read
# packages: read
# concurrency:
# group: cloud-slack-dev-e2e
# cancel-in-progress: false
# steps:
# - name: Setup Go modules
# uses: ./.github/actions/go-private
# with:
# access_token: ${{ secrets.E2E_TEST_GH_DEV_ACCOUNT_PAT }}
# username: ${{ env.GIT_USER }}
# - name: Checkout
# uses: actions/checkout@v3
#
# - name: Install Helm
# uses: azure/setup-helm@v3
# with:
# version: ${{ env.HELM_VERSION }}
#
# - name: Download k3d
# run: "wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${K3D_VERSION} bash"
# - name: Create k3d cluster
# run: "k3d cluster create cloud-slack-dev-e2e-cluster --wait --timeout=5m"
#
# - name: Run e2e tests
# env:
# SLACK_WORKSPACE_NAME: ${{ secrets.E2E_DEV_SLACK_WORKSPACE_NAME }}
# SLACK_EMAIL: ${{ secrets.E2E_DEV_SLACK_EMAIL }}
# SLACK_PASSWORD: ${{ secrets.E2E_DEV_SLACK_USER_PASSWORD }}
# SLACK_TESTER_TESTER_BOT_TOKEN: ${{ secrets.E2E_DEV_SLACK_TESTER_BOT_TOKEN }}
# SLACK_TESTER_BOT_NAME: botkubedev
# SLACK_TESTER_MESSAGE_WAIT_TIMEOUT: 1m
# BOTKUBE_CLOUD_EMAIL: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_EMAIL }}
# BOTKUBE_CLOUD_PASSWORD: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_PASSWORD }}
# BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID }}
# BOTKUBE_CLOUD_FREE_ORGANIZATION_ID: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_FREE_ORGANIZATION_ID }}
# SCREENSHOTS_DIR: ${{ runner.temp }}/screenshots
# DEBUG_MODE: true
# run: |
# KUBECONFIG=$(k3d kubeconfig write cli-migration-e2e-cluster) make test-cloud-slack-dev-e2e
#
# - name: Upload artifacts
# uses: actions/upload-artifact@v3
# if: ${{ always() }}
# with:
# name: screenshots_dump_${{github.sha}}
# path: ${{ runner.temp }}/screenshots
# retention-days: 5
#
# - name: Dump cluster state
# if: ${{ failure() }}
# uses: ./.github/actions/dump-cluster
#
# - name: Slack Notification
# uses: rtCamp/action-slack-notify@v2
# if: ${{ failure() }}
# env:
# SLACK_USERNAME: Botkube Cloud CI
# SLACK_COLOR: 'red'
# SLACK_TITLE: 'Message'
# SLACK_CHANNEL: 'botkube-cloud-ci-alerts'
# SLACK_MESSAGE: 'Cloud Slack Dev E2E tests failed :scream:'
# SLACK_ICON_EMOJI: ':this-is-fine-fire:'
# SLACK_FOOTER: "Fingers crossed it's just an outdated/flaky test..."
# SLACK_WEBHOOK: ${{ secrets.SLACK_CI_ALERTS_WEBHOOK }}
Loading

0 comments on commit 0829b0b

Please sign in to comment.