Skip to content

Commit 45d5915

Browse files
authored
Merge pull request #2 from AndyHaas/feature/nebula-adapter-integration
Feature/nebula adapter integration
2 parents ffa6377 + 0cd7ff8 commit 45d5915

File tree

3 files changed

+897
-47
lines changed

3 files changed

+897
-47
lines changed

.github/workflows/create-release.yml

Lines changed: 159 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,133 @@ jobs:
143143
run: |
144144
sf project convert source --root-dir force-app --output-dir mdapi_out
145145
146+
- name: Run tests and check code coverage
147+
run: |
148+
echo "Running tests for package-specific test classes: NebulaAdapter_Test, RestLibTests"
149+
150+
# Run only the test classes that are part of this package
151+
set +e # Don't exit on error, we'll handle it manually
152+
sf apex test run --class-names NebulaAdapter_Test,RestLibTests --target-org pkgorg --result-format json --code-coverage --wait 10 > test_result.json 2>&1
153+
TEST_EXIT_CODE=$?
154+
set -e # Re-enable exit on error
155+
156+
echo "Test execution exit code: $TEST_EXIT_CODE"
157+
echo "Test execution output:"
158+
# Read from file to avoid broken pipe issues
159+
cat test_result.json
160+
161+
# Check if test execution was successful
162+
if [ $TEST_EXIT_CODE -ne 0 ]; then
163+
echo "❌ ERROR: Test execution failed with exit code $TEST_EXIT_CODE"
164+
echo "Raw output:"
165+
cat test_result.json
166+
exit 1
167+
fi
168+
169+
# Check if we have valid JSON output
170+
if ! jq -e '.result' test_result.json > /dev/null 2>&1; then
171+
echo "❌ ERROR: Invalid test result format"
172+
echo "Raw output:"
173+
cat test_result.json
174+
exit 1
175+
fi
176+
177+
# Extract test summary
178+
if jq -e '.result.summary' test_result.json > /dev/null 2>&1; then
179+
SUMMARY=$(jq -r '.result.summary' test_result.json)
180+
echo "Test Summary: $SUMMARY"
181+
182+
# Show detailed test counts
183+
PASSING=$(jq -r '.result.summary.passing // 0' test_result.json)
184+
FAILING=$(jq -r '.result.summary.failing // 0' test_result.json)
185+
SKIPPED=$(jq -r '.result.summary.skipped // 0' test_result.json)
186+
TESTS_RAN=$(jq -r '.result.summary.testsRan // 0' test_result.json)
187+
188+
echo "📈 Test Results: $PASSING passed, $FAILING failed, $SKIPPED skipped (Total: $TESTS_RAN)"
189+
fi
190+
191+
# Extract coverage percentage - try multiple possible locations in the JSON
192+
COVERAGE=""
193+
if jq -e '.result.summary.testRunCoverage' test_result.json > /dev/null 2>&1; then
194+
COVERAGE=$(jq -r '.result.summary.testRunCoverage' test_result.json | sed 's/%//')
195+
echo "Code coverage (test run): $COVERAGE%"
196+
elif jq -e '.result.coverage.coverage' test_result.json > /dev/null 2>&1; then
197+
COVERAGE=$(jq -r '.result.coverage.coverage[].percent' test_result.json)
198+
echo "Code coverage (per class): $COVERAGE%"
199+
else
200+
echo "⚠️ WARNING: Could not extract coverage information from test results"
201+
fi
202+
203+
# Check if coverage meets minimum requirement (75%)
204+
if [ -n "$COVERAGE" ]; then
205+
MIN_COVERAGE=75
206+
if (( $(echo "$COVERAGE < $MIN_COVERAGE" | bc -l) )); then
207+
echo ""
208+
echo "❌ COVERAGE FAILURE: Code coverage $COVERAGE% is below minimum requirement of $MIN_COVERAGE%"
209+
echo ""
210+
echo "📊 COVERAGE ANALYSIS:"
211+
echo " Current Coverage: $COVERAGE%"
212+
echo " Required Coverage: $MIN_COVERAGE%"
213+
echo " Coverage Gap: $((MIN_COVERAGE - COVERAGE))%"
214+
echo ""
215+
echo "🔍 TEST CLASSES BEING VALIDATED:"
216+
echo " - NebulaAdapter_Test"
217+
echo " - RestLibTests"
218+
echo ""
219+
echo "💡 TO FIX THIS ISSUE:"
220+
echo " 1. Add more test methods to cover uncovered code paths"
221+
echo " 2. Improve existing test methods to cover more scenarios"
222+
echo " 3. Review uncovered lines in the test results above"
223+
echo " 4. Ensure all public methods and critical code paths are tested"
224+
echo ""
225+
echo "📋 NEXT STEPS:"
226+
echo " - Check the detailed coverage information in the test output above"
227+
echo " - Look for 'uncoveredLines' in the JSON output to see which lines need testing"
228+
echo " - Add test methods for any missing scenarios"
229+
echo " - Re-run the workflow after improving test coverage"
230+
echo ""
231+
exit 1
232+
else
233+
echo "✅ SUCCESS: Code coverage $COVERAGE% meets minimum requirement of $MIN_COVERAGE%"
234+
fi
235+
fi
236+
237+
# Check for test failures
238+
if jq -e '.result.failures' test_result.json > /dev/null 2>&1; then
239+
FAILURES=$(jq -r '.result.failures' test_result.json)
240+
if [ "$FAILURES" != "0" ] && [ "$FAILURES" != "null" ]; then
241+
echo "❌ ERROR: $FAILURES test(s) failed"
242+
echo "Test failures details:"
243+
jq -r '.result.tests[] | select(.Outcome == "Fail") | " - \(.MethodName): \(.Message)"' test_result.json 2>/dev/null || echo "Could not extract failure details"
244+
exit 1
245+
fi
246+
fi
247+
248+
# Clean up temporary test result file
249+
rm -f test_result.json
250+
146251
- name: Deploy to packaging org
147252
run: |
148-
sf project deploy start --metadata-dir mdapi_out --target-org pkgorg --wait 60 --ignore-conflicts
253+
echo "Deploying converted metadata to packaging org..."
254+
echo "Source directory: mdapi_out"
255+
echo "Target org: pkgorg"
256+
257+
set +e # Don't exit on error, we'll handle it manually
258+
DEPLOY_OUTPUT=$(sf project deploy start --metadata-dir mdapi_out --target-org pkgorg --wait 60 --ignore-conflicts 2>&1)
259+
DEPLOY_EXIT_CODE=$?
260+
set -e # Re-enable exit on error
261+
262+
echo "Deploy exit code: $DEPLOY_EXIT_CODE"
263+
echo "Deploy output:"
264+
echo "$DEPLOY_OUTPUT"
265+
266+
if [ $DEPLOY_EXIT_CODE -eq 0 ]; then
267+
echo "✅ Successfully deployed to packaging org"
268+
else
269+
echo "❌ ERROR: Deployment failed with exit code $DEPLOY_EXIT_CODE"
270+
echo "💡 Check the output above for specific error details"
271+
exit 1
272+
fi
149273
150274
- name: Create package and version
151275
id: package_version
@@ -215,19 +339,23 @@ jobs:
215339
echo "Creating package version for package: $SF_PACKAGE1_ID"
216340
echo "Command: sf package version create --package '$SF_PACKAGE1_ID' --installation-key-bypass --wait 10 --target-dev-hub pkgorg --json"
217341
342+
# Run the command and capture both output and exit code
343+
set +e # Don't exit on error, we'll handle it manually
218344
PACKAGE_VERSION_OUTPUT=$(sf package version create \
219345
--package "$SF_PACKAGE1_ID" \
220346
--installation-key-bypass \
221347
--wait 10 \
222348
--target-dev-hub pkgorg \
223349
--json 2>&1)
350+
PACKAGE_VERSION_EXIT_CODE=$?
351+
set -e # Re-enable exit on error
224352
225-
echo "Package version create exit code: $?"
353+
echo "Package version create exit code: $PACKAGE_VERSION_EXIT_CODE"
226354
echo "Package version create output:"
227355
echo "$PACKAGE_VERSION_OUTPUT"
228356
229357
# Check if the command was successful
230-
if echo "$PACKAGE_VERSION_OUTPUT" | jq -e '.result.SubscriberPackageVersionId' > /dev/null 2>&1; then
358+
if [ $PACKAGE_VERSION_EXIT_CODE -eq 0 ] && echo "$PACKAGE_VERSION_OUTPUT" | jq -e '.result.SubscriberPackageVersionId' > /dev/null 2>&1; then
231359
# Extract the package version ID and create installation URLs
232360
PACKAGE_VERSION_ID=$(echo "$PACKAGE_VERSION_OUTPUT" | jq -r '.result.SubscriberPackageVersionId')
233361
PRODUCTION_URL="https://login.salesforce.com/packaging/installPackage.apexp?p0=$PACKAGE_VERSION_ID"
@@ -238,12 +366,38 @@ jobs:
238366
echo "sandbox_url=$SANDBOX_URL" >> $GITHUB_OUTPUT
239367
echo "package_id=$SF_PACKAGE1_ID" >> $GITHUB_OUTPUT
240368
241-
echo "Created package version: $PACKAGE_VERSION_ID"
369+
echo "Created package version: $PACKAGE_VERSION_ID"
242370
echo "Production URL: $PRODUCTION_URL"
243371
echo "Sandbox URL: $SANDBOX_URL"
244372
else
245-
echo "ERROR: Failed to create package version"
373+
echo "❌ ERROR: Failed to create package version"
374+
echo "Exit code: $PACKAGE_VERSION_EXIT_CODE"
246375
echo "Full output: $PACKAGE_VERSION_OUTPUT"
376+
377+
# Try to extract error details from JSON output
378+
if echo "$PACKAGE_VERSION_OUTPUT" | jq -e '.message' > /dev/null 2>&1; then
379+
ERROR_MESSAGE=$(echo "$PACKAGE_VERSION_OUTPUT" | jq -r '.message')
380+
echo "Error message: $ERROR_MESSAGE"
381+
fi
382+
383+
if echo "$PACKAGE_VERSION_OUTPUT" | jq -e '.result[0].error' > /dev/null 2>&1; then
384+
ERROR_DETAILS=$(echo "$PACKAGE_VERSION_OUTPUT" | jq -r '.result[0].error')
385+
echo "Error details: $ERROR_DETAILS"
386+
fi
387+
388+
# Check for common issues
389+
if echo "$PACKAGE_VERSION_OUTPUT" | grep -i "permission" > /dev/null; then
390+
echo "💡 Possible permission issue - check if the user has Package Creation permissions"
391+
fi
392+
393+
if echo "$PACKAGE_VERSION_OUTPUT" | grep -i "validation" > /dev/null; then
394+
echo "💡 Possible validation error - check if all metadata is valid"
395+
fi
396+
397+
if echo "$PACKAGE_VERSION_OUTPUT" | grep -i "coverage" > /dev/null; then
398+
echo "💡 Possible code coverage issue - ensure all code has adequate test coverage"
399+
fi
400+
247401
exit 1
248402
fi
249403

0 commit comments

Comments
 (0)