Skip to content

Commit 8ffb539

Browse files
committed
chore: run examples before publishing SDKs
1 parent e6f3c39 commit 8ffb539

File tree

2 files changed

+47
-36
lines changed

2 files changed

+47
-36
lines changed

.github/workflows/release-sdk.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,19 @@ on:
1111
default: ''
1212

1313
jobs:
14+
run-examples:
15+
strategy:
16+
matrix:
17+
jdk: [ 8, 11, 17, 21 ]
18+
uses: ./.github/workflows/run-examples.yaml
19+
secrets: inherit
20+
with:
21+
branch: ${{ inputs.branch }}
22+
jdk: ${{ matrix.jdk }}
23+
1424
release-sdk:
15-
uses: ExpediaGroup/expediagroup-java-sdk/.github/workflows/selfserve-release-sdk.yaml@main
25+
uses: ExpediaGroup/expediagroup-java-sdk/.github/workflows/selfserve-release-sdk.yaml@v20241013
26+
needs: [ run-examples ]
1627
secrets: inherit
1728
with:
1829
branch: ${{ inputs.branch }}

.github/workflows/run-examples.yaml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,61 @@ name: Run Examples
22
on:
33
workflow_call:
44
inputs:
5-
source:
6-
description: 'Source of SDK to Test'
7-
required: true
8-
type: string
9-
default: 'specs'
10-
sdk_version:
11-
description: 'SDK version to run examples for'
12-
required: false
13-
type: string
14-
default: 'LATEST'
155
jdk:
166
description: 'JDK version to use'
177
required: true
188
type: string
19-
default: '21'
209
distribution:
2110
description: 'JDK distribution to use'
2211
required: false
2312
type: string
2413
default: 'corretto'
25-
sdk_key:
26-
description: 'Generated SDK artifact key'
27-
required: false
28-
type: string
29-
default: 'sdk'
30-
secrets:
31-
KEY:
32-
description: 'API Key'
33-
required: true
34-
SECRET:
35-
description: 'API Key'
14+
branch:
15+
description: 'Branch to build SDK and run examples from'
3616
required: true
17+
type: string
3718

3819
jobs:
3920
run-examples:
4021
runs-on: ubuntu-latest
4122
steps:
42-
- uses: actions/checkout@v4
43-
if: ${{ inputs.sdk_key != '' }}
23+
- name: Checkout repo
24+
uses: actions/checkout@v4
4425
with:
4526
repository: 'ExpediaGroup/rapid-java-sdk'
46-
- uses: actions/download-artifact@v4
47-
if: ${{ inputs.source == 'specs' }}
48-
with:
49-
name: ${{ inputs.sdk_key }}
50-
path: examples/sdk
27+
ref: ${{ inputs.branch }}
28+
path: sdk-repo
29+
30+
- name: Parse SDK version
31+
id: parse-sdk-version
32+
working-directory: sdk-repo/code
33+
shell: python -u {0}
34+
run: |
35+
import os
36+
import xml.etree.ElementTree as ET
37+
38+
tree = ET.parse("pom.xml")
39+
root = tree.getroot()
40+
version = root.find("{*}version").text
41+
42+
with open(os.getenv("GITHUB_OUTPUT"), "a") as GITHUB_OUTPUT:
43+
print(f"version={version}", file=GITHUB_OUTPUT)
44+
5145
- name: Set up JDK
5246
uses: actions/setup-java@v4
5347
with:
5448
java-version: ${{ inputs.jdk }}
5549
distribution: ${{ inputs.distribution }}
56-
- name: Install SDK into local repository
57-
if: ${{ inputs.source == 'specs' }}
58-
working-directory: examples/sdk
59-
run: mvn install
50+
51+
- name: Install SDK
52+
working-directory: sdk-repo/code
53+
run: |
54+
mvn clean install
55+
6056
- name: Run Examples
61-
working-directory: examples
62-
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 }}"
57+
working-directory: sdk-repo/examples
58+
run: |
59+
mvn install exec:java \
60+
-Drapid-java-sdk.sdk.version="${{ steps.parse-sdk-version.outputs.version }}" \
61+
-Dcom.expediagroup.rapidsdkjava.apikey="${{ secrets.KEY }}" \
62+
-Dcom.expediagroup.rapidsdkjava.apisecret="${{ secrets.SECRET }}"

0 commit comments

Comments
 (0)