Skip to content

Fixed actual plan not working for some queries #483

Fixed actual plan not working for some queries

Fixed actual plan not working for some queries #483

Workflow file for this run

name: PR Checks
# Trigger the workflow on PRs to the main branch.
# It performs the following checks:
# 1. Calculate the size difference between the webview bundles of the main branch and the PR branch.
# 2. Calculate the size difference between the VSIX files of the main branch and the PR branch.
# 3. Does a check if the PR has properly localized strings.
on:
pull_request:
branches:
- main
jobs:
pr-checks:
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
actions: read
issues: write
pull-requests: write
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
path: './main'
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: './pr'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install tools
run: |
echo "Installing Yarn"
npm install --global [email protected]
echo "Installing Gulp CLI"
npm install --global [email protected]
echo "Installing VSCE"
npm install --global [email protected]
echo "Installing gulp"
npm install --global [email protected]
- name: Install dependencies and build main extension
uses: ./pr/.github/actions/build-extension
with:
source-dir: './main'
- name: Install dependencies and build PR extension
uses: ./pr/.github/actions/build-extension
with:
source-dir: './pr'
- name: Code coverage
run: |
cd main
DISPLAY=:10 yarn test
xml_coverage_main=$(find ./coverage -name 'cobertura-coverage.xml')
line_rate_main=$(grep -m 1 -o 'line-rate="[0-9.]\+"' "$xml_coverage_main" | sed 's/line-rate="\([0-9.]*\)"/\1/')
line_rate_main=$(printf "%.2f" $(echo "$line_rate_main * 100" | bc))
echo "line_rate_main=$line_rate_main" >> $GITHUB_ENV
cd ../pr
DISPLAY=:10 yarn test
xml_coverage_pr=$(find ./coverage -name 'cobertura-coverage.xml')
line_rate_pr=$(grep -m 1 -o 'line-rate="[0-9.]\+"' "$xml_coverage_pr" | sed 's/line-rate="\([0-9.]*\)"/\1/')
line_rate_pr=$(printf "%.2f" $(echo "$line_rate_pr * 100" | bc))
echo "line_rate_pr=$line_rate_pr" >> $GITHUB_ENV
echo "line_rate_diff=$(echo "$line_rate_pr - $line_rate_main" | bc)" >> $GITHUB_ENV
coverage_text_color=$(if [ $line_rate_diff -gt 0 ]; then echo "red"; else echo "lightgreen"; fi)
echo "coverage_text_color=$coverage_text_color" >> $GITHUB_ENV
- name: Package both branches
run: |
cd main
yarn gulp package:online
cd ../pr
yarn gulp package:online
- name: Calculate webview bundle sizes
run: |
main_file=$(du -sk ./main/out/src/reactviews/assets | cut -f1)
pr_file=$(du -sk ./pr/out/src/reactviews/assets | cut -f1)
echo "Main branch bundle size: $main_file KB"
echo "PR branch bundle size: $pr_file KB"
size_diff=$((pr_file - main_file))
percentage_change=$((100 * size_diff / main_file))
echo "Size difference: $size_diff KB"
echo "Percentage change: $percentage_change%"
echo "main_webview_bundle_size=$main_file" >> $GITHUB_ENV
echo "pr_webview_bundle_size=$pr_file" >> $GITHUB_ENV
echo "webview_size_diff=$size_diff" >> $GITHUB_ENV
echo "webview_bundle_percentage_change=$percentage_change" >> $GITHUB_ENV
webview_text_color=$(if [ $percentage_change -gt 0 ]; then echo "red"; else echo "lightgreen"; fi)
echo "webview_text_color=$webview_text_color" >> $GITHUB_ENV
- name: Calculate vsix file sizes
run: |
main_vsix=$(find ./main -name "*.vsix")
pr_vsix=$(find ./pr -name "*.vsix")
main_size=$(stat -c%s "$main_vsix")
pr_size=$(stat -c%s "$pr_vsix")
main_size=$((main_size / 1024))
pr_size=$((pr_size / 1024))
size_diff=$((pr_size - main_size))
percentage_change=$((100 * size_diff / main_size))
echo "Main branch VSIX size: $main_size KB"
echo "PR branch VSIX size: $pr_size KB"
echo "Size difference: $size_diff bytes"
echo "Percentage change: $percentage_change%"
echo "main_vsix_size=$main_size" >> $GITHUB_ENV
echo "pr_vsix_size=$pr_size" >> $GITHUB_ENV
echo "vsix_size_diff=$size_diff" >> $GITHUB_ENV
echo "vsix_percentage_change=$percentage_change" >> $GITHUB_ENV
vsix_text_color=$(if [ $percentage_change -gt 0 ]; then echo "red"; else echo "lightgreen"; fi)
echo "vsix_text_color=$vsix_text_color" >> $GITHUB_ENV
- name: Write PR results to markdown
run: |
echo "### PR Changes" >> results.md
echo "| Category | Main Branch | PR Branch | Difference |" >> results.md
echo "|------------------------------|--------------------|-------------------|----------------------|" >> results.md
echo "| Code Coverage | ${{ env.line_rate_main }}% | ${{ env.line_rate_pr }}% | ${{ '\$\${\color{' }}${{ env.coverage_text_color }}} ${{ env.line_rate_diff }}\\\\% ${{ '}\$\$' }} |" >> results.md
echo "| VSIX Size | ${{ env.main_vsix_size }} KB | ${{ env.pr_vsix_size }} KB | ${{ '\$\${\color{' }}${{ env.vsix_text_color }}} ${{ env.vsix_size_diff }} KB \space (${{ env.vsix_percentage_change }}\\\\%) ${{ '}\$\$' }} |" >> results.md
echo "| Webview Bundle Size | ${{ env.main_webview_bundle_size }} KB | ${{ env.pr_webview_bundle_size }} KB | ${{ '\$\${\color{' }}${{ env.webview_text_color }}} ${{ env.webview_size_diff }} KB \space (${{ env.webview_bundle_percentage_change }}\\\\%) ${{ '}\$\$' }} |" >> results.md
- name: Find comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: |
### PR Changes
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body-path: ./results.md
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
- name: Fail if vsix size is increased by 5% or size is above 25mb
if: ${{ env.vsix_percentage_change > 5 || env.pr_vsix_size > 25000000 }}
run: exit 1
- name: Fail if bundle size is increased by 5%
if: ${{ env.webview_bundle_percentage_change > 5 }}
run: exit 1
- name: Generate xliff files in PR branch
run: |
cd pr
yarn localization
# Check if there are git changes in english xlf files
- name: Check for changes in english xlf files
run: |
cd pr
if git diff --quiet --exit-code ./localization/xliff/vscode-mssql.xlf; then
echo "Changes not found in english xlf files"
echo "loc_update_required=false" >> $GITHUB_ENV
else
echo "Changes found in english xlf files"
echo "loc_update_required=true" >> $GITHUB_ENV
fi
- name: Find comment
uses: peter-evans/find-comment@v3
id: loc-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: |
# Updates to localized strings required
- name: Create or update comment
if: ${{ env.loc_update_required == 'true' }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.loc-comment.outputs.comment-id }}
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
# Updates to localized strings required
Please update the localized strings in the PR with following steps:
1. Run `yarn localization` in the PR branch.
1. Based on the changes,
* If there are changes in localized strings in source code, make sure that `src/localization/xliff/vscode-mssql.xlf` and `src/l10n/bundle.l10n.json` files are updated.
* If there are changes in localized strings in `package.nls.json`, make sure that `src/localization/xliff/vscode-mssql.xlf` is updated.
edit-mode: replace
- name: Delete comment
if: ${{ env.loc_update_required == 'false' }} && steps.loc-comment.outputs.comment-id != ''
run: |
curl -X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ steps.loc-comment.outputs.comment-id }}
- name: Fail if there are changes required in english xlf files
if: ${{ env.loc_update_required == 'true' }}
run: exit 1