E2E Tests #140
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E Tests | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: Environment where to run tests | |
required: true | |
type: environment | |
default: dev | |
jobs: | |
define-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
shoots: ${{ steps.define.outputs.shoots }} | |
env: ${{ steps.define.outputs.env }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Find Shoots | |
id: define | |
run: | | |
ENV="${${{ inputs.environment }}:-dev}" | |
echo "env=$ENV" | |
SHOOTS=`jq -c ".skrs.$ENV | keys_unsorted " ./assets/config.json` | |
echo "shoots=$SHOOTS" | |
echo "env=$ENV" >> "$GITHUB_OUTPUT" | |
echo "shoots=$SHOOTS" >> "$GITHUB_OUTPUT" | |
run-tests: | |
runs-on: ubuntu-latest | |
needs: define-matrix | |
strategy: | |
matrix: | |
shoot: ${{ fromJSON(needs.define-matrix.outputs.shoots) }} | |
environment: ${{ needs.define-matrix.outputs.env }} | |
steps: | |
- name: Print shoot | |
run: echo ${{ matrix.shoot }} | |
- uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22' | |
- name: Build | |
run: | | |
go mod tidy | |
go mod download | |
go build -o bin/kfr cmd/main.go | |
- name: Download kubectl | |
run: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
- name: Build token | |
env: | |
IAS_URL: ${{ vars.IAS_URL }} | |
IAS_USERNAME: ${{ secrets.IAS_USERNAME }} | |
IAS_PASSWORD: ${{ secrets.IAS_PASSWORD }} | |
IAS_CLIENT_ID: ${{ secrets.IAS_CLIENT_ID }} | |
IAS_CLIENT_SECRET: ${{ secrets.IAS_CLIENT_SECRET }} | |
run: | | |
curl -X POST "$IAS_URL/oauth2/token" \ | |
-H 'Content-Type: application/x-www-form-urlencoded' \ | |
-d 'grant_type=password' \ | |
-d "username=$IAS_USERNAME" \ | |
-d "password=$IAS_PASSWORD" \ | |
-d "client_id=$IAS_CLIENT_ID" \ | |
-d "client_secret=$IAS_CLIENT_SECRET" \ | |
-d 'scope=groups, email' > token.json | |
- name: Build kubeconfig | |
env: | |
IAS_USERNAME: ${{ secrets.IAS_USERNAME }} | |
IAS_PASSWORD: ${{ secrets.IAS_PASSWORD }} | |
BTP_URL: ${{ vars.BTP_URL }} | |
BTP_SUBDOMAIN: ${{ vars.BTP_SUBDOMAIN }} | |
BTP_IDP: ${{ vars.BTP_IDP }} | |
run: | | |
URL=$(jq -r '.skrs.${{ needs.define-matrix.outputs.env }}."${{ matrix.shoot }}".url' ./assets/config.json) | |
echo "URL: $URL" | |
CA=$(jq -r '.skrs.${{ needs.define-matrix.outputs.env }}."${{ matrix.shoot }}".ca' ./assets/config.json) | |
TOKEN=$(jq -r '.id_token' ./token.json) | |
KC=$(jq ".users[0].user.token = \"$TOKEN\" | .clusters[0].cluster.server = \"$URL\" | .clusters[0].cluster.\"certificate-authority-data\" = \"$CA\"" ./assets/kubeconfig.json) | |
kubectl config view --minify --raw --kubeconfig <(echo $KC) > kubeconfig.yaml | |
echo "kubeconfig" | |
base64 -i kubeconfig.yaml | |
- name: Run E2E Tests | |
run: | | |
export SHOOT="${{ matrix.shoot }}" | |
export PROVIDER=$(jq -r '.skrs.${{ needs.define-matrix.outputs.env }}."${{ matrix.shoot }}".provider' ./assets/config.json) | |
export KUBECONFIG=$(pwd)/kubeconfig.yaml | |
export ENV=${{ needs.define-matrix.outputs.env }} | |
echo "shoot=$SHOOT" | |
echo "provider=$PROVIDER" | |
echo "env=$ENV" | |
./bin/kfr \ | |
-godog.paths $(pwd)/features \ | |
-godog.tags="@all,@allProviders,@$PROVIDER&&@all,@allShoots,@${{ matrix.shoot }}&&@all,@allEnvs,@$ENV" |