@@ -28,11 +28,21 @@ jobs:
2828 pull-requests : write
2929
3030 steps :
31- - name : Checkout main branch
31+ - name : Determine target branch
32+ id : target-branch
33+ run : |
34+ if [ "${{ github.event_name }}" = "pull_request" ]; then
35+ echo "branch=${{ github.event.pull_request.base.ref }}" >> $GITHUB_OUTPUT
36+ else
37+ echo "branch=main" >> $GITHUB_OUTPUT
38+ fi
39+
40+ - name : Checkout target branch
3241 uses : actions/checkout@v4
3342 with :
34- ref : main
35- path : ' ./main'
43+ ref : ${{ steps.target-branch.outputs.branch }}
44+ path : ' ./target'
45+
3646
3747 - name : Checkout PR branch
3848 uses : actions/checkout@v4
@@ -62,10 +72,10 @@ jobs:
6272 echo "Installing gulp"
6373 npm install --global [email protected] 6474
65- - name : Install dependencies and build main extension
75+ - name : Install dependencies and build target extension
6676 uses : ./pr/.github/actions/build-extension
6777 with :
68- source-dir : ' ./main '
78+ source-dir : ' ./target '
6979
7080 - name : Install dependencies and build PR extension
7181 uses : ./pr/.github/actions/build-extension
8292 # that increase size
8393 - name : Package both branches
8494 run : |
85- cd main
95+ cd target
8696 yarn gulp package:online
8797 cd ../pr
8898 yarn gulp package:online
@@ -95,15 +105,15 @@ jobs:
95105
96106 - name : Calculate webview bundle sizes
97107 run : |
98- main_file =$(du -sk ./main/out/src/reactviews/assets | cut -f1)
99- pr_file=$(du -sk ./pr/out/src/reactviews/assets | cut -f1)
100- echo "Main branch bundle size: $main_file KB"
108+ target_file =$(du -sk ./target/dist/views | cut -f1)
109+ pr_file=$(du -sk ./pr/dist/views | cut -f1)
110+ echo "Target branch bundle size: $target_file KB"
101111 echo "PR branch bundle size: $pr_file KB"
102- size_diff=$((pr_file - main_file ))
103- percentage_change=$((100 * size_diff / main_file ))
112+ size_diff=$((pr_file - target_file ))
113+ percentage_change=$((100 * size_diff / target_file ))
104114 echo "Size difference: $size_diff KB"
105115 echo "Percentage change: $percentage_change%"
106- echo "main_webview_bundle_size=$main_file " >> $GITHUB_ENV
116+ echo "target_webview_bundle_size=$target_file " >> $GITHUB_ENV
107117 echo "pr_webview_bundle_size=$pr_file" >> $GITHUB_ENV
108118 echo "webview_size_diff=$size_diff" >> $GITHUB_ENV
109119 echo "webview_bundle_percentage_change=$percentage_change" >> $GITHUB_ENV
@@ -117,19 +127,19 @@ jobs:
117127
118128 - name : Calculate vsix file sizes
119129 run : |
120- main_vsix =$(find ./main -name "*.vsix")
130+ target_vsix =$(find ./target -name "*.vsix")
121131 pr_vsix=$(find ./pr -name "*.vsix")
122- main_size =$(stat -c%s "$main_vsix ")
132+ target_size =$(stat -c%s "$target_vsix ")
123133 pr_size=$(stat -c%s "$pr_vsix")
124- main_size =$((main_size / 1024))
134+ target_size =$((target_size / 1024))
125135 pr_size=$((pr_size / 1024))
126- size_diff=$((pr_size - main_size ))
127- percentage_change=$((100 * size_diff / main_size ))
128- echo "Main branch VSIX size: $main_size KB"
136+ size_diff=$((pr_size - target_size ))
137+ percentage_change=$((100 * size_diff / target_size ))
138+ echo "Target branch VSIX size: $target_size KB"
129139 echo "PR branch VSIX size: $pr_size KB"
130140 echo "Size difference: $size_diff bytes"
131141 echo "Percentage change: $percentage_change%"
132- echo "main_vsix_size=$main_size " >> $GITHUB_ENV
142+ echo "target_vsix_size=$target_size " >> $GITHUB_ENV
133143 echo "pr_vsix_size=$pr_size" >> $GITHUB_ENV
134144 echo "vsix_size_diff=$size_diff" >> $GITHUB_ENV
135145 echo "vsix_percentage_change=$percentage_change" >> $GITHUB_ENV
@@ -142,31 +152,36 @@ jobs:
142152 fi
143153
144154 - name : Run unit tests for PR branch
155+ continue-on-error : true
145156 run : |
157+ set +e # Don't exit on errors
146158 cd pr
147159 DISPLAY=:10 yarn test
160+ UNIT_EXIT_CODE=$?
161+ echo "unit_tests_pr_exit_code=$UNIT_EXIT_CODE" >> $GITHUB_ENV
148162
149163 - name : PR Unit Test Report
150- uses : dorny/test-reporter@v1
164+ uses : dorny/test-reporter@v2
151165 if : success() || failure()
152166 with :
153167 name : ' Unit Test Report'
154168 path : ./test-reports/**/*.xml
155169 reporter : jest-junit
156170 working-directory : ./pr
157171 badge-title : ' unit-tests'
172+ fail-on-error : false
158173
159- - name : Run unit tests for main branch # for calculating coverage comparison
174+ - name : Run unit tests for target branch # for calculating coverage comparison
160175 continue-on-error : true
161176 run : |
162- cd main
177+ cd target
163178 DISPLAY=:10 yarn test
164179
165180 - name : Build mappings for React Webviews
166181 run : |
167182 cd ./pr
168183 gulp ext:compile-reactviews
169- cd ../main
184+ cd ../target
170185 gulp ext:compile-reactviews
171186
172187 - name : Setup environment for smoke tests
@@ -194,7 +209,9 @@ jobs:
194209 working-directory : ./pr
195210
196211 - name : Run smoke tests for PR branch
212+ continue-on-error : true
197213 run : |
214+ set +e # Don't exit on errors
198215 VS_CODE_VERSION=stable
199216 SERVER_NAME=localhost
200217 AUTHENTICATION_TYPE="SQL Login"
@@ -204,28 +221,31 @@ jobs:
204221 PROFILE_NAME=test-server
205222 cd pr
206223 DISPLAY=:10 yarn smoketest
207- cd ../main
224+ cd ../target
208225 DISPLAY=:10 yarn smoketest
226+ SMOKE_EXIT_CODE=$?
227+ echo "smoke_tests_pr_exit_code=$SMOKE_EXIT_CODE" >> $GITHUB_ENV
209228
210229 - name : Upload Smoke Test Screenshots
211230 uses : actions/upload-artifact@v4
212- if : failure()
213231 with :
214232 name : smoke-test-failure-screenshots
215233 path : ./pr/test-results/**/
216234 retention-days : 7
217235
218- - name : Smoke Test Report
219- uses : dorny/test-reporter@v1
236+
237+ - name : PR Smoke Test Report
238+ uses : dorny/test-reporter@v2
220239 if : success() || failure()
221240 with :
222- name : ' Smoke Test Report'
223- path : ./test-reports/**/smoke-results.xml
224- reporter : jest-junit
225- badge-title : ' smoke-tests'
226- working-directory : ./pr
241+ name : ' Smoke Test Report'
242+ path : ./test-reports/**/smoke-results.xml
243+ reporter : jest-junit
244+ working-directory : ./pr
245+ badge-title : ' smoke-tests'
246+ fail-on-error : false
227247
228- - name : Run smoke tests for main branch # for calculating coverage comparison
248+ - name : Run smoke tests for target branch # for calculating coverage comparison
229249 continue-on-error : true
230250 run : |
231251 VS_CODE_VERSION=stable
@@ -235,15 +255,15 @@ jobs:
235255 PASSWORD=${{ env.PASSWORD }}
236256 SAVE_PASSWORD=No
237257 PROFILE_NAME=test-server
238- cd main
258+ cd target
239259 DISPLAY=:10 yarn smoketest
240260
241261 - name : Merge Smoke and Unit Test Coverage Reports
242262 run : |
243- if [ -f main /test/resources/mergeReports.js ]; then
244- node main /test/resources/mergeReports.js main /coverage/coverage-e2e/cobertura-coverage.xml main /coverage/cobertura-coverage.xml
263+ if [ -f target /test/resources/mergeReports.js ]; then
264+ node target /test/resources/mergeReports.js target /coverage/coverage-e2e/cobertura-coverage.xml target /coverage/cobertura-coverage.xml
245265 else
246- echo "mergeReports.js not found in ./main , skipping..."
266+ echo "mergeReports.js not found in ./target , skipping..."
247267 fi
248268
249269 if [ -f pr/test/resources/mergeReports.js ]; then
@@ -268,13 +288,13 @@ jobs:
268288
269289 - name : Code coverage
270290 run : |
271- cd main
272- xml_coverage_main ="./coverage/cobertura-coverage.xml"
273- # Pull out the line rate coverage from the main branch's cobertura report
274- line_rate_main =$(grep -m 1 -o 'line-rate="[0-9.]\+"' "$xml_coverage_main " | sed 's/line-rate="\([0-9.]*\)"/\1/')
275- line_rate_main =$(printf "%.2f" $(echo "$line_rate_main * 100" | bc))
291+ cd target
292+ xml_coverage_target ="./coverage/cobertura-coverage.xml"
293+ # Pull out the line rate coverage from the target branch's cobertura report
294+ line_rate_target =$(grep -m 1 -o 'line-rate="[0-9.]\+"' "$xml_coverage_target " | sed 's/line-rate="\([0-9.]*\)"/\1/')
295+ line_rate_target =$(printf "%.2f" $(echo "$line_rate_target * 100" | bc))
276296 # Save formatted line rate in env variable
277- echo "line_rate_main=$line_rate_main " >> $GITHUB_ENV
297+ echo "line_rate_target=$line_rate_target " >> $GITHUB_ENV
278298 cd ../pr
279299 xml_coverage_pr="./coverage/cobertura-coverage.xml"
280300 # Pull out the line rate coverage from the pr branch's cobertura report
@@ -283,7 +303,7 @@ jobs:
283303 # Save formatted line rate in env variable
284304 echo "line_rate_pr=$line_rate_pr" >> $GITHUB_ENV
285305 # Calculate difference in line coverage rate
286- echo "line_rate_diff=$(echo "$line_rate_pr - $line_rate_main " | bc)" >> $GITHUB_ENV
306+ echo "line_rate_diff=$(echo "$line_rate_pr - $line_rate_target " | bc)" >> $GITHUB_ENV
287307 # Save formatted line rate difference in env variable
288308 line_rate_diff=$(printf "%.2f" $(echo "$line_rate_diff * 100" | bc))
289309 echo "line_rate_diff=$line_rate_diff" >> $GITHUB_ENV
@@ -298,11 +318,11 @@ jobs:
298318 - name : Write PR results to markdown
299319 run : |
300320 echo "### PR Changes" >> results.md
301- echo "| Category | Main Branch | PR Branch | Difference |" >> results.md
321+ echo "| Category | Target Branch | PR Branch | Difference |" >> results.md
302322 echo "|------------------------------|--------------------|-------------------|----------------------|" >> results.md
303- echo "| Code Coverage | ${{ env.line_rate_main }}% | ${{ env.line_rate_pr }}% | ${{ env.coverage_change_icon }} ${{ env.line_rate_diff }}% |" >> results.md
304- echo "| VSIX Size | ${{ env.main_vsix_size }} KB | ${{ env.pr_vsix_size }} KB | ${{ env.vsix_change_icon }} ${{ env.vsix_size_diff }} KB ( ${{ env.vsix_percentage_change }}% ) |" >> results.md
305- echo "| Webview Bundle Size | ${{ env.main_webview_bundle_size }} KB | ${{ env.pr_webview_bundle_size }} KB | ${{ env.webview_change_icon }} ${{ env.webview_size_diff }} KB ( ${{ env.webview_bundle_percentage_change }}% ) |" >> results.md
323+ echo "| Code Coverage | ${{ env.line_rate_target }}% | ${{ env.line_rate_pr }}% | ${{ env.coverage_change_icon }} ${{ env.line_rate_diff }}% |" >> results.md
324+ echo "| VSIX Size | ${{ env.target_vsix_size }} KB | ${{ env.pr_vsix_size }} KB | ${{ env.vsix_change_icon }} ${{ env.vsix_size_diff }} KB ( ${{ env.vsix_percentage_change }}% ) |" >> results.md
325+ echo "| Webview Bundle Size | ${{ env.target_webview_bundle_size }} KB | ${{ env.pr_webview_bundle_size }} KB | ${{ env.webview_change_icon }} ${{ env.webview_size_diff }} KB ( ${{ env.webview_bundle_percentage_change }}% ) |" >> results.md
306326
307327 - name : Find comment
308328 uses : peter-evans/find-comment@v3
@@ -324,14 +344,6 @@ jobs:
324344 comment-id : ${{ steps.fc.outputs.comment-id }}
325345 edit-mode : replace
326346
327- - name : Fail if vsix size is increased by 5% or size is above 25mb
328- if : ${{ env.vsix_percentage_change > 5 || env.pr_vsix_size > 25000000 }}
329- run : exit 1
330-
331- - name : Fail if bundle size is increased by 5%
332- if : ${{ env.webview_bundle_percentage_change > 5 }}
333- run : exit 1
334-
335347 - name : Generate xliff files in PR branch
336348 run : |
337349 cd pr
@@ -376,13 +388,62 @@ jobs:
376388 edit-mode : replace
377389
378390 - name : Delete comment
379- if : github.event_name == 'pull_request' && ${{ env.loc_update_required == 'false' }} && steps.loc-comment.outputs.comment-id != ''
391+ if : ${{ github.event_name == 'pull_request' && env.loc_update_required == 'false' && steps.loc-comment.outputs.comment-id != '' }}
380392 run : |
381393 curl -X DELETE \
382394 -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
383395 -H "Accept: application/vnd.github.v3+json" \
384396 https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ steps.loc-comment.outputs.comment-id }}
385397
386- - name : Fail if there are changes required in english xlf files
387- if : ${{ env.loc_update_required == 'true' }}
388- run : exit 1
398+ - name : Fail pipeline if any checks failed
399+ if : always()
400+ run : |
401+ # Initialize failure flag
402+ PIPELINE_FAILED=false
403+
404+ echo "Checking pipeline results..."
405+
406+ # Check unit tests
407+ if [ "${{ env.unit_tests_pr_exit_code }}" != "0" ] && [ "${{ env.unit_tests_pr_exit_code }}" != "" ]; then
408+ echo " ❌ Unit tests failed with exit code ${{ env.unit_tests_pr_exit_code }}"
409+ PIPELINE_FAILED=true
410+ fi
411+
412+ # Check smoke tests
413+ if [ "${{ env.smoke_tests_pr_exit_code }}" != "0" ] && [ "${{ env.smoke_tests_pr_exit_code }}" != "" ]; then
414+ echo " ❌ Smoke tests failed with exit code ${{ env.smoke_tests_pr_exit_code }}"
415+ PIPELINE_FAILED=true
416+ fi
417+
418+ # Check VSIX percentage change (if variables exist)
419+ if [ "${{ env.vsix_percentage_change }}" != "" ] && [ $(echo "${{ env.vsix_percentage_change }} > 5" | bc -l) -eq 1 ]; then
420+ echo " ❌ VSIX size increased by more than 5% (${{ env.vsix_percentage_change }}%)"
421+ PIPELINE_FAILED=true
422+ fi
423+
424+ # Check VSIX absolute size (if variables exist)
425+ if [ "${{ env.pr_vsix_size }}" != "" ] && [ "${{ env.pr_vsix_size }}" -gt 25000 ]; then
426+ echo " ❌ VSIX size is above 25MB (${{ env.pr_vsix_size }} KB)"
427+ PIPELINE_FAILED=true
428+ fi
429+
430+ # Check webview bundle percentage change (if variables exist)
431+ if [ "${{ env.webview_bundle_percentage_change }}" != "" ] && [ $(echo "${{ env.webview_bundle_percentage_change }} > 5" | bc -l) -eq 1 ]; then
432+ echo " ❌ Webview bundle size increased by more than 5% (${{ env.webview_bundle_percentage_change }}%)"
433+ PIPELINE_FAILED=true
434+ fi
435+
436+ # Check localization
437+ if [ "${{ env.loc_update_required }}" = "true" ]; then
438+ echo " ❌ Updates to localized strings are required"
439+ PIPELINE_FAILED=true
440+ fi
441+
442+ # Fail if any issues were found
443+ if [ "$PIPELINE_FAILED" = "true" ]; then
444+ echo ""
445+ echo "Pipeline failed due to the above issues."
446+ exit 1
447+ else
448+ echo " ✅ All checks passed!"
449+ fi
0 commit comments