From 83d39f70bc622431a1d920058d6b2f2efdb46f85 Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Tue, 25 Aug 2026 06:13:55 -0700 Subject: [PATCH 01/10] fix:sonar test --- .github/workflows/sonarcloud.yml | 71 ++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/sonarcloud.yml diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 00000000..9e240a02 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,71 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow helps you trigger a SonarCloud analysis of your code and populates +# GitHub Code Scanning alerts with the vulnerabilities found. +# Free for open source project. + +# 1. Login to SonarCloud.io using your GitHub account + +# 2. Import your project on SonarCloud +# * Add your GitHub organization first, then add your repository as a new project. +# * Please note that many languages are eligible for automatic analysis, +# which means that the analysis will start automatically without the need to set up GitHub Actions. +# * This behavior can be changed in Administration > Analysis Method. +# +# 3. Follow the SonarCloud in-product tutorial +# * a. Copy/paste the Project Key and the Organization Key into the args parameter below +# (You'll find this information in SonarCloud. Click on "Information" at the bottom left) +# +# * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN +# (On SonarCloud, click on your avatar on top-right > My account > Security +# or go directly to https://sonarcloud.io/account/security/) + +# Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/) +# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/help/sc/9) + +name: SonarCloud analysis + +on: + push: + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + workflow_dispatch: + +permissions: + pull-requests: read # allows SonarCloud to decorate PRs with analysis results + +jobs: + Analysis: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + with: + fetch-depth: 0 # 必须拉取完整历史,才能比较分支差异 + - name: Analyze with SonarCloud + + # You can pin the exact commit or the version. + # uses: SonarSource/sonarcloud-github-action@v2.2.0 + uses: SonarSource/sonarcloud-github-action@v3.0.0 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) + with: + # Additional arguments for the SonarScanner CLI + args: + # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) + # mandatory + -Dsonar.projectKey=msslulu_tiny-engine-backend-java + -Dsonar.organization=msslulu + # Comma-separated paths to directories containing main source files. + #-Dsonar.sources= # optional, default is project base directory + # Comma-separated paths to directories containing test source files. + #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ + # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing. + #-Dsonar.verbose= # optional, default is false + # When you need the analysis to take place in a directory other than the one from which it was launched, default is . + projectBaseDir: . From 89a9c5241be5754d36caa888071d8e8eb98e5e0a Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Tue, 25 Aug 2026 06:24:37 -0700 Subject: [PATCH 02/10] fix:sonar test --- .../it/common/utils/CalculatorTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 base/src/test/java/com/tinyengine/it/common/utils/CalculatorTest.java diff --git a/base/src/test/java/com/tinyengine/it/common/utils/CalculatorTest.java b/base/src/test/java/com/tinyengine/it/common/utils/CalculatorTest.java new file mode 100644 index 00000000..78f7ff90 --- /dev/null +++ b/base/src/test/java/com/tinyengine/it/common/utils/CalculatorTest.java @@ -0,0 +1,29 @@ +package com.tinyengine.it.common.utils; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class CalculatorTest { + @Test + void testAdd() { + Calculator calculator = new Calculator(); + int result = calculator.add(2, 3); + // 这是一个会通过的测试 + assertEquals(5, result, "2 + 3 应该等于 5"); + } + + @Test + void testAddWithNegative() { + Calculator calculator = new Calculator(); + int result = calculator.add(-1, 1); + // 这是一个会通过的测试 + assertEquals(0, result, "-1 + 1 应该等于 0"); + } +} +// 这是你要测试的简单业务类 +class Calculator { + public int add(int a, int b) { + return a + b; + } +} From 3e827a8d57135da1251a10a980dd97fb49baf410 Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Thu, 27 Aug 2026 18:48:57 -0700 Subject: [PATCH 03/10] fix:sonar test --- .../it/common/utils/CalculatorTest.java | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 base/src/test/java/com/tinyengine/it/common/utils/CalculatorTest.java diff --git a/base/src/test/java/com/tinyengine/it/common/utils/CalculatorTest.java b/base/src/test/java/com/tinyengine/it/common/utils/CalculatorTest.java deleted file mode 100644 index 78f7ff90..00000000 --- a/base/src/test/java/com/tinyengine/it/common/utils/CalculatorTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.tinyengine.it.common.utils; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class CalculatorTest { - @Test - void testAdd() { - Calculator calculator = new Calculator(); - int result = calculator.add(2, 3); - // 这是一个会通过的测试 - assertEquals(5, result, "2 + 3 应该等于 5"); - } - - @Test - void testAddWithNegative() { - Calculator calculator = new Calculator(); - int result = calculator.add(-1, 1); - // 这是一个会通过的测试 - assertEquals(0, result, "-1 + 1 应该等于 0"); - } -} -// 这是你要测试的简单业务类 -class Calculator { - public int add(int a, int b) { - return a + b; - } -} From f37e81838df8fc7f54fc7d9663c51faeda129c19 Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Thu, 27 Aug 2026 19:34:05 -0700 Subject: [PATCH 04/10] fix:sonar test --- .github/workflows/sonarcloud.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 9e240a02..3eeb32b0 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -41,7 +41,6 @@ permissions: jobs: Analysis: runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v6 From 443c0f3476390477fc537c23fa3785d9b8f6d6db Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Thu, 27 Aug 2026 19:52:30 -0700 Subject: [PATCH 05/10] fix:sonar test --- .github/workflows/sonarcloud.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 3eeb32b0..9e240a02 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -41,6 +41,7 @@ permissions: jobs: Analysis: runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v6 From 56ae62c43ee343438b2b203aa9e1b0652e34a9f6 Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Thu, 27 Aug 2026 19:56:58 -0700 Subject: [PATCH 06/10] fix:sonar test --- .github/workflows/sonarcloud.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 9e240a02..ed5a60f5 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -31,8 +31,6 @@ name: SonarCloud analysis on: push: branches: [ "develop" ] - pull_request: - branches: [ "develop" ] workflow_dispatch: permissions: From 5d1be44a5060fd21b55a5d66368294fb177767f9 Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Thu, 27 Aug 2026 20:26:33 -0700 Subject: [PATCH 07/10] fix:sonar test --- .github/workflows/sonarcloud.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index ed5a60f5..2b63071e 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -32,6 +32,19 @@ on: push: branches: [ "develop" ] workflow_dispatch: + inputs: + scan-type: + description: '扫描类型' + required: true + default: 'full' + type: choice + options: + - incremental + - full + branch: + description: '要扫描的分支' + required: true + default: 'develop' permissions: pull-requests: read # allows SonarCloud to decorate PRs with analysis results From 30c6e901df1c446495a83858c75e5d4cbfdabea8 Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Fri, 28 Aug 2026 00:02:04 -0700 Subject: [PATCH 08/10] fix:sonar test --- .github/workflows/sonarcloud.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 2b63071e..3d2425dd 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -31,6 +31,8 @@ name: SonarCloud analysis on: push: branches: [ "develop" ] + pull_request: + branches: [ "develop" ] workflow_dispatch: inputs: scan-type: From 0cd7a586b476bce00d3ba9899d40f28f496c0887 Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Fri, 28 Aug 2026 00:07:41 -0700 Subject: [PATCH 09/10] fix:sonar test --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 3d2425dd..0d90da2f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -64,7 +64,7 @@ jobs: # You can pin the exact commit or the version. # uses: SonarSource/sonarcloud-github-action@v2.2.0 - uses: SonarSource/sonarcloud-github-action@v3.0.0 + uses: SonarSource/sonarcloud-github-action@4006f663ecaf1f8093e8e4abb9227f6041f52216 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) with: From 50f8ca2c49c2f8832987e33d3dcad4a39f5eddc8 Mon Sep 17 00:00:00 2001 From: msslulu <1484036491@qq.com> Date: Fri, 28 Aug 2026 00:09:40 -0700 Subject: [PATCH 10/10] fix:sonar test --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 0d90da2f..3d2425dd 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -64,7 +64,7 @@ jobs: # You can pin the exact commit or the version. # uses: SonarSource/sonarcloud-github-action@v2.2.0 - uses: SonarSource/sonarcloud-github-action@4006f663ecaf1f8093e8e4abb9227f6041f52216 + uses: SonarSource/sonarcloud-github-action@v3.0.0 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) with: