Skip to content

Commit

Permalink
chore: run examples before publishing SDKs (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
anssari1 authored Nov 13, 2024
1 parent e6f3c39 commit 5052e91
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 36 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/release-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ on:
default: ''

jobs:
run-examples:
strategy:
matrix:
jdk: [ 8, 11, 17, 21 ]
uses: ./.github/workflows/run-examples.yaml
secrets: inherit
with:
branch: ${{ inputs.branch }}
jdk: ${{ matrix.jdk }}

release-sdk:
uses: ExpediaGroup/expediagroup-java-sdk/.github/workflows/selfserve-release-sdk.yaml@main
uses: ExpediaGroup/expediagroup-java-sdk/.github/workflows/selfserve-release-sdk.yaml@v20241013
needs: [ run-examples ]
secrets: inherit
with:
branch: ${{ inputs.branch }}
70 changes: 35 additions & 35 deletions .github/workflows/run-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@ name: Run Examples
on:
workflow_call:
inputs:
source:
description: 'Source of SDK to Test'
required: true
type: string
default: 'specs'
sdk_version:
description: 'SDK version to run examples for'
required: false
type: string
default: 'LATEST'
jdk:
description: 'JDK version to use'
required: true
type: string
default: '21'
distribution:
description: 'JDK distribution to use'
required: false
type: string
default: 'corretto'
sdk_key:
description: 'Generated SDK artifact key'
required: false
type: string
default: 'sdk'
secrets:
KEY:
description: 'API Key'
required: true
SECRET:
description: 'API Key'
branch:
description: 'Branch to build SDK and run examples from'
required: true
type: string

jobs:
run-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: ${{ inputs.sdk_key != '' }}
- name: Checkout repo
uses: actions/checkout@v4
with:
repository: 'ExpediaGroup/rapid-java-sdk'
- uses: actions/download-artifact@v4
if: ${{ inputs.source == 'specs' }}
with:
name: ${{ inputs.sdk_key }}
path: examples/sdk
ref: ${{ inputs.branch }}
path: sdk-repo

- name: Parse SDK version
id: parse-sdk-version
working-directory: sdk-repo/code
shell: python -u {0}
run: |
import os
import xml.etree.ElementTree as ET
tree = ET.parse("pom.xml")
root = tree.getroot()
version = root.find("{*}version").text
with open(os.getenv("GITHUB_OUTPUT"), "a") as GITHUB_OUTPUT:
print(f"version={version}", file=GITHUB_OUTPUT)
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.jdk }}
distribution: ${{ inputs.distribution }}
- name: Install SDK into local repository
if: ${{ inputs.source == 'specs' }}
working-directory: examples/sdk
run: mvn install

- name: Install SDK
working-directory: sdk-repo/code
run: |
mvn clean install
- name: Run Examples
working-directory: examples
run: mvn install exec:java -Drapid-java-sdk.sdk.version="${{ inputs.sdk_version }}" -Dcom.expediagroup.rapidsdkjava.apikey="${{ secrets.KEY }}" -Dcom.expediagroup.rapidsdkjava.apisecret="${{ secrets.SECRET }}"
working-directory: sdk-repo/examples
run: |
mvn install exec:java \
-Drapid-java-sdk.sdk.version="${{ steps.parse-sdk-version.outputs.version }}" \
-Dcom.expediagroup.rapidsdkjava.apikey="${{ secrets.KEY }}" \
-Dcom.expediagroup.rapidsdkjava.apisecret="${{ secrets.SECRET }}"

0 comments on commit 5052e91

Please sign in to comment.