Skip to content

Commit b6fd03d

Browse files
GvieveGenevieve Nuebel
andauthored
Fix sandbox workflow files (#87)
* Fix test-auto-generate workflow: config persistence, changelog version bug, respository dispatch - Issue 1: Upload config files as artifacts in Generate job, restore in Process-and-Push so version bumps persist across runners - Issue 2: Pass test directory names to changelog_manager.rb so it reads correct package.json (sandbox-only fix) - Issue 3: Pass generated versions in repository_dispatch client payload, use payload-based detection instead of paths-filter for dispatch events (sandbox-only fix, production uses same branch so paths-filter works) --------- Co-authored-by: Genevieve Nuebel <genevieve.nuebel@mx.com>
1 parent 30bce5a commit b6fd03d

2 files changed

Lines changed: 64 additions & 8 deletions

File tree

β€Ž.github/workflows/test-auto-generate.ymlβ€Ž

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,18 @@ jobs:
133133
echo "πŸ“‹ Generated files in test-${{ matrix.api_version }}/:"
134134
ls -la ./test-${{ matrix.api_version }}/
135135
136-
- name: Upload artifacts
136+
- name: Upload SDK artifacts
137137
uses: actions/upload-artifact@v4
138138
with:
139139
name: test-generated-${{ matrix.api_version }}
140140
path: ./test-${{ matrix.api_version }}
141141

142+
- name: Upload config artifact (for version bump persistence)
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: test-config-${{ matrix.api_version }}
146+
path: ${{ matrix.config_file }}
147+
142148
Process-and-Push:
143149
runs-on: ubuntu-latest
144150
needs: [Setup, Generate]
@@ -157,6 +163,22 @@ jobs:
157163
with:
158164
path: ./test-generated
159165

166+
- name: Restore config files from artifacts
167+
run: |
168+
echo "πŸ“‹ Restoring config files from artifacts..."
169+
if [ -d "./test-generated/test-config-v20111101" ]; then
170+
echo "πŸ“‹ Restoring test-config-v20111101.yml"
171+
cp ./test-generated/test-config-v20111101/* ./openapi/test-config-v20111101.yml 2>/dev/null || echo " (file not found in artifact)"
172+
fi
173+
if [ -d "./test-generated/test-config-v20250224" ]; then
174+
echo "πŸ“‹ Restoring test-config-v20250224.yml"
175+
cp ./test-generated/test-config-v20250224/* ./openapi/test-config-v20250224.yml 2>/dev/null || echo " (file not found in artifact)"
176+
fi
177+
echo "πŸ“‹ Config files after restoration:"
178+
cat ./openapi/test-config-v20111101.yml 2>/dev/null || echo " test-config-v20111101.yml not available"
179+
echo "---"
180+
cat ./openapi/test-config-v20250224.yml 2>/dev/null || echo " test-config-v20250224.yml not available"
181+
160182
- name: Move generated files and track versions
161183
id: track_versions
162184
run: |
@@ -213,9 +235,13 @@ jobs:
213235
cp CHANGELOG.md CHANGELOG.md.bak
214236
cp TEST-CHANGELOG.md CHANGELOG.md
215237
216-
VERSIONS_CSV=$(echo "$GENERATED_VERSIONS" | xargs | tr ' ' ',')
217-
echo "πŸ“‹ Updating TEST-CHANGELOG for versions: $VERSIONS_CSV"
218-
ruby .github/changelog_manager.rb "$VERSIONS_CSV"
238+
# *** ISSUE 2 FIX: Pass test directory names to changelog_manager.rb ***
239+
# Instead of "v20111101", pass "test-v20111101" so changelog_manager reads from
240+
# test-v20111101/package.json (version 98.1.0) not v20111101/package.json (version 2.0.0)
241+
TEST_VERSIONS_CSV=$(echo "$GENERATED_VERSIONS" | xargs | sed 's/v20111101/test-v20111101/g' | sed 's/v20250224/test-v20250224/g' | tr ' ' ',')
242+
echo "πŸ“‹ Updating TEST-CHANGELOG for versions: $TEST_VERSIONS_CSV"
243+
echo "πŸ“‹ (directory names: converting api versions to test- prefixed directories)"
244+
ruby .github/changelog_manager.rb "$TEST_VERSIONS_CSV"
219245
220246
# Move updated changelog to TEST-CHANGELOG and restore real one
221247
cp CHANGELOG.md TEST-CHANGELOG.md
@@ -261,6 +287,7 @@ jobs:
261287
with:
262288
token: ${{ steps.generate_token.outputs.token }}
263289
event-type: test_push_to_branch
290+
client-payload: '{"versions": "${{ needs.Setup.outputs.versions_to_generate }}"}'
264291

265292
- name: Summary
266293
run: |

β€Ž.github/workflows/test-on-push.ymlβ€Ž

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,51 @@ jobs:
3939
echo "βœ… No skip flag - proceeding with publish/release"
4040
fi
4141
42-
# Detect which test API versions were modified in this push
42+
# Detect which test API versions were modified
43+
# On repository_dispatch: versions come from client payload (paths-filter can't
44+
# detect changes correctly because dispatch runs on master, not test-auto-generate)
45+
# On push: use paths-filter as normal (push events have correct git context)
46+
# NOTE: This is a SANDBOX-ONLY workaround. Production on-push-master.yml does NOT
47+
# need this because both push and dispatch target master (same branch = correct context).
4348
detect-changes:
4449
runs-on: ubuntu-latest
4550
outputs:
46-
test_v20111101: ${{ steps.filter.outputs.test_v20111101 }}
47-
test_v20250224: ${{ steps.filter.outputs.test_v20250224 }}
51+
test_v20111101: ${{ steps.result.outputs.test_v20111101 }}
52+
test_v20250224: ${{ steps.result.outputs.test_v20250224 }}
4853
steps:
4954
- uses: actions/checkout@v3
50-
- uses: dorny/paths-filter@v2
55+
- name: Detect from dispatch payload
56+
id: dispatch
57+
if: github.event_name == 'repository_dispatch'
58+
run: |
59+
VERSIONS="${{ github.event.client_payload.versions }}"
60+
echo "πŸ“‹ Dispatch payload versions: $VERSIONS"
61+
[[ "$VERSIONS" == *"v20111101"* ]] && echo "test_v20111101=true" >> $GITHUB_OUTPUT || echo "test_v20111101=false" >> $GITHUB_OUTPUT
62+
[[ "$VERSIONS" == *"v20250224"* ]] && echo "test_v20250224=true" >> $GITHUB_OUTPUT || echo "test_v20250224=false" >> $GITHUB_OUTPUT
63+
- name: Detect from push paths
5164
id: filter
65+
if: github.event_name == 'push'
66+
uses: dorny/paths-filter@v2
5267
with:
5368
filters: |
5469
test_v20111101:
5570
- 'test-v20111101/**'
5671
test_v20250224:
5772
- 'test-v20250224/**'
73+
- name: Set outputs
74+
id: result
75+
run: |
76+
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
77+
echo "test_v20111101=${{ steps.dispatch.outputs.test_v20111101 }}" >> $GITHUB_OUTPUT
78+
echo "test_v20250224=${{ steps.dispatch.outputs.test_v20250224 }}" >> $GITHUB_OUTPUT
79+
echo "πŸ“‹ Using dispatch-based detection"
80+
else
81+
echo "test_v20111101=${{ steps.filter.outputs.test_v20111101 }}" >> $GITHUB_OUTPUT
82+
echo "test_v20250224=${{ steps.filter.outputs.test_v20250224 }}" >> $GITHUB_OUTPUT
83+
echo "πŸ“‹ Using paths-filter-based detection"
84+
fi
85+
echo "πŸ“‹ test_v20111101=${{ steps.dispatch.outputs.test_v20111101 || steps.filter.outputs.test_v20111101 }}"
86+
echo "πŸ“‹ test_v20250224=${{ steps.dispatch.outputs.test_v20250224 || steps.filter.outputs.test_v20250224 }}"
5887
5988
# Simulated publish and release for each version conditionally
6089
# Same conditional structure as production but echoes success instead of real npm publish/GitHub release

0 commit comments

Comments
Β (0)