Skip to content

Commit 243c80b

Browse files
authored
feat: github workflow for sdk package testing (#73)
* prefer build-and-run.sh script over other in the relay package * Reusable workflow to test server SDKs via test cluster * Package testing workflow triggered on changes to test-data w/php tesing
1 parent 7148bb0 commit 243c80b

File tree

3 files changed

+129
-5
lines changed

3 files changed

+129
-5
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Test Packaged SDKs
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ufc/**
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
test-php-sdk:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
platform: ['linux']
18+
uses: ./.github/workflows/test-server-sdk.yml
19+
with:
20+
platform: ${{ matrix.platform }}
21+
sdkName: 'eppo/php-sdk'
22+
sdkRelayDir: 'php-sdk-relay'
23+
secrets: inherit
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Test Packaged Server SDKs
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
platform:
7+
description: 'Platforms to test the SDK Relay on; linux, macos, windows'
8+
type: string
9+
required: true
10+
sdkName:
11+
description: 'Name of the SDK'
12+
type: string
13+
required: true
14+
sdkRelayDir:
15+
description: 'Directory of the SDK Relay server code'
16+
type: string
17+
required: false
18+
os:
19+
description: 'Specific runner OS to use'
20+
type: string
21+
22+
23+
jobs:
24+
test-packaged-server-sdks:
25+
runs-on: ${{ inputs.os || inputs.platform == 'linux' && 'ubuntu-latest' || inputs.platform == 'macos' && 'macos-13' || inputs.platform == 'windows' && 'windows-latest' || 'NONE' }}
26+
27+
env:
28+
SDK_NAME: ${{ inputs.sdkName }}
29+
SDK_DIR: ${{ inputs.sdkRelayDir }}
30+
EPPO_API_HOST: localhost
31+
SDK_RELAY_HOST: localhost
32+
TEST_RUNNER_HOST: localhost
33+
EPPO_SDK_PLATFORM: ${{ inputs.platform }}
34+
35+
PROJECT_ID: ${{ vars.SDK_TESTING_PROJECT_ID }}
36+
REGION: ${{ vars.SDK_TESTING_REGION }}
37+
GAR_LOCATION: ${{ vars.SDK_TESTING_REGION }}-docker.pkg.dev/${{ vars.SDK_TESTING_PROJECT_ID }}/sdk-testing
38+
39+
steps:
40+
- name: Test information header
41+
shell: bash
42+
run: echo "Running Test Cluster for ${SDK_NAME}"
43+
44+
- name: Set some variables
45+
id: vars
46+
run: |
47+
echo "::set-output name=date::$(date +'%Y-%m-%d')"
48+
echo "SAFE_SDK_NAME=$(echo ${SDK_NAME} | sed 's/\//_/g')" >> $GITHUB_ENV
49+
50+
51+
- name: "Checkout"
52+
uses: actions/checkout@v3
53+
54+
# Set up docker (macos runners)
55+
- id: setup-docker
56+
if: ${{ inputs.platform == 'macos' }}
57+
name: Setup Docker
58+
uses: douglascamata/setup-docker-macos-action@v1-alpha
59+
60+
# Set up gCloud
61+
- id: "auth"
62+
uses: "google-github-actions/auth@v1"
63+
with:
64+
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"
65+
66+
- name: "Set up Cloud SDK"
67+
uses: "google-github-actions/setup-gcloud@v1"
68+
69+
# Allow docker access to the GAR
70+
- name: "Docker auth"
71+
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
72+
73+
# Pull test runner and testing api images for GCP Artifact Registry (GAR) and
74+
# retag them locally as expected by the runner script.
75+
- name: Pull Test Runner image
76+
run: |
77+
docker pull ${{ env.GAR_LOCATION }}/sdk-test-runner:latest
78+
docker tag ${{ env.GAR_LOCATION }}/sdk-test-runner:latest Eppo-exp/sdk-test-runner:latest
79+
docker pull ${{ env.GAR_LOCATION }}/testing-api:latest
80+
docker tag ${{ env.GAR_LOCATION }}/testing-api:latest Eppo-exp/testing-api:latest
81+
82+
- name: Run tests
83+
run: |
84+
pushd package-testing/sdk-test-runner
85+
./test-sdk.sh server ${SDK_NAME}
86+
popd
87+
88+
- name: Upload Logs
89+
if: success() || failure() # always run even if the previous steps fail
90+
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: ${{ steps.date.outputs.date }}-${{ env.SAFE_SDK_NAME }}-${{ inputs.platform }}-test-logs
94+
path: package-testing/sdk-test-runner/logs/
95+
96+
- name: Publish Test Report
97+
uses: mikepenz/action-junit-report@v5
98+
if: success() || failure() # always run even if the previous steps fail
99+
with:
100+
report_paths: 'package-testing/sdk-test-runner/logs/results.xml'

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ case "$command" in
136136
pushd ../$SDK_DIR
137137

138138
BUILD_AND_RUN_PLATFORM=build-and-run-${EPPO_SDK_PLATFORM}.sh
139-
if [ -f docker-run.sh ]; then
139+
140+
if [ -f build-and-run.sh ]; then
141+
echo " ... Starting SDK Relay via build-and-run script"
142+
./build-and-run.sh > ${RUNNER_DIR}/logs/sdk.log 2>&1 &
143+
144+
elif [ -f docker-run.sh ]; then
140145
echo " ... Starting SDK Relay via docker launch script"
141146

142147
# Docker containers need to point at host.docker.internal instead of localhost
@@ -146,10 +151,6 @@ case "$command" in
146151
echo " ... Starting SDK Relay via platform build-and-run script"
147152
./${BUILD_AND_RUN_PLATFORM} > ${RUNNER_DIR}/logs/sdk.log 2>&1 &
148153

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-
153154
else
154155
exit_with_message "SDK Relay does not have a launch script in $SDK_DIR"
155156
fi

0 commit comments

Comments
 (0)