Skip to content
Open
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
10 changes: 1 addition & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ repos:
- repo: 'https://github.com/jumanjihouse/pre-commit-hooks'
rev: 3.0.0
hooks:
- id: shellcheck
#- id: shellcheck
- id: script-must-have-extension
- id: git-dirty
- id: git-check
- repo: local # check java files format use a customized script
hooks:
- id: checkstyle
name: Checkstyle
entry: ./run-checkstyle.sh
language: script
files: \.java$
443 changes: 225 additions & 218 deletions conf/checkstyle/checkStyleAll.xml

Large diffs are not rendered by default.

64 changes: 0 additions & 64 deletions run-checkstyle.sh

This file was deleted.

46 changes: 46 additions & 0 deletions tools/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
allprojects {
group = 'io.github.tronprotocol'
version = '1.0'
}

subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'checkstyle'

checkstyle {
toolVersion = '8.41'
configFile = file("../../conf/checkstyle/checkStyleAll.xml")
}
checkstyleMain {
source 'src/main/java'
include '**/*.java'
exclude '**/generated/**'
classpath = files()
ignoreFailures = false
}
checkstyleTest {
source 'src/test/java'
include '**/*.java'
exclude '**/generated/**'
classpath = files()
ignoreFailures = false
}
}

//tasks.register('copyToParent', Copy) {
// into "$buildDir/libs"
// subprojects.each { subproject ->
// from(subproject.tasks.withType(Jar))
// }
//}

gradle.buildFinished {
if (project.hasProperty('cleanSubBuild')) {
subprojects.each { subproject ->
if (subproject.buildDir.exists()) {
subproject.buildDir.deleteDir()
}
}
}
}
12 changes: 6 additions & 6 deletions tools/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ If you encounter any problems during the build or testing process, please refer
- Docker
- JDK 8 (required by Gradle)

Follow the [getting-started](https://github.com/tronprotocol/tron-docker/blob/main/README.md#getting-started) guide to download Docker and the tron-docker repository. Then, navigate to the gradlew directory.
Follow the [getting-started](https://github.com/tronprotocol/tron-docker/blob/main/README.md#getting-started) guide to download Docker and the tron-docker repository. Then, navigate to the tools directory.
```
cd ./tools/gradlew
cd tools
```
Container testing uses the [Goss](https://github.com/goss-org/goss/blob/v0.4.9/README.md) tool, a YAML-based testing framework for validating service states. While no additional installation is required, it is beneficial to learn the basic usage of [Goss with container](https://goss.readthedocs.io/en/stable/container_image/) to help you better understand the following testing scripts.

## Build image

The command below will trigger the build process for java-tron image. Now we only support platform:`linux/amd64`.
```
./gradlew --no-daemon sourceDocker
./gradlew sourceDocker
```

The compilation process may take above 30 minutes, depending on your network conditions. Once it successfully completes, you will be able to see the generated image.
Expand All @@ -34,13 +34,13 @@ It will trigger the execution of `task sourceDocker` in [build.gradle](build.gra

For example:
```
./gradlew --no-daemon sourceDocker -PdockerOrgName=yourOrgName -PdockerArtifactName=test -Prelease.releaseVersion=V1.1.0
./gradlew sourceDocker -PdockerOrgName=yourOrgName -PdockerArtifactName=test -Prelease.releaseVersion=V1.1.0
```
## Test image

Test the java-tron image use the command below.
```
./gradlew --no-daemon testDocker
./gradlew testDocker
```
This will trigger the execution of `task testDocker` in [build.gradle](build.gradle). According to this logic, it will run the [test.sh](test.sh) script with the parameter of the Docker image name.

Expand All @@ -54,7 +54,7 @@ Currently, there are three test files:

Successful execution will output the following content:
```
$ ./gradlew --no-daemon testDocker
$ ./gradlew testDocker

To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.6.4/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build
Expand Down
30 changes: 13 additions & 17 deletions tools/docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
* This is a general purpose Gradle build.
* Learn more about Gradle by exploring our samples at https://docs.gradle.org/7.6.4/samples
*/
import java.text.SimpleDateFormat

//allprojects {
// version = "1.0.0"
// apply plugin: "java-library"
//}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

version = "1.0.0"
apply plugin: "java-library"
import java.text.SimpleDateFormat

def getGitCommitDetails(length = 8) {
try {
Expand Down Expand Up @@ -48,7 +44,7 @@ def getGitCommitDetails(length = 8) {

// http://label-schema.org/rc1/
// using the RFC3339 format "2016-04-12T23:20:50.52Z"
def buildTime() {
static def buildTime() {
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
Expand All @@ -62,22 +58,22 @@ def dockerOrgName = project.hasProperty('dockerOrgName') ? project.getProperty("
def dockerArtifactName = project.hasProperty("dockerArtifactName") ? project.getProperty("dockerArtifactName") : "java-tron"
def dockerImageName = "${dockerOrgName}/${dockerArtifactName}"

task sourceDocker {
tasks.register('sourceDocker') {
def dockerBuildDir = "${rootDir}/build/docker-tron/"

doLast {
copy {
from file("${rootDir}/../docker/Dockerfile")
from file("${rootDir}/docker/Dockerfile")
into(dockerBuildDir)
}
copy {
from file("${rootDir}/../docker/docker-entrypoint.sh")
from file("${rootDir}/docker/docker-entrypoint.sh")
into "${dockerBuildDir}"
}
exec {
def image = "${dockerImageName}:${dockerBuildVersion}"
def dockerPlatform = ""
if (project.hasProperty('docker-platform')){
if (project.hasProperty('docker-platform')) {
dockerPlatform = "--platform ${project.getProperty('docker-platform')}"
println "Building for platform ${project.getProperty('docker-platform')}"
} else {
Expand All @@ -93,9 +89,9 @@ task sourceDocker {
}


task testDocker {
tasks.register('testDocker') {
dependsOn sourceDocker
def dockerReportsDir = "${rootDir}/../docker/reports/"
def dockerReportsDir = "${rootDir}/docker/reports/"

doFirst {
new File(dockerReportsDir).mkdir()
Expand All @@ -104,15 +100,15 @@ task testDocker {
doLast {
exec {
def image = "${dockerImageName}:${dockerBuildVersion}"
workingDir "${rootDir}/../docker"
workingDir "${rootDir}/docker"
executable shell
args "-c", "./test.sh ${image}"
}
}
}

// Make sure to `docker login` first
task dockerUpload {
tasks.register('dockerUpload') {
dependsOn sourceDocker
def image = "${dockerImageName}:${dockerBuildVersion}"

Expand Down
Binary file not shown.
File renamed without changes.
Loading