Skip to content

Commit 381f1d6

Browse files
authored
Adding checks for loc strings (#18032)
1 parent 520ca4f commit 381f1d6

File tree

3 files changed

+60
-14
lines changed

3 files changed

+60
-14
lines changed

.github/workflows/file-size-check.yml .github/workflows/pr-checks.yml

+57-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
name: File Size Check
2-
# Trigger the workflow on PRs to the main branch. It builds the extension in prod mode and checks the size of the
3-
# vsix file and webview bundle file and compares it with the main branch. It fails if the size has increased by more than 10%.
4-
# For vsix, we also check if the size is greater than 25MB.
1+
name: PR Checks
2+
# Trigger the workflow on PRs to the main branch.
3+
# It performs the following checks:
4+
# 1. Calculate the size difference between the webview bundles of the main branch and the PR branch.
5+
# 2. Calculate the size difference between the VSIX files of the main branch and the PR branch.
6+
# 3. Does a check if the PR has properly localized strings.
57

68
on:
79
pull_request:
810
branches:
911
- main
1012

1113
jobs:
12-
size-check:
14+
pr-checks:
1315
runs-on: ubuntu-latest
1416
permissions:
1517
contents: read
@@ -119,21 +121,14 @@ jobs:
119121
body-includes: |
120122
### VSIX Size Comparison
121123
122-
- name: Create comment
124+
- name: Create or update comment
123125
if: steps.fc.outputs.comment-id == ''
124126
uses: peter-evans/create-or-update-comment@v4
125127
with:
126128
token: ${{ secrets.GITHUB_TOKEN }}
127129
issue-number: ${{ github.event.pull_request.number }}
128130
body-path: ./results.md
129-
130-
- name: Update comment
131-
if: steps.fc.outputs.comment-id != ''
132-
uses: peter-evans/create-or-update-comment@v4
133-
with:
134-
token: ${{ secrets.GITHUB_TOKEN }}
135131
comment-id: ${{ steps.fc.outputs.comment-id }}
136-
body-path: ./results.md
137132
edit-mode: replace
138133

139134
- name: Fail if vsix size is increased by 5% or size is above 25mb
@@ -144,7 +139,56 @@ jobs:
144139
if: ${{ env.webview_bundle_percentage_change > 5 }}
145140
run: exit 1
146141

142+
- name: Generate xliff files in PR branch
143+
run: |
144+
cd pr
145+
yarn localization
147146
147+
# Check if there are git changes in english xlf files
148+
- name: Check for changes in english xlf files
149+
run: |
150+
cd pr
151+
if git diff --quiet --exit-code ./localization/xliff/vscode-mssql.xlf; then
152+
echo "Changes not found in english xlf files"
153+
echo "loc_update_required=false" >> $GITHUB_ENV
154+
else
155+
echo "Changes found in english xlf files"
156+
echo "loc_update_required=true" >> $GITHUB_ENV
157+
fi
148158
159+
- name: Find comment
160+
uses: peter-evans/find-comment@v3
161+
id: loc-comment
162+
with:
163+
issue-number: ${{ github.event.pull_request.number }}
164+
comment-author: 'github-actions[bot]'
165+
body-includes: |
166+
# Updates to localized strings required
149167
168+
- name: Create or update comment
169+
if: ${{ env.loc_update_required == 'true' }}
170+
uses: peter-evans/create-or-update-comment@v4
171+
with:
172+
comment-id: ${{ steps.loc-comment.outputs.comment-id }}
173+
token: ${{ secrets.GITHUB_TOKEN }}
174+
issue-number: ${{ github.event.pull_request.number }}
175+
body: |
176+
# Updates to localized strings required
177+
Please update the localized strings in the PR with following steps:
178+
1. Run `yarn localization` in the PR branch.
179+
1. Based on the changes,
180+
* 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.
181+
* If there are changes in localized strings in `package.nls.json`, make sure that `src/localization/xliff/vscode-mssql.xlf` is updated.
182+
edit-mode: replace
150183

184+
- name: Delete comment
185+
if: ${{ env.loc_update_required == 'false' }} && steps.loc-comment.outputs.comment-id != ''
186+
run: |
187+
curl -X DELETE \
188+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
189+
-H "Accept: application/vnd.github.v3+json" \
190+
https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ steps.loc-comment.outputs.comment-id }}
191+
192+
- name: Fail if there are changes required in english xlf files
193+
if: ${{ env.loc_update_required == 'true' }}
194+
run: exit 1

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ coverage
1818
coverage-remapped
1919
test-reports
2020
.vscode-test
21-
localization/i18n/
2221
src/constants/localizedConstants.ts
2322
package.nls.*.json
2423
/test-results/

localization/xliff/vscode-mssql.xlf

+3
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,9 @@
10461046
<trans-unit id="mssql.queryHistoryLimit">
10471047
<source xml:lang="en">Number of query history entries to show in the Query History view</source>
10481048
</trans-unit>
1049+
<trans-unit id="mssql.openExecutionPlanFile">
1050+
<source xml:lang="en">Open Execution Plan File</source>
1051+
</trans-unit>
10491052
<trans-unit id="mssql.openQueryHistory">
10501053
<source xml:lang="en">Open Query</source>
10511054
</trans-unit>

0 commit comments

Comments
 (0)