Skip to content

Commit 7148bb0

Browse files
authored
chore: prep SDK relay runners for running on github (#82)
fix: dotnet build fix: testing-api, allow duplicate /api in URL tweaks: baseUrl, allow relay to specify a `build-and-run` file, longer wait for relay apps to boot
1 parent 02265c9 commit 7148bb0

File tree

5 files changed

+46
-71
lines changed

5 files changed

+46
-71
lines changed
Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#!/usr/bin/env bash
22

3-
: "${SDK_VERSION:=3.4.0}"
4-
5-
DOTNET_VERSION="8.0.10"
6-
DOTNET_SDK_VERSION="8.0"
3+
# default version of the SDK to use.
4+
: "${SDK_VERSION:=3.5.1}"
75

86
SDK="https://github.com/Eppo-exp/dot-net-server-sdk.git"
97

@@ -12,33 +10,9 @@ if [ -e .env ]; then
1210
source .env
1311
fi
1412

15-
16-
# Configure environment to **build** the app
17-
echo "Configuring for build"
18-
19-
# Github runners use the package managers below
20-
# https://github.com/actions/runner-images
21-
case "${EPPO_SDK_PLATFORM}" in
22-
"windows")
23-
choco install dotnet-sdk -v ${DOTNET_SDK_VERSION}
24-
;;
25-
"macos")
26-
brew install dotnet-sdk@${DOTNET_SDK_VERSION}
27-
;;
28-
"linux")
29-
sudo apt update
30-
sudo apt install dotnet-sdk-${DOTNET_SDK_VERSION}
31-
;;
32-
*)
33-
echo "Unsupported platform: ${EPPO_SDK_PLATFORM}"
34-
exit 1
35-
;;
36-
esac
37-
38-
13+
# No need to configure the environment; GH Runners all have .NET installed.
3914

4015
# Inject desired SDK version
41-
4216
dotnet remove EppoSDKRelay package Eppo.Sdk
4317

4418
if [[ -n "$SDK_REF" ]]; then
@@ -57,53 +31,35 @@ if [[ -n "$SDK_REF" ]]; then
5731
pushd tmp
5832
echo "Building SDK"
5933
dotnet pack
60-
61-
echo "Moving build artifact"
62-
mv dot-net-sdk/bin/Release/*.nupkg ./
6334
popd
6435

65-
echo "Adding local dep"
66-
dotnet add EppoSDKRelay package Eppo.Sdk --source tmp/
36+
echo "Adding local dependency"
37+
pushd EppoSDKRelay
38+
dotnet restore
39+
dotnet add package Eppo.Sdk --source ../tmp/dot-net-sdk/bin/Release/
40+
popd
6741
else
42+
pushd EppoSDKRelay
6843
# Use the provided SDK_VERSION (or the default)
6944
echo "Using Eppo.sdk@${SDK_VERSION}"
70-
dotnet add EppoSDKRelay package Eppo.Sdk --version $SDK_VERSION
45+
dotnet add package Eppo.Sdk --version $SDK_VERSION
7146
if [ $? -ne 0 ]; then
7247
echo "Adding versioned package failed";
7348
exit 1
7449
fi
50+
popd
7551
fi
7652

7753
# Build project
7854
echo "Building project"
79-
dotnet build EppoSDKRelay
55+
56+
cd EppoSDKRelay
57+
dotnet build
8058

8159
echo "Publishing project"
8260
dotnet publish
8361

84-
85-
# Configure environment to **run** the app
86-
echo "Configuring for run"
87-
88-
case "${EPPO_SDK_PLATFORM}" in
89-
"windows")
90-
choco install dotnet-runtime -v ${DOTNET_VERSION}
91-
;;
92-
"macos")
93-
brew install dotnet@${DOTNET_VERSION}
94-
;;
95-
"linux")
96-
sudo apt update
97-
sudo apt install dotnet-${DOTNET_VERSION}
98-
;;
99-
*)
100-
echo "Unsupported platform: ${EPPO_SDK_PLATFORM}"
101-
exit 1
102-
;;
103-
esac
104-
105-
10662
echo "Running Eppo SDK Relay"
10763

10864
# Pipe in parameters.
109-
dotnet run --project EppoSDKRelay
65+
dotnet run

package-testing/php-sdk-relay/docker-run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ fi
99

1010
docker stop php-relay
1111
docker remove php-relay
12+
13+
docker build . -t Eppo-exp/php-sdk-relay:$VERSION
14+
1215
docker run -p $SDK_RELAY_PORT:$SDK_RELAY_PORT \
16+
--add-host host.docker.internal:host-gateway \
1317
-e SDK_REF \
18+
-e EPPO_BASE_URL \
1419
-e SDK_RELAY_PORT \
1520
--name php-relay \
1621
-d --rm \

package-testing/sdk-test-runner/test-sdk.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function wait_for_url() {
3939
while [[ $attempt -le $max_attempts ]]; do
4040
curl --silent --output /dev/null --fail "$url" && { return 1; }
4141
echo "Waiting attempt number ${attempt}"
42-
sleep 1
42+
sleep 5
4343
((attempt++))
4444
done
4545

@@ -137,13 +137,19 @@ case "$command" in
137137

138138
BUILD_AND_RUN_PLATFORM=build-and-run-${EPPO_SDK_PLATFORM}.sh
139139
if [ -f docker-run.sh ]; then
140-
echo " ... Starting SDK Relay via docker launch script"
140+
echo " ... Starting SDK Relay via docker launch script"
141141

142142
# Docker containers need to point at host.docker.internal instead of localhost
143-
EPPO_BASE_URL=host.docker.internal:${EPPO_API_PORT} EPPO_API_HOST=host.docker.internal ./docker-run.sh >> ${RUNNER_DIR}/logs/sdk.log 2>&1 &
143+
EPPO_BASE_URL=http://host.docker.internal:${EPPO_API_PORT}/api EPPO_API_HOST=host.docker.internal ./docker-run.sh > ${RUNNER_DIR}/logs/sdk.log 2>&1 &
144+
144145
elif [ -f ${BUILD_AND_RUN_PLATFORM} ]; then
145-
echo " ... Starting SDK Relay via platform build-and-run script"
146-
./${BUILD_AND_RUN_PLATFORM} >> ${RUNNER_DIR}/logs/sdk.log 2>&1 &
146+
echo " ... Starting SDK Relay via platform build-and-run script"
147+
./${BUILD_AND_RUN_PLATFORM} > ${RUNNER_DIR}/logs/sdk.log 2>&1 &
148+
149+
elif [ -f build-and-run.sh ]; then
150+
echo " ... Starting SDK Relay via build-and-run script"
151+
./build-and-run.sh > ${RUNNER_DIR}/logs/sdk.log 2>&1 &
152+
147153
else
148154
exit_with_message "SDK Relay does not have a launch script in $SDK_DIR"
149155
fi

package-testing/testing-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eppo-testing-api",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "UFC server for SDK integration testing",
55
"main": "src/server.ts",
66
"repository": "github.com/Eppo-exp/sdk-test-data",

package-testing/testing-api/src/routes.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Router } from 'express';
1+
import { RequestHandler, Router } from 'express';
22
import { getDataForRequest, isObfuscatedSdk, updateClientDataMap } from './ufc/data';
33

44
const routes = Router();
@@ -9,7 +9,7 @@ routes.get('/', (req, res) => {
99
});
1010

1111
// Serve Unified Flag Config
12-
routes.get('/api/flag-config/v1/config', (req, res) => {
12+
const serveUFC: RequestHandler = (req, res) => {
1313
const sdk: string = req.query.sdkName as string;
1414

1515
const data = getDataForRequest(sdk);
@@ -37,10 +37,10 @@ routes.get('/api/flag-config/v1/config', (req, res) => {
3737
}
3838

3939
return res.status(404).json({ message: 'No data for specified SDK' });
40-
});
40+
};
4141

42-
// Serve bandit models
43-
routes.get('/api/flag-config/v1/bandits', (req, res) => {
42+
// Serve bandit params
43+
const serveBanditParams: RequestHandler =(req, res) => {
4444
const sdk: string = req.query.sdkName as string;
4545

4646
const data = getDataForRequest(sdk);
@@ -51,7 +51,15 @@ routes.get('/api/flag-config/v1/bandits', (req, res) => {
5151
}
5252

5353
return res.status(404).json({ message: 'No data for specified SDK' });
54-
});
54+
};
55+
56+
// Serve with and without the /api prefix to accomodate SDKs in transition.
57+
routes.get('/api/flag-config/v1/config', serveUFC);
58+
routes.get('/api/flag-config/v1/bandits', serveBanditParams);
59+
60+
// For SDKs which in transition; they're passed a baseUrl including `/api` and are using endpoint constants which start with `api/`
61+
routes.get('/api/api/flag-config/v1/config', serveUFC);
62+
routes.get('/api/api/flag-config/v1/bandits', serveBanditParams);
5563

5664
// Allow a test runner to change the scenario for an SDK
5765
routes.post('/sdk/:sdk/scenario', (req, res) => {

0 commit comments

Comments
 (0)