diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 5a0f120e11..2fc16f3155 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,36 +29,18 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). - # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + uses: github/codeql-action/autobuild@v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@v4 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index f4593f64d4..82fa4bcd35 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -1,6 +1,8 @@ name: PR Check on: + push: + branches: [ 'master', 'release_**' ] pull_request: branches: [ 'develop', 'release_**' ] types: [ opened, edited, synchronize, reopened ] @@ -12,6 +14,7 @@ concurrency: jobs: pr-lint: name: PR Lint + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: @@ -93,53 +96,17 @@ jobs: core.info('PR lint passed.'); } - build: - name: Build (JDK ${{ matrix.java }} / ${{ matrix.arch }}) - needs: pr-lint - runs-on: ${{ matrix.runner }} - strategy: - fail-fast: false - matrix: - include: - - java: '8' - runner: ubuntu-latest - arch: x86_64 - - java: '17' - runner: ubuntu-24.04-arm - arch: aarch64 - - steps: - - uses: actions/checkout@v4 - - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - java-version: ${{ matrix.java }} - distribution: 'temurin' - - - name: Cache Gradle packages - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-${{ matrix.arch }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} - restore-keys: ${{ runner.os }}-${{ matrix.arch }}-gradle- - - - name: Build - run: ./gradlew clean build -x test - checkstyle: name: Checkstyle - runs-on: ubuntu-latest + runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: - java-version: '8' + java-version: '17' distribution: 'temurin' - name: Cache Gradle packages @@ -163,10 +130,11 @@ jobs: framework/build/reports/checkstyle/ plugins/build/reports/checkstyle/ - test: - name: Unit Tests (JDK ${{ matrix.java }} / ${{ matrix.arch }}) + build: + name: Build ${{ matrix.os-name }}(JDK ${{ matrix.java }} / ${{ matrix.arch }}) + if: github.event.action != 'edited' && !failure() + needs: [pr-lint, checkstyle] runs-on: ${{ matrix.runner }} - needs: build timeout-minutes: 60 strategy: fail-fast: false @@ -174,9 +142,19 @@ jobs: include: - java: '8' runner: ubuntu-latest + os-name: ubuntu arch: x86_64 - java: '17' runner: ubuntu-24.04-arm + os-name: ubuntu + arch: aarch64 + - java: '8' + runner: macos-26-intel + os-name: macos + arch: x86_64 + - java: '17' + runner: macos-26 + os-name: macos arch: aarch64 steps: @@ -197,13 +175,111 @@ jobs: key: ${{ runner.os }}-${{ matrix.arch }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} restore-keys: ${{ runner.os }}-${{ matrix.arch }}-gradle- - - name: Run tests - run: ./gradlew test + - name: Build + run: ./gradlew clean build --no-daemon - - name: Upload test reports - if: failure() + docker-build-rockylinux: + name: Build rockylinux (JDK 8 / x86_64) + if: github.event.action != 'edited' && !failure() + needs: [pr-lint, checkstyle] + runs-on: ubuntu-latest + timeout-minutes: 60 + + container: + image: rockylinux:8 + + env: + GRADLE_USER_HOME: /github/home/.gradle + LANG: en_US.UTF-8 + LC_ALL: en_US.UTF-8 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies (Rocky 8 + JDK8) + run: | + set -euxo pipefail + dnf -y install java-1.8.0-openjdk-devel git wget unzip which jq bc curl glibc-langpack-en + dnf -y groupinstall "Development Tools" + + - name: Check Java version + run: java -version + + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + /github/home/.gradle/caches + /github/home/.gradle/wrapper + key: ${{ runner.os }}-rockylinux-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-rockylinux-gradle- + + - name: Grant execute permission + run: chmod +x gradlew + + - name: Stop Gradle daemon + run: ./gradlew --stop || true + + - name: Build + run: ./gradlew clean build --no-daemon --no-build-cache + + - name: Generate JaCoCo report + run: ./gradlew jacocoTestReport --no-daemon --no-build-cache + + - name: Upload JaCoCo artifacts uses: actions/upload-artifact@v4 with: - name: test-reports-${{ matrix.arch }} + name: jacoco-rockylinux path: | - **/build/reports/tests/ + **/build/reports/jacoco/test/jacocoTestReport.xml + **/build/reports/** + **/build/test-results/** + if-no-files-found: error + + docker-build-debian11: + name: Build debian11 (JDK 8 / x86_64) + if: github.event.action != 'edited' && !failure() + needs: [pr-lint, checkstyle] + runs-on: ubuntu-latest + timeout-minutes: 60 + + container: + image: eclipse-temurin:8-jdk # base image is Debian 11 (Bullseye) + + defaults: + run: + shell: bash + + env: + GRADLE_USER_HOME: /github/home/.gradle + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies (Debian + build tools) + run: | + set -euxo pipefail + apt-get update + apt-get install -y git wget unzip build-essential curl jq + + - name: Check Java version + run: java -version + + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + /github/home/.gradle/caches + /github/home/.gradle/wrapper + key: ${{ runner.os }}-debian11-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-debian11-gradle- + + - name: Grant execute permission + run: chmod +x gradlew + + - name: Build + run: ./gradlew clean build --no-daemon --no-build-cache diff --git a/.github/workflows/system-test.yml b/.github/workflows/system-test.yml new file mode 100644 index 0000000000..4c234d4bf3 --- /dev/null +++ b/.github/workflows/system-test.yml @@ -0,0 +1,92 @@ +name: System Test + +on: + push: + branches: [ 'master', 'release_**' ] + pull_request: + branches: [ 'develop', 'release_**' ] + types: [ opened, 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 + timeout-minutes: 60 + + steps: + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + java-version: '8' + distribution: 'temurin' + + - name: Clone system-test + uses: actions/checkout@v4 + with: + repository: tronprotocol/system-test + ref: release_workflow + path: system-test + + - 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 for it to be ready..." + + MAX_ATTEMPTS=60 + INTERVAL=5 + for i in $(seq 1 $MAX_ATTEMPTS); do + if curl -s --fail "http://localhost:8090/wallet/getblockbynum?num=1" > /dev/null 2>&1; then + echo "FullNode is ready! (attempt $i)" + exit 0 + fi + echo "Waiting... (attempt $i/$MAX_ATTEMPTS)" + sleep $INTERVAL + done + + echo "FullNode failed to start within $((MAX_ATTEMPTS * INTERVAL)) seconds." + echo "=== FullNode log (last 50 lines) ===" + tail -50 fullnode.log || true + exit 1 + + - name: Run system tests + working-directory: system-test + run: | + if [ ! -f solcDIR/solc-linux-0.8.6 ]; then + echo "ERROR: solc binary not found at solcDIR/solc-linux-0.8.6" + exit 1 + fi + 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/framework/build.gradle b/framework/build.gradle index 59d070e066..16a0d481f5 100644 --- a/framework/build.gradle +++ b/framework/build.gradle @@ -69,6 +69,7 @@ check.dependsOn 'lint' checkstyle { toolVersion = "${versions.checkstyle}" configFile = file("config/checkstyle/checkStyleAll.xml") + maxWarnings = 0 } diff --git a/framework/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java index 38f1fe4f95..b99b7f54b7 100644 --- a/framework/src/main/java/org/tron/core/config/args/Args.java +++ b/framework/src/main/java/org/tron/core/config/args/Args.java @@ -344,7 +344,7 @@ private static String getCommitIdAbbrev() { InputStream in = Thread.currentThread() .getContextClassLoader().getResourceAsStream("git.properties"); properties.load(in); - } catch (IOException e) { + } catch (Exception e) { logger.warn("Load resource failed,git.properties {}", e.getMessage()); } return properties.getProperty("git.commit.id.abbrev"); diff --git a/gradle.properties b/gradle.properties index 031a8cddc8..09532810ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,4 @@ org.gradle.parallel=true org.gradle.jvmargs=-Xms1g +org.gradle.caching=true +org.gradle.daemon=false \ No newline at end of file diff --git a/plugins/build.gradle b/plugins/build.gradle index e03e9a7c49..85dcdd2342 100644 --- a/plugins/build.gradle +++ b/plugins/build.gradle @@ -58,6 +58,7 @@ check.dependsOn 'lint' checkstyle { toolVersion = "${versions.checkstyle}" configFile = file("../framework/config/checkstyle/checkStyleAll.xml") + maxWarnings = 0 } checkstyleMain {