Skip to content

Commit

Permalink
test(strings): lint strings files
Browse files Browse the repository at this point in the history
Introduces an extra job to the linting stage, which uses swiftlint to
validate Localizable.strings files in the Strings package.
  • Loading branch information
flexjdev committed Nov 1, 2023
1 parent 20cefd6 commit e6f85cc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ linting:commit-quality:
linting:code-quality:
extends:
- .mr_job_template
- .ios_job_template
stage: linting
artifacts:
paths:
Expand All @@ -82,6 +81,18 @@ linting:code-quality:
codequality: codequality_report.json
script:
- scripts/code_quality.sh
tags:
- iOS_vpn
rules:

linting:strings-files:
extends:
- .mr_job_template
stage: linting
script:
- scripts/lint_translations.sh
tags:
- macOS_vpn
rules:

# Reenable when/if we have a license
Expand Down
1 change: 1 addition & 0 deletions Mintfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
realm/[email protected]
15 changes: 15 additions & 0 deletions libraries/Strings/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
only_rules:
- custom_rules

included: doesn't seem to work, so these input files have to be passed during the swiftlint invocation
- Sources/Strings/Resources/*/Localizable.strings

custom_rules:
malformed_entry:
regex: '^(?!($|(\/\* [^\n]* \*\/$)|(\"[^\n]*\" = \"[^\n]*\";$)|(\/\/)))'
message: "Each line should be either a comment or translation"
severity: error
leaky_block_comment:
regex: '^\/\*[^\n]*\*\/[^\n]'
message: "Block comments should not have any characters after the closing brace"
severity: error
2 changes: 2 additions & 0 deletions scripts/lint_translations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mint run swiftlint --config libraries/Strings/.swiftlint.yml libraries/Strings/Sources/Strings/Resources/*.lproj/Localizable.strings

0 comments on commit e6f85cc

Please sign in to comment.