Skip to content

Create .circleci/config.yml #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
102 changes: 11 additions & 91 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,13 @@
version: 2
jobs:
build:
environment:
# Configure the JVM and Gradle to avoid OOM errors
_JAVA_OPTIONS: "-Xmx3g"
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2"
docker:
- image: circleci/openjdk:11.0.3-jdk-stretch
steps:
- checkout
- restore_cache:
key: v1-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- restore_cache:
key: v1-gradle-cache-{{ checksum "build.gradle" }}
- run:
name: Install dependencies
command: ./gradlew build -x test
- save_cache:
paths:
- ~/.gradle/wrapper
key: v1-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- save_cache:
paths:
- ~/.gradle/caches
key: v1-gradle-cache-{{ checksum "build.gradle" }}
- persist_to_workspace:
root: .
paths:
- build
test:
# Remove if parallelism is not desired
parallelism: 2
environment:
# Configure the JVM and Gradle to avoid OOM errors
_JAVA_OPTIONS: "-Xmx3g"
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2"
docker:
- image: circleci/openjdk:11.0.3-jdk-stretch
- image: circleci/postgres:12-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_DB: circle_test
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Run tests in parallel
# Use "./gradlew test" instead if tests are not run in parallel
command: |
cd src/test/java
# Get list of classnames of tests that should run on this node
CLASSNAMES=$(circleci tests glob "**/*.java" \
| cut -c 1- | sed 's@/@.@g' \
| sed 's/.\{5\}$//' \
| circleci tests split --split-by=timings --timings-type=classname)
cd ../../..
# Format the arguments to "./gradlew test"
GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}')
echo "Prepared arguments for Gradle: $GRADLE_ARGS"
./gradlew test $GRADLE_ARGS
- run:
name: Generate code coverage report
command:
./gradlew jacocoTestReport
- store_test_results:
path: build/test-results/test
- store_artifacts:
path: build/test-results/test
when: always
- store_artifacts:
path: build/reports/jacoco/test/html
when: always
- run:
name: Assemble JAR
command: |
# Skip this for other nodes
if [ "$CIRCLE_NODE_INDEX" == 0 ]; then
./gradlew assemble
fi
# This will be empty for all nodes except the first one
- store_artifacts:
path: build/libs

# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
# Use a package of configuration called an orb.
orbs:
# Declare a dependency on the welcome-orb
welcome: circleci/[email protected]
# Orchestrate or schedule a set of jobs
workflows:
version: 2
workflow:
# Name the workflow "welcome"
welcome:
# Run the welcome/run job in its own container
jobs:
- build
- test:
requires:
- build
- welcome/run