Skip to content

Commit

Permalink
testing using images
Browse files Browse the repository at this point in the history
  • Loading branch information
typotter committed Nov 19, 2024
1 parent ec09b50 commit cf92f88
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 84 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/package-testing/test-server-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Test Packaged Server SDKs

on:
workflow_call:
inputs:
platform:
description: 'Platforms to test the SDK Relay on; linux, macos, windows'
type: string
required: true
os:
description: 'Specific runner OS to use'
type: string
required: true
sdkName:
description: 'Name of the SDK'
type: string
required: true
sdkRelayDir:
description: 'Directory of the SDK Relay server code'
type: string
required: false

jobs:

test-packaged-server-sdks:


runs-on: ${{ inputs.os }}
env:
SDK_NAME: ${{ inputs.sdkName }}
SDK_DIR: ${{ inputs.sdkRelayDir }}
EPPO_API_HOST: localhost
SDK_RELAY_HOST: localhost
TEST_RUNNER_HOST: localhost
EPPO_SDK_PLATFORM: ${{ inputs.platform }}

PROJECT_ID: ${{ vars.SDK_TESTING_PROJECT_ID }}
REGION: ${{ vars.SDK_TESTING_REGION }}
GAR_LOCATION: ${{ vars.SDK_TESTING_REGION }}-docker.pkg.dev/${{ vars.SDK_TESTING_PROJECT_ID }}/sdk-testing

steps:
- name: Test information header
shell: bash
run: echo "Running Test Cluster for ${SDK_NAME}"

- name: Get current date
id: date
run: |
echo "::set-output name=date::$(date +'%Y-%m-%d')"
echo "SAFE_SDK_NAME=$(echo ${SDK_NAME} | sed 's/\//_/g')" >> $GITHUB_ENV
- name: "Checkout"
uses: actions/checkout@v3


# Set up gCloud
- id: "auth"
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"

- name: "Use gcloud CLI"
run: "gcloud info"

# Allow docker access to the GAR
- name: "Docker auth"
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
# Pull test runner and testing api images for GCP Artifact Registry (GAR) and
# retag them locally as expected by the runner script.
- name: Pull Test Runner image
run: |
docker pull ${{ env.GAR_LOCATION }}/sdk-test-runner:latest
docker tag ${{ env.GAR_LOCATION }}/sdk-test-runner:latest Eppo-exp/sdk-test-runner
docker pull ${{ env.GAR_LOCATION }}/testing-api:latest
docker tag ${{ env.GAR_LOCATION }}/testing-api:latest Eppo-exp/testing-api
- name: Run tests
run: |
pushd package-testing/sdk-test-runner
./test-sdk.sh server ${SDK_NAME}
ls -al ./logs
popd
- name: Logs
if: success() || failure() # always run even if the previous steps fail
run: |
echo "List log files"
pushd package-testing/sdk-test-runner
ls logs
cat logs/sdk.log
popd
- name: Upload Logs
if: success() || failure() # always run even if the previous steps fail

uses: actions/upload-artifact@v4
with:
name: ${{ steps.date.outputs.date }}-${{ env.SAFE_SDK_NAME }}-test-logs
path: package-testing/sdk-test-runner/logs/

- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: success() || failure() # always run even if the previous steps fail
with:
report_paths: 'package-testing/sdk-test-runner/logs/results.xml'
2 changes: 1 addition & 1 deletion .github/workflows/release-sdk-test-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
version: ${{ inputs.version }}
docker_context: ./package-testing/sdk-test-runner
image_name: sdk-test-runner
secrets: inherit
secrets: inherit
96 changes: 13 additions & 83 deletions .github/workflows/test-sdk-packages.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,23 @@
name: Test Packaged Server SDKs
name: Test Packaged SDKs

on:
workflow_dispatch:
push:
paths:
.github/workflows/test-sdk-packages.yml

jobs:

test-packaged-server-sdks:


test-php-sdk:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk:
- { sdkName: "eppo/php-sdk",
sdkDir: "php-sdk-relay",
hostAddressFromDocker: "localhost"
}

runs-on: ubuntu-latest
env:
SDK_NAME: ${{matrix.sdk.sdkName}}
SDK_DIR: ${{ matrix.sdk.sdkDir }}
EPPO_API_HOST: ${{matrix.sdk.hostAddressFromDocker}}
SDK_RELAY_HOST: ${{matrix.sdk.hostAddressFromDocker}}
TEST_RUNNER_HOST: ${{matrix.sdk.hostAddressFromDocker}}
EPPO_SDK_PLATFORM: linux

steps:


- name: Test information heade
shell: bash
run: echo "Running Test Cluster for ${SDK_NAME}"


- name: Get current date
id: date
run: |
echo "::set-output name=date::$(date +'%Y-%m-%d')"
echo "SAFE_SDK_NAME=$(echo ${SDK_NAME} | sed 's/\//_/g')" >> $GITHUB_ENV
- name: "Checkout"
uses: actions/checkout@v3

# Pull from GAR instead
- name: Build and export
uses: docker/build-push-action@v6
with:
context: ./package-testing/sdk-test-runner
tags: Eppo-exp/sdk-test-runner:latest,Eppo-exp/sdk-test-runner:local

- name: Prepare testing API server image
run: |
pushd package-testing/testing-api
docker build . -t Eppo-exp/test-api-server:latest
echo "pull the latest instead"
popd
- name: Run tests
run: |
pushd package-testing/sdk-test-runner
./test-sdk.sh server ${SDK_NAME}
ls -al ./logs
popd
- name: Logs
if: success() || failure() # always run even if the previous steps fail
run: |
echo "List log files"
pushd package-testing/sdk-test-runner
ls logs
cat logs/sdk.log
popd
- name: Upload Logs
if: success() || failure() # always run even if the previous steps fail

uses: actions/upload-artifact@v4
with:
name: ${{ steps.date.outputs.date }}-${{ env.SAFE_SDK_NAME }}-test-logs
path: package-testing/sdk-test-runner/logs/

- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: success() || failure() # always run even if the previous steps fail
with:
report_paths: 'package-testing/sdk-test-runner/logs/results.xml'
platform:
- { os: ubuntu-latest,
platform: linux }
uses: ./.github/workflows/package-testing/test-server-sdk.yml
with:
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
sdkName: "eppo/php-sdk"
sdkRelayDir: "php-sdk-relay"
secrets: inherit

0 comments on commit cf92f88

Please sign in to comment.