-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* test: PR Title linter * improvements * add linter to template * translations action * Improvments * Test change * Test change on tl * run grunt translations * ignore whitespace * Test change * revert * zh test change * revert zh change * run on pull request
- Loading branch information
1 parent
ebb5d01
commit 9fccb0e
Showing
3 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Validate PR Title | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize] | ||
|
||
jobs: | ||
check-title: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Validate PR title | ||
env: | ||
PR_TITLE: ${{ github.event.pull_request.title }} | ||
run: | | ||
# Define the regex for the required formats | ||
jira_regex="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test): DAH-[0-9]+ .+" | ||
urgent_regex="^urgent: \S+" | ||
if [[ "${PR_TITLE}" =~ $urgent_regex ]]; then | ||
echo "PR title contains 'urgent'. Skipping JIRA check but validating description." | ||
elif [[ "${PR_TITLE}" =~ $jira_regex ]]; then | ||
echo "PR title matches JIRA format." | ||
exit 0 | ||
else | ||
echo "Invalid PR title: '${PR_TITLE}'" | ||
echo "Please format your PR title as:" | ||
echo "'<label>: DAH-<issue number> <description>'" | ||
echo "or use 'urgent: <description>' for urgent PRs." | ||
echo "Available labels (case sensitive): build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test." | ||
echo "Examples:" | ||
echo "- 'feat: DAH-1234 Add new feature'" | ||
echo "- 'urgent: Hotfix for production'" | ||
exit 1 | ||
fi | ||
# Validate that a description exists and has no trailing whitespace | ||
description_regex="^.*: \S+" | ||
if [[ ! "${PR_TITLE}" =~ $description_regex ]]; then | ||
echo "Missing or invalid description in PR title: '${PR_TITLE}'" | ||
echo "Ensure your PR title includes a description after the colon with no extra whitespace." | ||
exit 1 | ||
fi | ||
echo "PR title is valid." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Check Translation Files Sorting | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "app/assets/json/translations/react/*.json" | ||
|
||
jobs: | ||
check-sorting: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Verify jq installation | ||
run: | | ||
if ! command -v jq &> /dev/null; then | ||
echo "jq could not be found, installing..." | ||
sudo apt-get update && sudo apt-get install -y jq | ||
else | ||
echo "jq is already installed: $(jq --version)" | ||
fi | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16" | ||
|
||
- name: Install dependencies | ||
run: npm install --global jsonlint-cli | ||
|
||
- name: Validate and check sorting of translation files | ||
run: | | ||
for file in app/assets/json/translations/react/*.json; do | ||
echo "Checking $file" | ||
jsonlint-cli $file | ||
jq -S '.' $file > sorted.json | ||
if ! diff -uw $file sorted.json > differences.txt; then | ||
echo "Sorting errors found in $file:" | ||
cat differences.txt | ||
rm sorted.json differences.txt | ||
exit 1 | ||
else | ||
echo "$file is properly sorted." | ||
rm sorted.json | ||
fi | ||
done |