-
Notifications
You must be signed in to change notification settings - Fork 14
137 lines (123 loc) · 6.02 KB
/
system-testing.yml
File metadata and controls
137 lines (123 loc) · 6.02 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Trigger E2E Testing Workflow
on:
pull_request_target:
types: [opened, reopened, synchronize]
branches:
- main
jobs:
trigger-system-tests:
runs-on: ubuntu-latest
steps:
- name: Check if system testing is activated
id: check_activation
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
ACTIVATE=$(echo "$PR_BODY" | grep '^SYSTEM_TESTING:' | sed 's/SYSTEM_TESTING: *//' | tr -d '[:space:]')
echo "System testing activation: '$ACTIVATE'"
if [[ "$ACTIVATE" == "ACTIVATE" ]]; then
echo "activated=true" >> $GITHUB_OUTPUT
echo "System testing is ACTIVATED"
else
echo "activated=false" >> $GITHUB_OUTPUT
echo "System testing NOT activated (add 'SYSTEM_TESTING: ACTIVATE' to PR body to enable)"
fi
- name: Trigger Repository Dispatch
if: steps.check_activation.outputs.activated == 'true'
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
echo "Parsing PR body for dependencies..."
# Parse PROXY dependency
PROXY_LOCATION=$(echo "$PR_BODY" | grep '^PROXY:' | sed 's/PROXY: *//' | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | xargs)
echo "Proxy location: $PROXY_LOCATION"
# Parse CHARGING dependency
CHARGING_LOCATION=$(echo "$PR_BODY" | grep '^CHARGING:' | sed 's/CHARGING: *//' | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | xargs)
echo "Charging location: $CHARGING_LOCATION"
# Parse TM_VERSION
TM_VERSION=$(echo "$PR_BODY" | grep '^TM_VERSION:' | sed 's/TM_VERSION: *//' | xargs)
echo "TMForum API version: $TM_VERSION"
# Parse E2E_BRANCH (optional - branch of E2E-DOME-BAE to use)
E2E_BRANCH=$(echo "$PR_BODY" | grep '^E2E_BRANCH:' | sed 's/E2E_BRANCH: *//' | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | xargs)
echo "E2E branch: $E2E_BRANCH"
# Default values (using upstream FIWARE-TMForum repos)
PROXY_REPO="FIWARE-TMForum/business-ecosystem-logic-proxy"
PROXY_BRANCH="master"
CHARGING_REPO="FIWARE-TMForum/business-ecosystem-charging-backend"
CHARGING_BRANCH="master"
TM_VERSION="${TM_VERSION:-1.10.2}"
# Process PROXY location if specified
if [[ -n "$PROXY_LOCATION" ]]; then
echo "Validating proxy repository..."
STATUS=$(curl -o /dev/null -s -w "%{http_code}" "$PROXY_LOCATION")
if [[ "$STATUS" -eq 200 ]]; then
echo "Proxy repository found"
PROXY_REPO=$(echo "$PROXY_LOCATION" | awk -F "/" '{print $4 "/" $5}')
PROXY_BRANCH=$(echo "$PROXY_LOCATION" | awk -F "/tree/" '{print $2}')
PROXY_BRANCH="${PROXY_BRANCH:-master}"
echo "Extracted - Repo: $PROXY_REPO, Branch: $PROXY_BRANCH"
else
echo "Proxy repository not found: $PROXY_LOCATION (HTTP $STATUS)"
exit 1
fi
fi
# Process CHARGING location if specified
if [[ -n "$CHARGING_LOCATION" ]]; then
echo "Validating charging repository..."
STATUS=$(curl -o /dev/null -s -w "%{http_code}" "$CHARGING_LOCATION")
if [[ "$STATUS" -eq 200 ]]; then
echo "Charging repository found"
CHARGING_REPO=$(echo "$CHARGING_LOCATION" | awk -F "/" '{print $4 "/" $5}')
CHARGING_BRANCH=$(echo "$CHARGING_LOCATION" | awk -F "/tree/" '{print $2}')
CHARGING_BRANCH="${CHARGING_BRANCH:-master}"
echo "Extracted - Repo: $CHARGING_REPO, Branch: $CHARGING_BRANCH"
else
echo "Charging repository not found: $CHARGING_LOCATION (HTTP $STATUS)"
exit 1
fi
fi
echo ""
echo "E2E Test Configuration:"
echo " Proxy: $PROXY_REPO @ $PROXY_BRANCH"
echo " Charging: $CHARGING_REPO @ $CHARGING_BRANCH"
echo " Frontend: ${{ github.event.pull_request.head.repo.full_name }} @ ${{ github.event.pull_request.head.ref }}"
echo " TM Version: $TM_VERSION"
echo " E2E Branch: $E2E_BRANCH"
echo " PR URL: ${{ github.event.pull_request.html_url }}"
echo ""
# Trigger E2E tests in E2E-DOME-BAE repository
echo "Triggering E2E tests..."
HTTP_STATUS=$(curl -X POST \
-H "Authorization: token ${{ secrets.ADMIN }}" \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Content-Type: application/json" \
-w "%{http_code}" \
-o /dev/null \
-s \
-d "{
\"event_type\": \"cross-repo-test\",
\"client_payload\": {
\"repository_A\": \"$PROXY_REPO\",
\"branch_A\": \"$PROXY_BRANCH\",
\"repository_B\": \"$CHARGING_REPO\",
\"branch_B\": \"$CHARGING_BRANCH\",
\"repository_frontend\": \"${{ github.event.pull_request.head.repo.full_name }}\",
\"branch_frontend\": \"${{ github.event.pull_request.head.ref }}\",
\"tm_version\": \"$TM_VERSION\",
\"cypress_branch\": \"$E2E_BRANCH\",
\"pull_request_url\": \"${{ github.event.pull_request.html_url }}\"
}
}" \
https://api.github.com/repos/Ficodes/E2E-DOME-BAE/dispatches)
echo "HTTP Status: $HTTP_STATUS"
if [ "$HTTP_STATUS" -eq 204 ] || [ "$HTTP_STATUS" -eq 200 ]; then
echo "E2E tests triggered successfully!"
else
echo "Failed to trigger E2E tests. HTTP Status: $HTTP_STATUS"
if [ "$HTTP_STATUS" -eq 401 ]; then
echo "Error: Unauthorized. Check if the ADMIN token has the correct permissions."
elif [ "$HTTP_STATUS" -eq 404 ]; then
echo "Error: Repository not found or token doesn't have access."
fi
exit 1
fi