Skip to content

Commit 3b0ed81

Browse files
committed
Update gradle script and environment variable names
1 parent 97f92e7 commit 3b0ed81

4 files changed

Lines changed: 18 additions & 92 deletions

File tree

.github/workflows/generate_php_sources.yml

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,6 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v4
17-
# Extract prefixes from all files in api-specifications directory
18-
- name: Get all files and extract prefixes
19-
id: extract_prefix
20-
run: |
21-
# Get all JSON files in api-specifications directory
22-
FILES=$(find api-specifications -name "*.json" -type f)
23-
24-
if [ -n "$FILES" ]; then
25-
echo "Found files:"
26-
echo "$FILES"
27-
28-
# Extract prefixes from all files
29-
PREFIXES=""
30-
for file in $FILES; do
31-
# Extract filename without path and extension
32-
filename=$(basename "$file" .json)
33-
# Extract prefix (everything before the first underscore)
34-
raw_prefix=$(echo "$filename" | cut -d'_' -f1)
35-
prefix=$(echo "$raw_prefix" | tr '[:lower:]' '[:upper:]')
36-
echo "File: $file -> Raw prefix: '$raw_prefix' -> Uppercase prefix: '$prefix'"
37-
38-
# Add to prefixes list if not already present
39-
if [[ ! "$PREFIXES" =~ $prefix ]]; then
40-
PREFIXES="$PREFIXES $prefix"
41-
fi
42-
done
43-
44-
# Trim whitespace and use the first prefix for now
45-
PREFIXES=$(echo "$PREFIXES" | xargs)
46-
FIRST_PREFIX=$(echo "$PREFIXES" | cut -d' ' -f1)
47-
48-
echo "prefixes=$PREFIXES" >> $GITHUB_OUTPUT
49-
echo "prefix=$FIRST_PREFIX" >> $GITHUB_OUTPUT
50-
echo "Found prefixes: $PREFIXES"
51-
echo "Using prefix: $FIRST_PREFIX"
52-
else
53-
echo "No JSON files found in api-specifications directory"
54-
echo "prefixes=" >> $GITHUB_OUTPUT
55-
echo "prefix=DEFAULT" >> $GITHUB_OUTPUT
56-
fi
57-
shell: bash
5817

5918
- name: Make gradlew executable
6019
run: chmod +x ./gradlew
@@ -96,9 +55,12 @@ jobs:
9655
- name: Test SDKs
9756
run: python ./scripts/test_sdk.py --language php
9857
env:
99-
${{ format('TEST_CLIENT_ID_{0}', steps.extract_prefix.outputs.prefix) }}: ${{ secrets[format('SDK_TEST_CLIENT_ID_{0}', steps.extract_prefix.outputs.prefix)] }}
100-
${{ format('TEST_CLIENT_SECRET_{0}', steps.extract_prefix.outputs.prefix) }}: ${{ secrets[format('SDK_TEST_CLIENT_SECRET_{0}', steps.extract_prefix.outputs.prefix)] }}
101-
${{ format('TEST_APPLICATION_ID_{0}', steps.extract_prefix.outputs.prefix) }}: ${{ secrets[format('SDK_TEST_APPLICATION_ID_{0}', steps.extract_prefix.outputs.prefix)] }}
58+
RETAILMEDIA_TEST_CLIENT_ID: ${{ secrets.RETAILMEDIA_SDK_TEST_CLIENT_ID }}
59+
RETAILMEDIA_TEST_CLIENT_SECRET: ${{ secrets.RETAILMEDIA_SDK_TEST_CLIENT_SECRET }}
60+
RETAILMEDIA_TEST_APPLICATION_ID: ${{ secrets.RETAILMEDIA_SDK_TEST_APPLICATION_ID }}
61+
MARKETINGSOLUTIONS_TEST_CLIENT_ID: ${{ secrets.MARKETINGSOLUTIONS_SDK_TEST_CLIENT_ID }}
62+
MARKETINGSOLUTIONS_TEST_CLIENT_SECRET: ${{ secrets.MARKETINGSOLUTIONS_SDK_TEST_CLIENT_SECRET }}
63+
MARKETINGSOLUTIONS_TEST_APPLICATION_ID: ${{ secrets.MARKETINGSOLUTIONS_SDK_TEST_APPLICATION_ID }}
10264
shell: bash
10365

10466
- name: Upload SDKs

.github/workflows/test_php.yml

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,6 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20-
# Extract prefixes from all files in api-specifications directory
21-
- name: Get all files and extract prefixes
22-
id: extract_prefix
23-
run: |
24-
# Get all JSON files in api-specifications directory
25-
FILES=$(find api-specifications -name "*.json" -type f)
26-
27-
if [ -n "$FILES" ]; then
28-
echo "Found files:"
29-
echo "$FILES"
30-
31-
# Extract prefixes from all files
32-
PREFIXES=""
33-
for file in $FILES; do
34-
# Extract filename without path and extension
35-
filename=$(basename "$file" .json)
36-
# Extract prefix (everything before the first underscore)
37-
raw_prefix=$(echo "$filename" | cut -d'_' -f1)
38-
prefix=$(echo "$raw_prefix" | tr '[:lower:]' '[:upper:]')
39-
echo "File: $file -> Raw prefix: '$raw_prefix' -> Uppercase prefix: '$prefix'"
40-
41-
# Add to prefixes list if not already present
42-
if [[ ! "$PREFIXES" =~ $prefix ]]; then
43-
PREFIXES="$PREFIXES $prefix"
44-
fi
45-
done
46-
47-
# Trim whitespace and use the first prefix for now
48-
PREFIXES=$(echo "$PREFIXES" | xargs)
49-
FIRST_PREFIX=$(echo "$PREFIXES" | cut -d' ' -f1)
50-
51-
echo "prefixes=$PREFIXES" >> $GITHUB_OUTPUT
52-
echo "prefix=$FIRST_PREFIX" >> $GITHUB_OUTPUT
53-
echo "Found prefixes: $PREFIXES"
54-
echo "Using prefix: $FIRST_PREFIX"
55-
else
56-
echo "No JSON files found in api-specifications directory"
57-
echo "prefixes=" >> $GITHUB_OUTPUT
58-
echo "prefix=DEFAULT" >> $GITHUB_OUTPUT
59-
fi
60-
shell: bash
61-
6220
- name: Make gradlew executable
6321
run: chmod +x ./gradlew
6422

@@ -93,7 +51,10 @@ jobs:
9351
- name: Test SDKs
9452
run: python ./scripts/test_sdk.py --language php
9553
env:
96-
${{ format('TEST_CLIENT_ID_{0}', steps.extract_prefix.outputs.prefix) }}: ${{ secrets[format('SDK_TEST_CLIENT_ID_{0}', steps.extract_prefix.outputs.prefix)] }}
97-
${{ format('TEST_CLIENT_SECRET_{0}', steps.extract_prefix.outputs.prefix) }}: ${{ secrets[format('SDK_TEST_CLIENT_SECRET_{0}', steps.extract_prefix.outputs.prefix)] }}
98-
${{ format('TEST_APPLICATION_ID_{0}', steps.extract_prefix.outputs.prefix) }}: ${{ secrets[format('SDK_TEST_APPLICATION_ID_{0}', steps.extract_prefix.outputs.prefix)] }}
54+
RETAILMEDIA_TEST_CLIENT_ID: ${{ secrets.RETAILMEDIA_SDK_TEST_CLIENT_ID }}
55+
RETAILMEDIA_TEST_CLIENT_SECRET: ${{ secrets.RETAILMEDIA_SDK_TEST_CLIENT_SECRET }}
56+
RETAILMEDIA_TEST_APPLICATION_ID: ${{ secrets.RETAILMEDIA_SDK_TEST_APPLICATION_ID }}
57+
MARKETINGSOLUTIONS_TEST_CLIENT_ID: ${{ secrets.MARKETINGSOLUTIONS_SDK_TEST_CLIENT_ID }}
58+
MARKETINGSOLUTIONS_TEST_CLIENT_SECRET: ${{ secrets.MARKETINGSOLUTIONS_SDK_TEST_CLIENT_SECRET }}
59+
MARKETINGSOLUTIONS_TEST_APPLICATION_ID: ${{ secrets.MARKETINGSOLUTIONS_SDK_TEST_APPLICATION_ID }}
9960
shell: bash

generator/php/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ task generateClient(type: GradleBuild) {
7575
invokerPackage : "${namespaceBase}".toString(),
7676
packageName : "criteo-api-${criteoService}-sdk".toString(),
7777
]
78+
additionalProperties = [
79+
criteoServiceAsPrefix : "${criteoService}".toString().toUpperCase(),
80+
]
7881
}
7982

8083

generator/php/resources/templates/custom/GatewayApiTest.php.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class GatewayApiTest extends TestCase
3333
{
3434
parent::__construct();
3535
36-
$this->clientId = $_SERVER["TEST_CLIENT_ID"];
37-
$this->clientSecret = $_SERVER["TEST_CLIENT_SECRET"];
38-
$this->applicationId = (int) $_SERVER["TEST_APPLICATION_ID"];
36+
$this->clientId = $_SERVER["{{criteoServiceAsPrefix}}_TEST_CLIENT_ID"];
37+
$this->clientSecret = $_SERVER["{{criteoServiceAsPrefix}}_TEST_CLIENT_SECRET"];
38+
$this->applicationId = (int) $_SERVER["{{criteoServiceAsPrefix}}_TEST_APPLICATION_ID"];
3939
}
4040

4141
public function secretEnvironmentVariables()

0 commit comments

Comments
 (0)