Skip to content

Commit bc583b5

Browse files
committed
Enhance CI testing with smart PR version detection and comprehensive error reporting
1 parent 106792a commit bc583b5

2 files changed

Lines changed: 72 additions & 3 deletions

File tree

.github/workflows/postgresql-test.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,37 @@ jobs:
4848
VERSION="${{ github.event.inputs.version }}"
4949
echo "Testing specific version: $VERSION"
5050
VERSIONS="[\"$VERSION\"]"
51+
elif [ "${{ github.event_name }}" == "pull_request" ]; then
52+
# For PRs, detect which versions were added or modified
53+
echo "Detecting versions changed in this PR..."
54+
echo "Base ref: ${{ github.base_ref }}"
55+
echo "Head ref: ${{ github.head_ref }}"
56+
57+
# Get changed lines in releases.properties using GitHub's merge base
58+
CHANGED_VERSIONS=$(git diff ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- releases.properties 2>/dev/null | \
59+
grep "^+" | \
60+
grep -v "^+++" | \
61+
grep -E "^\\+[0-9]+\\.[0-9]+" | \
62+
sed 's/^+//' | \
63+
cut -d'=' -f1 | \
64+
tr -d ' ' | \
65+
grep -v -E "(RC|beta|alpha)" || true)
66+
67+
if [ -z "$CHANGED_VERSIONS" ]; then
68+
echo "No version changes detected in releases.properties"
69+
echo "Testing latest 5 stable versions as fallback"
70+
VERSIONS=$(grep -E "^[0-9]+\.[0-9]+" releases.properties | \
71+
grep -v -E "(RC|beta|alpha)" | \
72+
cut -d'=' -f1 | \
73+
tr -d ' ' | \
74+
jq -R -s -c 'split("\n") | map(select(length > 0)) | unique | sort_by(split(".") | map(tonumber)) | reverse | .[0:5]')
75+
else
76+
echo "Changed versions detected:"
77+
echo "$CHANGED_VERSIONS"
78+
VERSIONS=$(echo "$CHANGED_VERSIONS" | jq -R -s -c 'split("\n") | map(select(length > 0)) | unique')
79+
fi
5180
else
52-
# Get all versions from releases.properties, excluding RC/beta versions
81+
# For other events, test latest 5 stable versions
5382
VERSIONS=$(grep -E "^[0-9]+\.[0-9]+" releases.properties | \
5483
grep -v -E "(RC|beta|alpha)" | \
5584
cut -d'=' -f1 | \

docs/CI-CD-TESTING.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,24 @@ The PostgreSQL testing workflow is triggered automatically on:
1313

1414
## Test Scope
1515

16-
The workflow tests the **latest 5 PostgreSQL versions** from `releases.properties` by default. This ensures recent versions are validated while keeping CI runtime reasonable.
16+
The workflow intelligently determines which versions to test based on the context:
17+
18+
### Pull Request Testing
19+
- **Smart Detection**: Automatically detects which PostgreSQL versions were added or modified in the PR
20+
- **Targeted Testing**: Only tests the versions that changed in `releases.properties`
21+
- **Efficiency**: Reduces CI runtime by testing only relevant versions
22+
- **Fallback**: If no version changes detected, tests the latest 5 stable versions
23+
- **Exclusions**: Automatically excludes RC (Release Candidate), beta, and alpha versions
24+
25+
### Manual Testing
26+
- Tests a specific version provided as input parameter
27+
- Useful for re-testing or validating specific versions
28+
29+
### Example Scenarios
30+
- **Add PostgreSQL 17.5**: Only version 17.5 is tested
31+
- **Add versions 16.9 and 17.5**: Both versions are tested
32+
- **Modify existing version URL**: That specific version is tested
33+
- **Non-version changes**: Latest 5 stable versions tested as fallback
1734

1835
## Test Phases
1936

@@ -149,11 +166,34 @@ Each version's summary includes:
149166

150167
## Error Handling
151168

169+
The workflow provides comprehensive error reporting at multiple levels:
170+
171+
### Detailed Error Messages
172+
173+
Each phase captures and reports specific error information:
174+
175+
- **Download failures**: HTTP status codes, error messages, attempted URLs
176+
- **Extraction failures**: 7-Zip exit codes, output logs, directory listings
177+
- **Missing files**: Expected vs. actual directory structure
178+
- **Server failures**: Complete server logs, initialization output
179+
- **Database operation failures**: SQL error messages, connection details
180+
181+
### Error Propagation
182+
152183
- Each phase uses `continue-on-error: true` to allow subsequent phases to run
153-
- Failed phases are clearly marked in the summary
184+
- Failed phases are clearly marked in the summary with ❌ indicators
185+
- Error messages are included inline in test summaries
154186
- Server logs are always uploaded for debugging
155187
- Cleanup phase always runs to prevent resource leaks
156188

189+
### Troubleshooting Assistance
190+
191+
When tests fail, the summary includes:
192+
- Specific error messages for each failed phase
193+
- Collapsible troubleshooting tips section
194+
- Links to detailed workflow logs
195+
- References to downloadable artifacts
196+
157197
## Platform
158198

159199
- **Runner**: `windows-latest`

0 commit comments

Comments
 (0)