Skip to content

Commit 30cac0b

Browse files
committed
Added an implementation that allows secrets to be passed to a test run for python uv ci
1 parent 9c2058f commit 30cac0b

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

.github/workflows/python-uv-ci.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ on:
105105
required: false
106106
type: string
107107
default: uv build
108+
secrets:
109+
TEST_SECRETS:
110+
description: JSON object containing test secrets to be unfurled as environment variables
111+
required: false
108112

109113
jobs:
110114
python-ci:
@@ -156,8 +160,23 @@ jobs:
156160

157161
- name: Test
158162
if: ${{ inputs.run-tests }}
159-
run: ${{ inputs.test-script }}
160-
env: ${{ fromJson(inputs.test-environment-variables) }}
163+
run: |
164+
# Parse and export environment variables from JSON
165+
# Handle empty or null TEST_SECRETS
166+
if [ -z "$TEST_SECRETS" ] || [ "$TEST_SECRETS" = "null" ]; then
167+
TEST_SECRETS='{}'
168+
fi
169+
170+
# Use jq to merge JSON objects, with TEST_SECRETS taking precedence
171+
echo "$TEST_ENV_VARS $TEST_SECRETS" | jq -s '.[0] * .[1]' | jq -r 'to_entries[] | "export \(.key)=\(.value)"' | while IFS= read -r line; do
172+
eval "$line"
173+
done
174+
175+
# Run the test script
176+
${{ inputs.test-script }}
177+
env:
178+
TEST_ENV_VARS: '${{ inputs.test-environment-variables }}'
179+
TEST_SECRETS: '${{ secrets.TEST_SECRETS }}'
161180

162181
- name: Publish coverage
163182
if: ${{ inputs.publish-coverage-path }}

0 commit comments

Comments
 (0)