From 7a6ed8fbda276f7dc9e4d20a002d7988c70fa88d Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 12:32:57 -0800 Subject: [PATCH 01/13] Fix copy-paste error in workflow conditions --- .github/workflows/build-client.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index 8282d027..ed1f929a 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -4,11 +4,11 @@ on: push: branches: [main] paths: - - ".github/workflows/deploy_frontend_main.yml" + - ".github/workflows/build-client.yml" - "client/**/*" pull_request: paths: - - ".github/workflows/deploy_frontend_main.yml" + - ".github/workflows/build-client.yml" - "client/**/*" concurrency: From 1936df8dd33d1b968f0baaa31090d13ebf0621f3 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 12:28:22 -0800 Subject: [PATCH 02/13] Allow (but still check) bad translations in CI This allows the translations lint/test step to fail without failing the whole job and thus blocking the build. It logs some summary info for the workflow so it's possible to keep an eye on the status of translation issues. --- .github/workflows/build-client.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index ed1f929a..83fbbb75 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -118,7 +118,25 @@ jobs: run: npm ci - name: Spanish translation test - run: npm run test:intl-translations + # TODO: Make this error fatal when we have a strategy for translations! + # + # Right now, we are trying to quickly iterate on this community + # deployment of CEJST and don't have a clear process or strategy around + # how to handle translations. We're keeping this check in so we have an + # eye on what is or isn't translated, but missing or deprecated + # non-English strings should not stop the build and prevent us from + # merging or deploying changes. + continue-on-error: true + run: | + npm run test:intl-translations + if [ "${?}" -eq 0 ]; then + echo "✅ Translations: In good shape." >> $GITHUB_STEP_SUMMARY + else + echo "⚠️ Translations: English and Spanish are mismatched." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "See *tranlsations* job logs for details." >> $GITHUB_STEP_SUMMARY + fi + deploy: if: github.ref == 'refs/heads/main' From e54e9262253706d90e831a1c77dd7bc3cd4eec17 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 12:53:00 -0800 Subject: [PATCH 03/13] Oops, forgot `run` is operating with `-e` --- .github/workflows/build-client.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index 83fbbb75..eea429ba 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -117,7 +117,7 @@ jobs: - name: Install run: npm ci - - name: Spanish translation test + - name: Check Spanish translations # TODO: Make this error fatal when we have a strategy for translations! # # Right now, we are trying to quickly iterate on this community @@ -128,13 +128,13 @@ jobs: # merging or deploying changes. continue-on-error: true run: | - npm run test:intl-translations - if [ "${?}" -eq 0 ]; then - echo "✅ Translations: In good shape." >> $GITHUB_STEP_SUMMARY - else + npm run test:intl-translations || echo "Error: ${?}" > ./failed + if [ -f ./failed ]; then echo "⚠️ Translations: English and Spanish are mismatched." >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "See *tranlsations* job logs for details." >> $GITHUB_STEP_SUMMARY + else + echo "✅ Translations: In good shape." >> $GITHUB_STEP_SUMMARY fi From 220ed62458b5ab0f2d8994e3f1aa5c8c8a9431d5 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 13:16:41 -0800 Subject: [PATCH 04/13] Make the output a little nicer --- .github/workflows/build-client.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index eea429ba..f5c9c544 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -128,13 +128,24 @@ jobs: # merging or deploying changes. continue-on-error: true run: | - npm run test:intl-translations || echo "Error: ${?}" > ./failed + npm run test:intl-translations > output.txt \ + || echo "Error: ${?}" > ./failed + + # Make sure you can see the output in the log! + cat output.txt + if [ -f ./failed ]; then - echo "⚠️ Translations: English and Spanish are mismatched." >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "See *tranlsations* job logs for details." >> $GITHUB_STEP_SUMMARY + { + echo '⚠️ Translations: English and Spanish are mismatched.' + echo '
Details:' + echo '' + cat output.txt + echo '' + echo '
' + } >> "${GITHUB_STEP_SUMMARY}" + exit 1 else - echo "✅ Translations: In good shape." >> $GITHUB_STEP_SUMMARY + echo '✅ Translations: In good shape.' >> "${GITHUB_STEP_SUMMARY}" fi From 817d766f6b2c087d02272dc87152522fa0b04760 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 13:26:07 -0800 Subject: [PATCH 05/13] This output really needs to not be treated as markdown --- .github/workflows/build-client.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index f5c9c544..fc56894b 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -136,16 +136,18 @@ jobs: if [ -f ./failed ]; then { - echo '⚠️ Translations: English and Spanish are mismatched.' + echo '⚠️ English and Spanish translations are mismatched.' echo '
Details:' echo '' + echo '```' cat output.txt + echo '```' echo '' echo '
' } >> "${GITHUB_STEP_SUMMARY}" exit 1 else - echo '✅ Translations: In good shape.' >> "${GITHUB_STEP_SUMMARY}" + echo '✅ Translations in good shape.' >> "${GITHUB_STEP_SUMMARY}" fi From 640d23cd66eee69d01a70927caf2957d02591916 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 13:29:40 -0800 Subject: [PATCH 06/13] Test auto-update of strings file --- .github/workflows/build-client.yml | 26 ++++++++++++++++++++++++++ client/src/data/copy/common.tsx | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index fc56894b..e6dcd190 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -106,6 +106,8 @@ jobs: defaults: run: working-directory: client + permissions: + contents: write steps: - uses: actions/checkout@v4 @@ -117,6 +119,30 @@ jobs: - name: Install run: npm ci + - name: Extract English from source code + id: extract + if: github.event_name == 'pull_request' + run: | + ENGLISH_FILE='src/intl/en.json' + npm run intl:extract + if (git diff --exit-code "${ENGLISH_FILE}" > /dev/null); then + echo 'english-changed=' >> "${GITHUB_OUTPUT}" + else + echo 'english-changed=true' >> "${GITHUB_OUTPUT}" + git add "${ENGLISH_FILE}" + git commit -m 'Auto-update en.json from component source code' + git push + fi + + - if: github.event_name == 'pull_request' && steps.extract.outputs.english-changed == 'true' + uses: thollander/actions-comment-pull-request@v3 + with: + message: | + :wave: FYI, your PR has been automatically updated with changes to + `client/src/intl/en.json`, which contains all the translatable text + from the application (probably because you made changes to + the text of a component without updating this file). + - name: Check Spanish translations # TODO: Make this error fatal when we have a strategy for translations! # diff --git a/client/src/data/copy/common.tsx b/client/src/data/copy/common.tsx index 5633b92a..a139d181 100644 --- a/client/src/data/copy/common.tsx +++ b/client/src/data/copy/common.tsx @@ -56,7 +56,7 @@ export const UPDATE_BANNER_CONTENT_LARGE = This is an unofficial copy of the CEJST Tool. We are working on an overhaul, but in the meantime some links and text may incorrectly suggest that this site is affiliated with the US Government.`} + defaultMessage={`This is an unofficial copy of the CEJST Tool!!!! We are working on an overhaul, but in the meantime some links and text may incorrectly suggest that this site is affiliated with the US Government.`} description={`Alert body that appears at the top of pages.`} values={{ bold: boldFn, From 77de7c3cd94e21859aef7eb11ab7835a50c3a71e Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 13:34:26 -0800 Subject: [PATCH 07/13] Turns out we need git config --- .github/workflows/build-client.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index e6dcd190..b5ff7cba 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -123,6 +123,9 @@ jobs: id: extract if: github.event_name == 'pull_request' run: | + git config user.email "commit-bot@i-am-a-bot.com" + git config user.name "Translation Update Bot" + ENGLISH_FILE='src/intl/en.json' npm run intl:extract if (git diff --exit-code "${ENGLISH_FILE}" > /dev/null); then From d4404dfa4e0b9741ef2e47bafb6eb4a35357e2e2 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 13:43:32 -0800 Subject: [PATCH 08/13] Simplify by using a pre-built action --- .github/workflows/build-client.yml | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index b5ff7cba..7531b487 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -120,25 +120,18 @@ jobs: run: npm ci - name: Extract English from source code - id: extract if: github.event_name == 'pull_request' - run: | - git config user.email "commit-bot@i-am-a-bot.com" - git config user.name "Translation Update Bot" + run: npm run intl:extract - ENGLISH_FILE='src/intl/en.json' - npm run intl:extract - if (git diff --exit-code "${ENGLISH_FILE}" > /dev/null); then - echo 'english-changed=' >> "${GITHUB_OUTPUT}" - else - echo 'english-changed=true' >> "${GITHUB_OUTPUT}" - git add "${ENGLISH_FILE}" - git commit -m 'Auto-update en.json from component source code' - git push - fi + - uses: stefanzweifel/git-auto-commit-action@v5 + id: commit-strings + if: github.event_name == 'pull_request' + with: + commit_message: 'Auto-update en.json from component source code' + file_pattern: 'client/src/intl/en.json' - - if: github.event_name == 'pull_request' && steps.extract.outputs.english-changed == 'true' - uses: thollander/actions-comment-pull-request@v3 + - uses: thollander/actions-comment-pull-request@v3 + if: steps.commit-strings.outputs.changes_detected == 'true' with: message: | :wave: FYI, your PR has been automatically updated with changes to From 08fa8ea61bff3909d6edeaf5bdd0acc7870f4131 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 13:47:26 -0800 Subject: [PATCH 09/13] Set permissions for commenting --- .github/workflows/build-client.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index 7531b487..b34b1d02 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -107,7 +107,10 @@ jobs: run: working-directory: client permissions: + # To commit `en.json` changes back to the current PR. contents: write + # To comment on the PR that changes were made. + pull-requests: write steps: - uses: actions/checkout@v4 From 628e99511fda586d04a89549f553b8dd197f41a0 Mon Sep 17 00:00:00 2001 From: Mr0grog <74178+Mr0grog@users.noreply.github.com> Date: Fri, 21 Feb 2025 21:48:54 +0000 Subject: [PATCH 10/13] Auto-update en.json from component source code --- client/src/intl/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/intl/en.json b/client/src/intl/en.json index a923dc39..310aab43 100644 --- a/client/src/intl/en.json +++ b/client/src/intl/en.json @@ -88,7 +88,7 @@ "description": "Alert body that appears at the top of pages." }, "common.pages.alerts.banner.update.content.small": { - "defaultMessage": "This is an unofficial copy of the CEJST Tool. We are working on an overhaul, but in the meantime some links and text may incorrectly suggest that this site is affiliated with the US Government.", + "defaultMessage": "This is an unofficial copy of the CEJST Tool!!!! We are working on an overhaul, but in the meantime some links and text may incorrectly suggest that this site is affiliated with the US Government.", "description": "Alert body that appears at the top of pages." }, "common.pages.alerts.banner.update.heading.large": { From 669e86e2f00b2d053944c67263cb0d176b1ee1bc Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 13:56:40 -0800 Subject: [PATCH 11/13] Formatting cleanup --- .github/workflows/build-client.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-client.yml b/.github/workflows/build-client.yml index b34b1d02..7d114fbe 100644 --- a/.github/workflows/build-client.yml +++ b/.github/workflows/build-client.yml @@ -107,10 +107,8 @@ jobs: run: working-directory: client permissions: - # To commit `en.json` changes back to the current PR. - contents: write - # To comment on the PR that changes were made. - pull-requests: write + contents: write # For commiting changes back to the current PR. + pull-requests: write # For commenting on the PR. steps: - uses: actions/checkout@v4 @@ -136,7 +134,7 @@ jobs: - uses: thollander/actions-comment-pull-request@v3 if: steps.commit-strings.outputs.changes_detected == 'true' with: - message: | + message: > :wave: FYI, your PR has been automatically updated with changes to `client/src/intl/en.json`, which contains all the translatable text from the application (probably because you made changes to From 9ac33f85c06e1f4362f4d6082b466a602d0546c6 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 21 Feb 2025 14:00:16 -0800 Subject: [PATCH 12/13] Revert change to test i18n extraction --- client/src/data/copy/common.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/data/copy/common.tsx b/client/src/data/copy/common.tsx index a139d181..5633b92a 100644 --- a/client/src/data/copy/common.tsx +++ b/client/src/data/copy/common.tsx @@ -56,7 +56,7 @@ export const UPDATE_BANNER_CONTENT_LARGE = This is an unofficial copy of the CEJST Tool!!!! We are working on an overhaul, but in the meantime some links and text may incorrectly suggest that this site is affiliated with the US Government.`} + defaultMessage={`This is an unofficial copy of the CEJST Tool. We are working on an overhaul, but in the meantime some links and text may incorrectly suggest that this site is affiliated with the US Government.`} description={`Alert body that appears at the top of pages.`} values={{ bold: boldFn, From 786d672195d8a029ea5ec5c16eab0d8c1dd9cde9 Mon Sep 17 00:00:00 2001 From: Mr0grog <74178+Mr0grog@users.noreply.github.com> Date: Fri, 21 Feb 2025 22:02:09 +0000 Subject: [PATCH 13/13] Auto-update en.json from component source code --- client/src/intl/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/intl/en.json b/client/src/intl/en.json index 310aab43..a923dc39 100644 --- a/client/src/intl/en.json +++ b/client/src/intl/en.json @@ -88,7 +88,7 @@ "description": "Alert body that appears at the top of pages." }, "common.pages.alerts.banner.update.content.small": { - "defaultMessage": "This is an unofficial copy of the CEJST Tool!!!! We are working on an overhaul, but in the meantime some links and text may incorrectly suggest that this site is affiliated with the US Government.", + "defaultMessage": "This is an unofficial copy of the CEJST Tool. We are working on an overhaul, but in the meantime some links and text may incorrectly suggest that this site is affiliated with the US Government.", "description": "Alert body that appears at the top of pages." }, "common.pages.alerts.banner.update.heading.large": {