Skip to content

Commit 521952b

Browse files
authored
Merge pull request #14153 from ethereum/crowdin-ci-debug
fix: crowdin-ci workflow
2 parents 5f6163a + 517bf11 commit 521952b

File tree

2 files changed

+18
-41
lines changed

2 files changed

+18
-41
lines changed

src/scripts/crowdin/translations/getTranslations.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import fs from "fs"
22

3-
import { checkMarkdown } from "../../markdownChecker"
43
import crowdin from "../api-client/crowdinClient"
54
import crowdinImport from "../import/main"
65
import type { BucketsList } from "../import/types"
76

8-
import { BUCKETS_PATH, DOT_CROWDIN, FILE_PATH, SUMMARY_PATH } from "./constants"
7+
import { BUCKETS_PATH, DOT_CROWDIN, FILE_PATH } from "./constants"
98
import getApprovedBuckets from "./getApprovedBuckets"
109
import { decompressFile, downloadFile } from "./utils"
1110

@@ -43,9 +42,6 @@ async function main() {
4342

4443
// Run Crowdin import script with buckets from Notion
4544
crowdinImport(buckets)
46-
47-
// Check markdown
48-
checkMarkdown(SUMMARY_PATH)
4945
} catch (error: unknown) {
5046
console.error((error as Error).message)
5147
}

src/scripts/crowdin/translations/utils.ts

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { execSync } from "child_process"
2-
import fs, { readFileSync, unlinkSync, writeFileSync } from "fs"
2+
import fs, { unlinkSync, writeFileSync } from "fs"
33
import path from "path"
44
import { Readable } from "stream"
55
import { finished } from "stream/promises"
@@ -9,9 +9,6 @@ import decompress from "decompress"
99

1010
import { INTL_JSON_DIR, TRANSLATIONS_DIR } from "../../../lib/constants"
1111

12-
import { SUMMARY_PATH } from "./constants"
13-
import { QASummary } from "./types"
14-
1512
export const downloadFile = async (url: string, writePath: string) => {
1613
// Get directory from writePath and ensure it exists
1714
const dir = writePath.substring(0, writePath.lastIndexOf("/"))
@@ -40,33 +37,6 @@ export const decompressFile = async (filePath: string, targetDir: string) => {
4037
console.log("✅ Decompression complete.")
4138
}
4239

43-
const getQAMessage = (locale: string) => {
44-
console.log("Checking summary path:", SUMMARY_PATH)
45-
if (!fs.existsSync(SUMMARY_PATH)) {
46-
console.error("Could not find summary path:", SUMMARY_PATH)
47-
throw new Error("No summary file found.")
48-
}
49-
50-
const summaryJson: QASummary = JSON.parse(readFileSync(SUMMARY_PATH, "utf-8"))
51-
const qaResults = summaryJson[locale]
52-
? summaryJson[locale].map((s) => "- " + s).join("\n")
53-
: null
54-
55-
if (!qaResults) return "No QA issues found"
56-
return `
57-
\`\`\`shell
58-
yarn markdown-checker
59-
\`\`\`
60-
61-
<details><summary>Unfold for ${summaryJson[locale].length} result(s)</summary>
62-
63-
${qaResults}
64-
</details>
65-
66-
@coderabbitai review
67-
`
68-
}
69-
7040
export const createLocaleTranslationPR = (
7141
locale: string,
7242
buckets: number[]
@@ -88,8 +58,22 @@ export const createLocaleTranslationPR = (
8858
}).trim()
8959
execSync(`git checkout -b ${branchName}`)
9060
execSync("git reset .")
91-
execSync(`git add ${TRANSLATIONS_DIR}/${locale}`)
92-
execSync(`git add ${INTL_JSON_DIR}/${locale}`)
61+
62+
// Check if the translations directory exists and contains files
63+
const translationsDir = path.join(TRANSLATIONS_DIR, locale)
64+
if (
65+
fs.existsSync(translationsDir) &&
66+
fs.readdirSync(translationsDir).length > 0
67+
) {
68+
execSync(`git add ${translationsDir}`)
69+
}
70+
71+
// Check if the intl JSON directory exists and contains files
72+
const intlJsonDir = path.join(INTL_JSON_DIR, locale)
73+
if (fs.existsSync(intlJsonDir) && fs.readdirSync(intlJsonDir).length > 0) {
74+
execSync(`git add ${intlJsonDir}`)
75+
}
76+
9377
execSync(`git commit -m "${message}"`)
9478
execSync(`git push origin ${branchName}`)
9579

@@ -101,9 +85,6 @@ export const createLocaleTranslationPR = (
10185
10286
## Content buckets imported
10387
${buckets.sort((a, b) => a - b).join(", ")}
104-
105-
## Markdown QA checker alerts
106-
${getQAMessage(locale)}
10788
`
10889

10990
const bodyWritePath = path.resolve(process.cwd(), "body.txt")

0 commit comments

Comments
 (0)