Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
172 changes: 124 additions & 48 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: PR Check

on:
push:
Copy link
Contributor

@waynercheung waynercheung Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a bug: the pr-lint will crash on push events.

This workflow(line 15) triggers on both push (line 4-5) and pull_request (line 6-8).

The script accesses context.payload.pull_request.title, but on push events context.payload.pull_request is undefined, which throws a TypeError and marks this job as failure. Since downstream jobs (build, docker-build-*) depend on pr-lint via needs, they will all be skipped on push events.

Suggest splitting into two workflows:

  • pr-check.yml: triggered by pull_request only, includes pr-lint + checkstyle + builds.
  • post-merge.yml: triggered by push only, includes checkstyle + builds (no pr-lint).

This avoids the need for conditional if / always() workarounds on the needs chain.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you issue. I fix it as this: skip pr-lint when push; When the PR lint job succeeds or is skipped, the jobs depending on it can still run.

branches: [ 'master', 'release_**' ]
pull_request:
branches: [ 'develop', 'release_**' ]
types: [ opened, edited, synchronize, reopened ]
Expand All @@ -12,6 +14,7 @@ concurrency:
jobs:
pr-lint:
name: PR Lint
if: github.event_name == 'pull_request'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix works: adding if: github.event_name == 'pull_request' to pr-lint and !failure() to downstream jobs correctly handles the push/PR scenarios.

One remaining issue: !failure() also returns true when jobs are cancelled. If a user manually cancels the workflow, build jobs will still start. Suggest adding !cancelled():
if: github.event.action != 'edited' && !failure() && !cancelled()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users cannot manually cancel only the PR lint job. When the PR is updated, the running PR lint job will be canceled and all jobs will be triggered again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification. You're right that the concurrency group handles the PR update case well — the entire old run is cancelled and a new one starts fresh.

The !cancelled() is more about the manual "Cancel workflow run" case from the Actions UI. In that scenario, !failure() alone would briefly allow pending jobs to start before GitHub cancels them again. The practical impact is minimal — at most a few seconds of wasted runner time.

Adding !cancelled() is a best practice for correctness, but I agree it's not a blocking issue. Feel free to address it or leave as-is.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback. There is no strong need to add !cancelled() now. If a similar scenario occurs during execution, we can add it later.

runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (non-blocking): Currently checkstyle is only enabled for framework and plugins. It might be worth considering extending it to other modules (actuator, chainbase, common, etc.) in a follow-up PR to enforce consistent code style across the whole project.

Copy link

@liuyifei001 liuyifei001 Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. The current purpose is to migrate it from buildkite to workflow. Might extends it in another PR.

name: Checkstyle
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checkstyle is pure static analysis and architecture-independent.
Why do you use ARM instead of ubuntu-latest (x86)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a pinned version instead of a mutable version.


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
Expand All @@ -163,20 +130,31 @@ 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
matrix:
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:
Expand All @@ -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:
Copy link
Contributor

@waynercheung waynercheung Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can add timeout-minutes: 60 as the system-test job.
Besides, build and docker-build-debian11 can also add timeout-minutes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add it.

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
92 changes: 92 additions & 0 deletions .github/workflows/system-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: System Test

on:
push:
branches: [ 'master', 'release_**' ]
pull_request:
branches: [ 'develop', 'release_**' ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason the master branch isn’t considered?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, I will add it later.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using raw git clone + git checkout has a few drawbacks:

  1. The release_workflow branch is hardcoded — if it's deleted or renamed, CI breaks with no clear error.
  2. No GitHub token auth — will fail if the repo ever becomes private.
  3. No shallow clone optimization.

Suggest using actions/checkout instead:

  - name: Clone system-test
    uses: actions/checkout@v4
    with:
      repository: tronprotocol/system-test
      ref: release_workflow
      path: system-test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimize it.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the system-test repo updates the solc version or changes the directory structure, this cp will fail and may produce confusing downstream test errors.

Suggest adding an existence check:

  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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add it.

./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
1 change: 1 addition & 0 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ check.dependsOn 'lint'
checkstyle {
toolVersion = "${versions.checkstyle}"
configFile = file("config/checkstyle/checkStyleAll.xml")
maxWarnings = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plugins need this, too.

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
org.gradle.parallel=true
org.gradle.jvmargs=-Xms1g
org.gradle.caching=true
org.gradle.daemon=false
1 change: 1 addition & 0 deletions plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ check.dependsOn 'lint'
checkstyle {
toolVersion = "${versions.checkstyle}"
configFile = file("../framework/config/checkstyle/checkStyleAll.xml")
maxWarnings = 0
}

checkstyleMain {
Expand Down
Loading