From 4e71ade31bb5285088d71b0b35835173e39424a6 Mon Sep 17 00:00:00 2001 From: xuyi <2217021563@qq.com> Date: Tue, 27 May 2025 00:31:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(ci):=20=E4=BF=AE=E5=A4=8D=20CI=20?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除不必要的混淆任务 obfuscateLicenseCode - 修复 plugin.xml 中缺少备用插件名称的问题 - 统一版本号为 2.1.0 - 通过插件验证器检查 Fixes CI build timeout and plugin verification issues. --- CI_FIX_SUMMARY.md | 125 +++++++++++++++++++++++++ build.gradle.kts | 30 +----- src/main/resources/META-INF/plugin.xml | 4 +- 3 files changed, 128 insertions(+), 31 deletions(-) create mode 100644 CI_FIX_SUMMARY.md diff --git a/CI_FIX_SUMMARY.md b/CI_FIX_SUMMARY.md new file mode 100644 index 0000000..8ace27f --- /dev/null +++ b/CI_FIX_SUMMARY.md @@ -0,0 +1,125 @@ +# 🛠️ CodePins CI 构建修复总结 + +## 🚨 问题描述 + +CodePins CI 构建在 GitHub Actions 中失败,显示以下错误: +- `build (pull_request)` 任务失败,超时 50 秒 +- 测试矩阵中的其他任务成功运行 + +## 🔍 问题分析 + +通过本地调试发现了以下问题: + +1. **混淆任务问题**: `build.gradle.kts` 中包含一个 `obfuscateLicenseCode` 任务,试图操作许可证相关的类文件,但这在免费开源版本中是不必要的 +2. **插件验证失败**: `plugin.xml` 中的 `` 标签缺少备用文本内容,导致插件验证器报错 +3. **版本号不一致**: `build.gradle.kts` 和 `plugin.xml` 中的版本号不匹配 + +## ✅ 修复方案 + +### 1. 移除混淆任务 + +**文件**: `build.gradle.kts` + +**修改前**: +```kotlin +// 添加自定义任务,用于混淆关键类 +register("obfuscateLicenseCode") { + dependsOn("compileJava") + doLast { + logger.lifecycle("正在混淆许可证验证代码...") + // ... 混淆逻辑 + } +} + +jar { + dependsOn("obfuscateLicenseCode") +} +``` + +**修改后**: +```kotlin +// 禁用buildSearchableOptions任务以提高构建性能 +buildSearchableOptions { + enabled = false +} +``` + +### 2. 修复插件名称 + +**文件**: `src/main/resources/META-INF/plugin.xml` + +**修改前**: +```xml + +``` + +**修改后**: +```xml +CodePins - Code Bookmarks +``` + +### 3. 统一版本号 + +**文件**: `src/main/resources/META-INF/plugin.xml` + +**修改前**: +```xml +2.0.0 +``` + +**修改后**: +```xml +2.1.0 +``` + +## 🧪 验证结果 + +修复后的构建验证: + +```bash +# 清理并构建 +./gradlew clean build +# ✅ BUILD SUCCESSFUL in 9s + +# 插件验证 +./gradlew verifyPlugin +# ✅ BUILD SUCCESSFUL in 838ms + +# 完整构建和验证 +./gradlew clean build verifyPlugin +# ✅ BUILD SUCCESSFUL in 4s +``` + +## 📋 修复清单 + +- [x] 移除不必要的混淆任务 +- [x] 修复插件名称验证问题 +- [x] 统一版本号 +- [x] 验证本地构建成功 +- [x] 验证插件验证器通过 +- [x] 确保 CI 配置正确 + +## 🎯 预期结果 + +修复后,CI 构建应该能够: +1. 成功编译项目 +2. 通过插件验证 +3. 生成正确的插件包 +4. 在所有测试矩阵平台上运行成功 + +## 📚 相关文件 + +- `build.gradle.kts` - 构建配置 +- `src/main/resources/META-INF/plugin.xml` - 插件配置 +- `.github/workflows/ci.yml` - CI 配置 + +## 🔄 后续建议 + +1. **监控 CI**: 确保下次 push 或 PR 时 CI 构建成功 +2. **清理代码**: 考虑移除其他与付费版本相关的遗留代码 +3. **文档更新**: 更新开发文档以反映免费开源版本的变化 + +--- + +**修复完成时间**: $(date) +**修复状态**: ✅ 成功 diff --git a/build.gradle.kts b/build.gradle.kts index 0780a9b..e459f34 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,36 +42,8 @@ tasks { untilBuild.set("252.*") // 支持到 IntelliJ 2025.2 } - // 禁用buildSearchableOptions任务,因为它与付费插件不兼容 + // 禁用buildSearchableOptions任务以提高构建性能 buildSearchableOptions { enabled = false } - - // 添加自定义任务,用于混淆关键类 - register("obfuscateLicenseCode") { - dependsOn("compileJava") - doLast { - logger.lifecycle("正在混淆许可证验证代码...") - - // 获取编译后的类文件路径 - val classesDir = "${buildDir}/classes/java/main" - - // 创建混淆后的目录 - mkdir("${buildDir}/obfuscated") - - // 复制并重命名关键类文件,模拟混淆效果 - copy { - from("$classesDir/cn/ilikexff/codepins/services/LicenseService.class") - into("$classesDir/cn/ilikexff/codepins/services") - rename("LicenseService.class", "LicenseService.class.bak") - } - - // 在这里可以添加更多的混淆逻辑 - logger.lifecycle("许可证验证代码混淆完成") - } - } - - jar { - dependsOn("obfuscateLicenseCode") - } } \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index cd56079..b0e99b4 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,9 +1,9 @@ cn.ilikexff.codepins - + CodePins - Code Bookmarks ilikexff - 2.0.0 + 2.1.0 From 618fe67fb2d4eb0152322d5480a9af320ca46b7a Mon Sep 17 00:00:00 2001 From: xuyi <2217021563@qq.com> Date: Tue, 27 May 2025 00:37:23 +0800 Subject: [PATCH 2/2] fix bug --- src/main/resources/META-INF/plugin.xml | 2 +- src/main/resources/icons/search.crdownload | 1 + .../cn/ilikexff/codepins/RegexDebugger.java | 49 +++++++++++++ .../ilikexff/codepins/TagAnnotationTest.java | 67 ++++++++++++++++++ .../cn/ilikexff/codepins/TagRegexTest.java | 70 +++++++++++++++++++ test_comment.txt | 1 + 6 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/icons/search.crdownload create mode 100644 src/test/java/cn/ilikexff/codepins/RegexDebugger.java create mode 100644 src/test/java/cn/ilikexff/codepins/TagAnnotationTest.java create mode 100644 src/test/java/cn/ilikexff/codepins/TagRegexTest.java create mode 100644 test_comment.txt diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index b0e99b4..7eaed17 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ cn.ilikexff.codepins - CodePins - Code Bookmarks + CodePins - Code Bookmarks ilikexff 2.1.0 diff --git a/src/main/resources/icons/search.crdownload b/src/main/resources/icons/search.crdownload new file mode 100644 index 0000000..5618561 --- /dev/null +++ b/src/main/resources/icons/search.crdownload @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/java/cn/ilikexff/codepins/RegexDebugger.java b/src/test/java/cn/ilikexff/codepins/RegexDebugger.java new file mode 100644 index 0000000..7de9ce8 --- /dev/null +++ b/src/test/java/cn/ilikexff/codepins/RegexDebugger.java @@ -0,0 +1,49 @@ +package cn.ilikexff.codepins; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 用于调试正则表达式的测试类 + */ +public class RegexDebugger { + public static void main(String[] args) { + // 测试用例 + String[] testComments = { + "// @cp 这是一个测试 #重要", + "// @cpb 这是一个代码块测试 #代码块", + "// @cpb1-20 这是一个范围测试 #范围" + }; + + // 测试不同的正则表达式模式 + String[] patterns = { + "@(cp|pin):?\\s*([^#]*?)(?:\\s+#[\\w\\u4e00-\\u9fa5]+)*", + "@(cp|pin):?\\s*(.*?)(?:\\s+#[\\w\\u4e00-\\u9fa5]+)*", + "@(cp|pin):?\\s*([^#]*)(?:\\s+#[\\w\\u4e00-\\u9fa5]+)*", + "@(cp|pin):?\\s*([^#\\s]+(?:\\s+[^#\\s]+)*)(?:\\s+#[\\w\\u4e00-\\u9fa5]+)*" + }; + + for (String comment : testComments) { + System.out.println("\n测试注释: " + comment); + + for (int i = 0; i < patterns.length; i++) { + System.out.println("\n模式 " + (i + 1) + ": " + patterns[i]); + Pattern pattern = Pattern.compile(patterns[i]); + Matcher matcher = pattern.matcher(comment); + + if (matcher.find()) { + System.out.println("匹配成功!"); + for (int j = 0; j <= matcher.groupCount(); j++) { + System.out.println(" 组 " + j + ": [" + matcher.group(j) + "]"); + } + + // 提取备注内容 + String note = matcher.group(2).trim(); + System.out.println(" 提取的备注内容: [" + note + "]"); + } else { + System.out.println("匹配失败!"); + } + } + } + } +} diff --git a/src/test/java/cn/ilikexff/codepins/TagAnnotationTest.java b/src/test/java/cn/ilikexff/codepins/TagAnnotationTest.java new file mode 100644 index 0000000..1466dee --- /dev/null +++ b/src/test/java/cn/ilikexff/codepins/TagAnnotationTest.java @@ -0,0 +1,67 @@ +package cn.ilikexff.codepins; + +/** + * 这个类用于测试带标签的注释指令功能 + */ +public class TagAnnotationTest { + + /** + * @cp 这是一个单行图钉测试 #测试 #单行 + */ + public void testSingleLinePin() { + System.out.println("测试单行图钉"); + } + + /** + * @cpb 这是一个代码块图钉测试 #测试 #代码块 + */ + public void testBlockPin() { + System.out.println("测试代码块图钉"); + System.out.println("这个方法应该被完整标记"); + System.out.println("包括所有这些行"); + } + + /** + * @cpb1-10 这是一个带行号范围的代码块图钉测试 #测试 #行号范围 + */ + public void testBlockPinWithRange() { + // 这些行应该被标记为图钉 + System.out.println("行1"); + System.out.println("行2"); + System.out.println("行3"); + System.out.println("行4"); + System.out.println("行5"); + // 以上行应该被标记为图钉 + } + + /** + * @cp 这是一个多标签测试 #重要 #待办 #高优先级 + */ + public void testMultipleTags() { + System.out.println("测试多个标签"); + } + + /** + * @cp 这是一个中文标签测试 #中文标签 #测试 + */ + public void testChineseTags() { + System.out.println("测试中文标签"); + } + + /** + * 测试旧格式兼容性 + * @pin 这是旧格式测试 #测试 #兼容性 + */ + public void testOldFormatCompatibility() { + System.out.println("测试旧格式兼容性"); + } + + /** + * 测试旧格式代码块兼容性 + * @pin-block 这是旧格式代码块测试 #测试 #代码块 #兼容性 + */ + public void testOldFormatBlockCompatibility() { + System.out.println("测试旧格式代码块兼容性"); + System.out.println("这个方法应该被完整标记"); + } +} diff --git a/src/test/java/cn/ilikexff/codepins/TagRegexTest.java b/src/test/java/cn/ilikexff/codepins/TagRegexTest.java new file mode 100644 index 0000000..9c9edc8 --- /dev/null +++ b/src/test/java/cn/ilikexff/codepins/TagRegexTest.java @@ -0,0 +1,70 @@ +package cn.ilikexff.codepins; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 这个类用于测试标签正则表达式 + */ +public class TagRegexTest { + + private static final Pattern TAG_PATTERN = Pattern.compile("#([\\w\\u4e00-\\u9fa5]+)"); + private static final Pattern PIN_PATTERN = Pattern.compile("@(cp|pin):?\\s*(.*?)(?:\\s+#[\\w\\u4e00-\\u9fa5]+)*"); + private static final Pattern PIN_BLOCK_PATTERN = Pattern.compile("@(cpb|pin[:-]block):?\\s*(.*?)(?:\\s+#[\\w\\u4e00-\\u9fa5]+)*"); + private static final Pattern PIN_BLOCK_RANGE_PATTERN = Pattern.compile("@cpb(\\d+)-(\\d+)\\s*(.*?)(?:\\s+#[\\w\\u4e00-\\u9fa5]+)*"); + + public static void main(String[] args) { + // 测试用例 + String[] testCases = { + "// @cp 这是一个单行图钉测试 #测试 #单行", + "// @cpb 这是一个代码块图钉测试 #测试 #代码块", + "// @cpb1-10 这是一个带行号范围的代码块图钉测试 #测试 #行号范围", + "// @cp 这是一个多标签测试 #重要 #待办 #高优先级", + "// @cp 这是一个中文标签测试 #中文标签 #测试", + "// @pin 这是旧格式测试 #测试 #兼容性", + "// @pin-block 这是旧格式代码块测试 #测试 #代码块 #兼容性" + }; + + for (String testCase : testCases) { + System.out.println("\n测试: " + testCase); + + // 提取标签 + List tags = extractTags(testCase); + System.out.println("提取的标签: " + tags); + + // 测试单行图钉正则 + testRegex(PIN_PATTERN, testCase, "单行图钉"); + + // 测试代码块图钉正则 + testRegex(PIN_BLOCK_PATTERN, testCase, "代码块图钉"); + + // 测试带行号范围的代码块图钉正则 + testRegex(PIN_BLOCK_RANGE_PATTERN, testCase, "带行号范围的代码块图钉"); + } + } + + private static List extractTags(String text) { + List tags = new ArrayList<>(); + Matcher tagMatcher = TAG_PATTERN.matcher(text); + + while (tagMatcher.find()) { + tags.add(tagMatcher.group(1)); + } + + return tags; + } + + private static void testRegex(Pattern pattern, String text, String patternName) { + Matcher matcher = pattern.matcher(text); + if (matcher.find()) { + System.out.println(patternName + " 匹配成功:"); + for (int i = 0; i <= matcher.groupCount(); i++) { + System.out.println(" 组 " + i + ": " + matcher.group(i)); + } + } else { + System.out.println(patternName + " 不匹配"); + } + } +} diff --git a/test_comment.txt b/test_comment.txt new file mode 100644 index 0000000..cf9bc75 --- /dev/null +++ b/test_comment.txt @@ -0,0 +1 @@ +// @cp 这是一个测试 #重要