diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 5b76470a5f1..9d861078267 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -93,9 +93,43 @@ jobs: core.info('PR lint passed.'); } + checkstyle: + name: Checkstyle + runs-on: ubuntu-24.04-arm + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle- + + - name: Run Checkstyle + run: ./gradlew :framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain + + - name: Upload Checkstyle reports + if: failure() + uses: actions/upload-artifact@v4 + with: + name: checkstyle-reports + path: | + framework/build/reports/checkstyle/ + plugins/build/reports/checkstyle/ + build: name: Build ${{ matrix.os-name }}(JDK ${{ matrix.java }} / ${{ matrix.arch }}) - needs: pr-lint + needs: [pr-lint, checkstyle] runs-on: ${{ matrix.runner }} strategy: fail-fast: false @@ -141,7 +175,7 @@ jobs: docker-build-rockylinux: name: Build rockylinux (JDK 8 / x86_64) - needs: pr-lint + needs: [pr-lint, checkstyle] runs-on: ubuntu-latest container: @@ -207,7 +241,7 @@ jobs: docker-build-debian11: name: Build debian11 (JDK 8 / x86_64) - needs: pr-lint + needs: [pr-lint, checkstyle] runs-on: ubuntu-latest container: @@ -247,7 +281,7 @@ jobs: run: chmod +x gradlew - name: Build - run: ./gradlew clean build --no-daemon + run: ./gradlew clean build --no-daemon --no-build-cache coverage-gate: @@ -398,53 +432,18 @@ jobs: fi # Rule 3: patch coverage on changed files >= 80% - if [ "$impacted_files" -gt 0 ] && [ "$(echo "$patch_cov > 0" | bc)" -eq 1 ]; then - if [ "$(echo "$patch_cov < 80" | bc)" -eq 1 ]; then - echo "FAIL: Patch coverage is ${patch_cov}% (minimum 80%)." - echo "Please add tests for new/changed code." - exit 1 - fi - else - echo "No impacted files or no patch data; skipping patch coverage check." - fi + # if [ "$impacted_files" -gt 0 ] && [ "$(echo "$patch_cov > 0" | bc)" -eq 1 ]; then + # if [ "$(echo "$patch_cov < 80" | bc)" -eq 1 ]; then + # echo "FAIL: Patch coverage is ${patch_cov}% (minimum 80%)." + # echo "Please add tests for new/changed code." + # exit 1 + # fi + # else + # echo "No impacted files or no patch data; skipping patch coverage check." + # fi echo "" echo "All coverage gates passed!" echo " Current commit : ${self_cov}%" echo " Base branch : ${base_branch_cov}%" - echo " Patch coverage : ${patch_cov}%" - - checkstyle: - name: Checkstyle - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up JDK 8 - uses: actions/setup-java@v4 - with: - java-version: '8' - distribution: 'temurin' - - - name: Cache Gradle packages - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} - restore-keys: ${{ runner.os }}-gradle- - - - name: Run Checkstyle - run: ./gradlew :framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain - - - name: Upload Checkstyle reports - if: failure() - uses: actions/upload-artifact@v4 - with: - name: checkstyle-reports - path: | - framework/build/reports/checkstyle/ - plugins/build/reports/checkstyle/ - + echo " Patch coverage : ${patch_cov}%" \ No newline at end of file diff --git a/.github/workflows/sonar-check.yml b/.github/workflows/sonar-check.yml new file mode 100644 index 00000000000..ecd69f0ee7f --- /dev/null +++ b/.github/workflows/sonar-check.yml @@ -0,0 +1,72 @@ +name: SonarCloud Analysis + +on: + pull_request: + branches: [ 'develop_ci', 'release_**' ] + types: [ opened, edited, synchronize, reopened ] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +permissions: + contents: read # don't comment in PR after check + +jobs: + sonar-check: + name: SonarCloud Analysis + runs-on: ubuntu-24.04-arm + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Cache SonarCloud packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle- + + - name: Build and analyze + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + cat > /tmp/sonar-init.gradle << 'EOF' + initscript { + repositories { + maven { url 'https://plugins.gradle.org/m2/' } + } + dependencies { + classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882' + } + } + rootProject { + apply plugin: org.sonarqube.gradle.SonarQubePlugin + } + EOF + + ./gradlew clean classes testClasses sonar --info \ + --init-script /tmp/sonar-init.gradle \ + -PskipJdkCheck \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.organization=${{ github.repository_owner }} \ + -Dsonar.projectKey=${{ github.repository_owner }}_${{ github.event.repository.name }} \ + -Dsonar.qualitygate.wait=false \ + -Dsonar.pullrequest.github.summary_comment=false diff --git a/.github/workflows/system-test.yml b/.github/workflows/system-test.yml new file mode 100644 index 00000000000..a8fb2053b12 --- /dev/null +++ b/.github/workflows/system-test.yml @@ -0,0 +1,71 @@ +name: System Test + +on: + pull_request: + branches: [ 'develop_ci', 'release_**' ] + types: [ opened, edited, synchronize, reopened ] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + system-test: + name: System Test (JDK 8 / x86_64) + runs-on: ubuntu-latest + + steps: + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + java-version: '8' + distribution: 'temurin' + + - name: Clone system-test + run: | + git clone https://github.com/tronprotocol/system-test.git + cd system-test + git checkout release_workflow + + - name: Checkout java-tron + uses: actions/checkout@v4 + with: + path: java-tron + + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-system-test-${{ hashFiles('java-tron/**/*.gradle', 'java-tron/**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle-system-test- + + - name: Build java-tron + working-directory: java-tron + run: ./gradlew clean build -x test --no-daemon + + - name: Copy config and start FullNode + run: | + cp system-test/testcase/src/test/resources/config-system-test.conf java-tron/ + cd java-tron + nohup java -jar build/libs/FullNode.jar --witness -c config-system-test.conf > fullnode.log 2>&1 & + echo "FullNode started, waiting 30 seconds..." + sleep 30 + echo "=== FullNode log (last 30 lines) ===" + tail -30 fullnode.log || true + + - name: Run system tests + working-directory: system-test + run: | + cp solcDIR/solc-linux-0.8.6 solcDIR/solc + ./gradlew clean --no-daemon + ./gradlew --info stest --no-daemon + + - name: Upload FullNode log + if: always() + uses: actions/upload-artifact@v4 + with: + name: fullnode-log + path: java-tron/fullnode.log + if-no-files-found: warn diff --git a/build.gradle b/build.gradle index 12a0622db99..6f00196994d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ import org.gradle.nativeplatform.platform.internal.Architectures import org.gradle.internal.os.OperatingSystem + allprojects { version = "1.0.0" apply plugin: "java-library" @@ -40,7 +41,7 @@ ext.archInfo = [ VMOptions: isArm64 ? "${rootDir}/gradle/jdk17/java-tron.vmoptions" : "${rootDir}/gradle/java-tron.vmoptions" ] -if (!archInfo.java.is(archInfo.requires.JavaVersion)) { +if (!archInfo.java.is(archInfo.requires.JavaVersion) && !project.hasProperty('skipJdkCheck')) { throw new GradleException("Java ${archInfo.requires.JavaVersion} is required for ${archInfo.name}. Detected version ${archInfo.java}") } @@ -165,3 +166,26 @@ gradle.buildFinished { } } } + +// SonarQube configuration — only activates when the plugin is applied (via CI init script) +pluginManager.withPlugin('org.sonarqube') { + sonar { + properties { + property "sonar.sourceEncoding", "UTF-8" + } + } + + // Skip these projects + ["protocol", "platform", "example:actuator-example"].each { name -> + project(":${name}").sonar.skipProject = true + } + + // Only analyze main sources, exclude test sources + subprojects { + sonar { + properties { + property "sonar.tests", "" + } + } + } +} diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000000..69cb76019a4 --- /dev/null +++ b/codecov.yml @@ -0,0 +1 @@ +comment: false diff --git a/framework/build.gradle b/framework/build.gradle index 59d070e066d..42e905fda67 100644 --- a/framework/build.gradle +++ b/framework/build.gradle @@ -1,6 +1,6 @@ plugins { id "org.gradle.test-retry" version "1.5.9" - id "org.sonarqube" version "2.6" + id "com.gorylenko.gradle-git-properties" version "2.4.1" } diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 4d0bf1013d6..3dd82f7e74d 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -2262,6 +2262,19 @@ + + + + + + + + + + + + + @@ -2270,6 +2283,11 @@ + + + + + @@ -2283,6 +2301,14 @@ + + + + + + + + diff --git a/plugins/build.gradle b/plugins/build.gradle index e03e9a7c49a..6f18f2b9d41 100644 --- a/plugins/build.gradle +++ b/plugins/build.gradle @@ -1,5 +1,4 @@ plugins { - id "org.sonarqube" version "2.6" } apply plugin: 'application'