Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18n check: fix empty comment #586

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Changes from 10 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1f11b0a
Add check for existence of issue.md. Split consistency check and issu…
spier Sep 1, 2023
3c3bc3d
Fix YAML syntax
spier Sep 1, 2023
d108c7b
Simulate creation of issue.md (only for Japanese)
spier Sep 1, 2023
da92975
Fix bash syntax
spier Sep 1, 2023
a2ba3f1
Fix file creation
spier Sep 1, 2023
2b432ec
Remove simulation code
spier Sep 1, 2023
743c384
Combine header for issue, with details about the i18n inconsistencies…
spier Sep 1, 2023
d3c7b15
Move issue_title variable to the correct step
spier Sep 1, 2023
7e8f7ca
Remove dummy step
spier Sep 1, 2023
be68946
No need to check for issue.md existence within the shell script, as w…
spier Sep 1, 2023
cc36c63
Change the search query that identifies the issue to write the data t…
spier Dec 1, 2023
4685428
Add some debug output
spier Dec 1, 2023
61c178f
More debug output. test on the other languages too
spier Dec 1, 2023
7f3ddaf
Add check for existence of issue.md. Split consistency check and issu…
spier Sep 1, 2023
0ea4033
Fix YAML syntax
spier Sep 1, 2023
72cf2df
Simulate creation of issue.md (only for Japanese)
spier Sep 1, 2023
a52f65d
Fix bash syntax
spier Sep 1, 2023
70717f3
Fix file creation
spier Sep 1, 2023
ce7c677
Remove simulation code
spier Sep 1, 2023
3f09f1e
Combine header for issue, with details about the i18n inconsistencies…
spier Sep 1, 2023
52167a1
Move issue_title variable to the correct step
spier Sep 1, 2023
8e0cd53
Remove dummy step
spier Sep 1, 2023
22bff62
No need to check for issue.md existence within the shell script, as w…
spier Sep 1, 2023
9524620
Change the search query that identifies the issue to write the data t…
spier Dec 1, 2023
746f346
Add some debug output
spier Dec 1, 2023
7a08700
More debug output. test on the other languages too
spier Dec 1, 2023
1ed04bf
Merge branch 'i18n-check-fix-empty-comment' of github.com:InnerSource…
spier Dec 1, 2023
02365ec
Make heredoc work
spier Dec 1, 2023
cd539b9
Add more log messages
spier Dec 1, 2023
53eae7a
Change quotes
spier Dec 1, 2023
f066ed8
Change more quores
spier Dec 1, 2023
41ed0bb
Repeat flags
spier Dec 1, 2023
247da31
Change sed command to create translation filenames. Add different log…
spier Dec 1, 2023
2d0d04d
Fix error log
spier Dec 1, 2023
23a7611
Ignore all templates for now
spier Dec 1, 2023
54b6c40
Limit search to a single result
spier Dec 2, 2023
f2cb5ae
Merge branch 'main' into i18n-check-fix-empty-comment
spier Dec 2, 2023
a4d45f5
Determine i18n_filename based on input file
spier Dec 2, 2023
4d24fff
Fix sed syntax
spier Dec 2, 2023
586b683
Also write output for files that are entirely untranslated. Write deb…
spier Dec 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions .github/workflows/i18n-consistency-checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,12 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Check consistency and create issue
- name: Check consistency
id: check-consistency
run: |
# Declare the flags
declare -A flags=( ["ja"]=":jp: Japanese" ["zh"]=":cn: Chinese")

issue_title="${flags['${{matrix.language}}']}: Content Consistency Issue"

# Heredoc for issue header
cat <<- EOM > issue.md
# i18n Contents Consistency Issue

The following files may have consistency issues with the English version. Please check and update the files.

This issue is created when any of the English patterns have changed (in folder `patterns/`). It compares the git update history to let you know what updates are overdue. The issue should be closed when the update is complete.
EOM

# Loop through all files in the English directory
for file in $(find patterns/{2-structured,3-validated} -name '*.md'); do
[[ $file =~ "3-validated" ]] && continue # if the file is under 3-validated, skip (one liner) - 2023/08/26
Expand Down Expand Up @@ -72,18 +61,41 @@ jobs:
EOM
fi
done

- name: Check issue.md existence
Copy link
Member Author

@spier spier Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if a GHA is needed to check for file existence.

Maybe this can be done directly with a GHA expression? Could not find the syntax for that though.
Also assumed that the file-existence-action probably was created for a reason (i.e. that it was not possible differently).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation was set up in the past when we needed to do conditional calls on the GitHub Actions side, but as far as the current implementation is concerned, it only does the work when True, so I don't think we need this.

Copy link
Member

@yuhattor yuhattor Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross post #636 here
I edited this. Please merge this 🙏
I think my change is what you meant here. I did not push directly because I am not a bit confident about it, but I used PR!

id: check_files
uses: andstor/file-existence-action@v2
with:
files: "issue.md"
- name: Create issue
if: steps.check_files.outputs.files_exists == 'true'
run: |
# Heredoc for issue header
cat <<- EOM > issue-full.md
Copy link
Member Author

@spier spier Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than introducing a new file, we could also try to prepend the header to the content of issue.md.

Logic in pseudo code:

issue.md = <header string> + issue.md (generated in previous steps)

Just not sure how to do this in a shell script :)

# i18n Contents Consistency Issue

The following files may have consistency issues with the English version. Please check and update the files.

This issue is created when any of the English patterns have changed (in folder `patterns/`). It compares the git update history to let you know what updates are overdue. The issue should be closed when the update is complete.
EOM

# combine header and rest of file created in previous steps
cat issue.md >> issue-full.md

# title of the GitHub issue to look for
issue_title="${flags['${{matrix.language}}']}: Content Consistency Issue"

# Get the existing issue ID
existing_issue_id=$(gh issue list -S "is:issue is:open $issue_title" | cut -f1)
echo "existing_issue_id: $existing_issue_id"

# Create a new issue or comment on the existing one
if [ -f issue.md ]; then
if expr "$existing_issue_id" : '^[0-9]*$' >/dev/null; then
gh issue comment "$existing_issue_id" -F issue.md -R $GITHUB_REPOSITORY
else
gh issue create -t "$issue_title" -F issue.md -R $GITHUB_REPOSITORY -l "Type - Translation"
fi
if expr "$existing_issue_id" : '^[0-9]*$' >/dev/null; then
gh issue comment "$existing_issue_id" -F issue-full.md -R $GITHUB_REPOSITORY
else
gh issue create -t "$issue_title" -F issue-full.md -R $GITHUB_REPOSITORY -l "Type - Translation"
fi

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}