generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 7
93 lines (90 loc) · 3.53 KB
/
e2e.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
- 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"