Skip to content

Commit

Permalink
adding in circle config (hyperledger#143)
Browse files Browse the repository at this point in the history
* adding in circle config to publish artifacts
* test results
* pr fixes

Signed-off-by: Joshua Fernandes <[email protected]>
  • Loading branch information
joshuafernandes authored Oct 31, 2019
1 parent a48a2de commit 2a72a3b
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 1 deletion.
224 changes: 224 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
---
version: 2.1
executors:
besu_executor_med:
docker:
- image: circleci/openjdk:11.0.4-jdk-stretch
resource_class: medium
working_directory: ~/project
environment:
JAVA_TOOL_OPTIONS: -Xmx2048m
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=2 -Xmx2048m

besu_executor_xl:
docker:
- image: circleci/openjdk:11.0.4-jdk-stretch
resource_class: xlarge
working_directory: ~/project
environment:
JAVA_TOOL_OPTIONS: -Xmx2048m
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=6 -Xmx2048m

commands:
prepare:
description: "Prepare"
steps:
- checkout
- run:
name: Install Packages - LibSodium
command: |
sudo apt-get update
sudo apt-get install -y libsodium18 libsodium-dev apt-transport-https
- restore_cache:
name: Restore cached gradle dependencies
keys:
- deps-{{ checksum "build.gradle" }}-{{ .Branch }}-{{ .Revision }}
- deps-{{ checksum "build.gradle" }}
- deps-

capture_test_results:
description: "Capture test results"
steps:
- run:
name: Gather test results
when: always
command: |
FILES=`find . -name test-results`
for FILE in $FILES
do
MODULE=`echo "$FILE" | sed -e 's@./\(.*\)/build/test-results@\1@'`
TARGET="build/test-results/$MODULE"
mkdir -p "$TARGET"
cp -rf ${FILE}/*/* "$TARGET"
done
- store_test_results:
path: build/test-results
jobs:
assemble:
executor: besu_executor_xl
steps:
- prepare
- run:
name: DCO check
command: |
./scripts/dco_check.sh
- run:
name: Assemble
command: |
./gradlew --no-daemon --parallel clean spotlessCheck compileJava compileTestJava assemble
- save_cache:
name: Caching gradle dependencies
key: deps-{{ checksum "build.gradle" }}-{{ .Branch }}-{{ .Revision }}
paths:
- .gradle
- ~/.gradle
- persist_to_workspace:
root: ~/project
paths:
- ./

unitTests:
executor: besu_executor_xl
steps:
- prepare
- attach_workspace:
at: ~/project
- run:
name: Build
no_output_timeout: 20m
command: |
./gradlew --no-daemon --parallel build
- capture_test_results

integrationTests:
executor: besu_executor_med
steps:
- prepare
- attach_workspace:
at: ~/project
- run:
name: IntegrationTests
command: |
./gradlew --no-daemon --parallel integrationTest
- run:
name: Javadoc
command: |
./gradlew --no-daemon --parallel javadoc
- run:
name: CompileJmh
command: |
./gradlew --no-daemon --parallel compileJmh
- capture_test_results

referenceTests:
executor: besu_executor_xl
steps:
- prepare
- attach_workspace:
at: ~/project
- run:
name: ReferenceTests
no_output_timeout: 20m
command: |
git submodule update --init --recursive
./gradlew --no-daemon --parallel referenceTest
- capture_test_results

acceptanceTests:
executor: besu_executor_xl
steps:
- prepare
- attach_workspace:
at: ~/project
- run:
name: AcceptanceTests
no_output_timeout: 40m
command: |
./gradlew --no-daemon --parallel acceptanceTest
- capture_test_results

buildDocker:
executor: besu_executor_med
steps:
- prepare
- attach_workspace:
at: ~/project
- setup_remote_docker
- run:
name: hadoLint
command: |
docker run --rm -i hadolint/hadolint < docker/Dockerfile
- run:
name: build image
command: |
./gradlew --no-daemon distDocker
publish:
executor: besu_executor_med
steps:
- prepare
- attach_workspace:
at: ~/project
- run:
name: Publish
command: |
./gradlew --no-daemon --parallel bintrayUpload
publishDocker:
executor: besu_executor_med
steps:
- prepare
- attach_workspace:
at: ~/project
- setup_remote_docker
- run:
name: Publish Docker
command: |
docker login --username "${DOCKER_USER}" --password "${DOCKER_PASSWORD}"
./gradlew --no-daemon --parallel "-Pbranch=${CIRCLE_BRANCH}" dockerUpload
workflows:
version: 2
default:
jobs:
- assemble
- unitTests:
requires:
- assemble
- referenceTests:
requires:
- assemble
- integrationTests:
requires:
- assemble
- acceptanceTests:
requires:
- assemble
- buildDocker:
requires:
- unitTests
- publish:
filters:
branches:
only:
- master
- /^release-.*/
requires:
- integrationTests
- unitTests
- acceptanceTests
- referenceTests
- buildDocker
- publishDocker:
filters:
branches:
only:
- master
- /^release-.*/
requires:
- integrationTests
- unitTests
- acceptanceTests
- referenceTests
- buildDocker

26 changes: 25 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ allprojects {
*/
test {
jvmArgs = [
'-Xmx4g',
'-Xmx2g',
'-XX:-UseGCOverheadLimit',
// Mockito and jackson-databind do some strange reflection during tests.
// This suppresses an illegal access warning.
Expand Down Expand Up @@ -548,6 +548,30 @@ task distDocker(type: Exec) {
args "-c", "docker build --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ."
}

task dockerUpload(type: Exec) {
dependsOn distDocker
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
def imageName = "hyperledger/besu"
def image = project.hasProperty('release.releaseVersion') ? "${imageName}:" + project.property('release.releaseVersion') : "${imageName}:${project.version}"
def cmd = "docker push '${image}'"
def additionalTags = []

if (project.hasProperty('branch') && project.property('branch') == 'master') {
additionalTags.add('develop')
}

if (! version ==~ /.*-SNAPSHOT/) {
additionalTags.add('latest')
additionalTags.add(version.split(/\./)[0..1].join('.'))
}

additionalTags.each { tag ->
cmd += " && docker tag '${image}' '${imageName}:${tag.trim()}' && docker push '${imageName}:${tag.trim()}'"
}
executable "sh"
args "-c", cmd
}

task checkSpdxHeader(type: CheckSpdxHeader) {
apply plugin: 'groovy'

Expand Down
18 changes: 18 additions & 0 deletions scripts/dco_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

status=0
while IFS= read -r -a line; do
my_array+=( "$line" )
done < <( git branch -r | grep -v origin/HEAD )
for branch in "${my_array[@]}"
do
branch=$(echo "$branch" | xargs)
echo "Checking commits in branch $branch for commits missing DCO..."
while read -r results; do
status=1
commit_hash="$(echo "$results" | cut -d' ' -f1)"
>&2 echo "$commit_hash is missing Signed-off-by line."
done < <(git log "$branch" --no-merges --pretty="%H %ae" --grep 'Signed-off-by' --invert-grep -- )
done

exit $status

0 comments on commit 2a72a3b

Please sign in to comment.