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

Add github action to run e2e command "on-demand" #2241

Merged
merged 24 commits into from
Nov 5, 2021
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
104 changes: 104 additions & 0 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: pr-e2e-tests
concurrency: e2e-tests
on:
issue_comment:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
container: ghcr.io/kedacore/build-tools:main
steps:
- uses: actions/checkout@v2

- uses: khan/pull-request-comment-trigger@master
id: check-comment
with:
trigger: '/run-e2e'
reaction: rocket
prefix_only: true
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

- name: Check user permission
if: steps.check-comment.outputs.triggered == 'true'
id: check-permission
uses: scherermichael-oss/action-has-permission@master
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout Pull Request
if: steps.check-comment.outputs.triggered == 'true' && steps.check-permission.outputs.has-permission
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: checkout
run: |
PR_URL="${{ github.event.issue.pull_request.url }}"
PR_NUM=${PR_URL##*/}
echo "Checking out from PR #$PR_NUM based on URL: $PR_URL"
hub pr checkout $PR_NUM
echo "::set-output name=pr_num::$PR_NUM"

- name: Login to GitHub Container Registry
if: steps.check-comment.outputs.triggered == 'true' && steps.check-permission.outputs.has-permission
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish on GitHub Container Registry
if: steps.check-comment.outputs.triggered == 'true' && steps.check-permission.outputs.has-permission
run: make publish
env:
E2E_IMAGE_TAG: "pr-${{ steps.checkout.outputs.pr_num }}"

- name: Run end to end tests
continue-on-error: true
if: steps.check-comment.outputs.triggered == 'true' && steps.check-permission.outputs.has-permission
id: test
env:
AZURE_SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION }}
AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
AZURE_SP_ID: ${{ secrets.AZURE_SP_ID }}
AZURE_SP_KEY: ${{ secrets.AZURE_SP_KEY }}
AZURE_SP_TENANT: ${{ secrets.AZURE_SP_TENANT }}
TEST_STORAGE_CONNECTION_STRING: ${{ secrets.TEST_STORAGE_CONNECTION_STRING }}
TEST_LOG_ANALYTICS_WORKSPACE_ID: ${{ secrets.TEST_LOG_ANALYTICS_WORKSPACE_ID }}
OPENSTACK_USER_ID: ${{ secrets.OPENSTACK_USER_ID }}
OPENSTACK_PASSWORD: ${{ secrets.OPENSTACK_PASSWORD }}
OPENSTACK_PROJECT_ID: ${{ secrets.OPENSTACK_PROJECT_ID }}
OPENSTACK_AUTH_URL: ${{ secrets.OPENSTACK_AUTH_URL }}
AZURE_DEVOPS_BUILD_DEFINITON_ID: ${{ secrets.AZURE_DEVOPS_BUILD_DEFINITON_ID }}
AZURE_DEVOPS_ORGANIZATION_URL: ${{ secrets.AZURE_DEVOPS_ORGANIZATION_URL }}
AZURE_DEVOPS_PAT: ${{ secrets.AZURE_DEVOPS_PAT }}
AZURE_DEVOPS_POOL_NAME: ${{ secrets.AZURE_DEVOPS_POOL_NAME }}
AZURE_DEVOPS_PROJECT: ${{ secrets.AZURE_DEVOPS_PROJECT }}
E2E_IMAGE_TAG: "pr-${{ steps.checkout.outputs.pr_num }}"
run: |
MESSAGE="${{ github.event.comment.body }}"
REGEX='/run-e2e (.+)'
if [[ "$MESSAGE" =~ $REGEX ]]
then
export E2E_TEST_REGEX="${BASH_REMATCH[1]}"
fi
echo "${{ steps.checkout.outputs.pr_num }}"
make e2e-test

- name: React to comment with success
uses: dkershner6/reaction-action@v1
if: steps.test.outcome == 'success'
with:
token: ${{ secrets.GITHUB_TOKEN }}
commentId: ${{ github.event.comment.id }}
reaction: "+1"

- name: React to comment with failure
uses: dkershner6/reaction-action@v1
if: steps.test.outcome != 'success'
with:
token: ${{ secrets.GITHUB_TOKEN }}
commentId: ${{ github.event.comment.id }}
reaction: "-1"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- Prometheus scaler: omit `serverAddress` from generated metric name ([#2099](https://github.com/kedacore/keda/pull/2099))
- Add Makefile mockgen targets ([#2090](https://github.com/kedacore/keda/issues/2090)|[#2184](https://github.com/kedacore/keda/pull/2184))
- Drop support to `ValueMetricType` using cpu_memory_scaler ([#2218](https://github.com/kedacore/keda/issues/2218))
- Add github action to run e2e command "on-demand" ([#2241](https://github.com/kedacore/keda/issues/2241))

## v2.4.0

Expand Down
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@
# Variables #
##################################################
SHELL = /bin/bash
VERSION ?= main

# If E2E_IMAGE_TAG is defined, we are on pr e2e test and we have to use the new tag and append -test to the repository
ifeq '${E2E_IMAGE_TAG}' ''
VERSION = main
# SUFIX here is intentional empty to not append nothing to the repository
SUFFIX =
endif

ifneq '${E2E_IMAGE_TAG}' ''
VERSION = ${E2E_IMAGE_TAG}
SUFFIX = -test
endif

IMAGE_REGISTRY ?= ghcr.io
IMAGE_REPO ?= kedacore

IMAGE_CONTROLLER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda:$(VERSION)
IMAGE_ADAPTER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda-metrics-apiserver:$(VERSION)
IMAGE_CONTROLLER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda$(SUFFIX):$(VERSION)
IMAGE_ADAPTER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda-metrics-apiserver$(SUFFIX):$(VERSION)

IMAGE_BUILD_TOOLS = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/build-tools:main

Expand Down
4 changes: 3 additions & 1 deletion tests/run-all.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#! /bin/bash
set -eu

E2E_REGEX=${E2E_TEST_REGEX:-*.test.ts}

DIR=$(dirname "$0")
cd $DIR

Expand All @@ -18,7 +20,7 @@ function run_setup {
function run_tests {
counter=0
# randomize tests order using shuf
for test_case in $(find scalers -name "*.test.ts" | shuf)
for test_case in $(find scalers -name "$E2E_REGEX" | shuf)
do
counter=$((counter+1))
./node_modules/.bin/ava $test_case > "${test_case}.log" 2>&1 &
Expand Down
14 changes: 11 additions & 3 deletions tools/build-tools.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
FROM ubuntu:18.04

# Install prerequisite
RUN apt-get update && \
apt-get install -y wget curl build-essential git
RUN apt update && \
apt-get install software-properties-common -y
RUN apt-add-repository ppa:git-core/ppa && \
apt update && \
apt install -y wget curl build-essential git

# Use Bash instead of Dash
RUN ln -sf bash /bin/sh

# Install azure-cli
RUN apt-get install apt-transport-https lsb-release software-properties-common dirmngr -y && \
RUN apt-get install apt-transport-https lsb-release dirmngr -y && \
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | \
tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null && \
AZ_REPO=$(lsb_release -cs) && \
Expand Down Expand Up @@ -64,3 +67,8 @@ ENV PATH=${PATH}:/usr/local/go/bin \

# Install FOSSA tooling
RUN curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | bash

# Install hub
RUN curl -LJO https://github.com/github/hub/releases/download/v2.14.2/hub-linux-amd64-2.14.2.tgz && \
tar zxvf hub-linux-amd64-2.14.2.tgz
ENV PATH="/hub-linux-amd64-2.14.2/bin:${PATH}"