diff --git a/.circleci/config.yml b/.circleci/config.yml index 8ba5fc7..b47de21 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,15 +1,47 @@ -# Java Maven CircleCI 2.0 configuration file # -# Check https://circleci.com/docs/2.0/language-java/ for more details -# -version: 2 +version: 2.1 + +commands: + + abort_for_docs: + steps: + - run: + name: Avoid tests for docs + command: | + if [[ $CIRCLE_BRANCH == *docs ]]; then + echo "Identifies as documents PR, no testing required" + circleci step halt + fi + + abort_for_noci: + steps: + - run: + name: Ignore CI for specific branches + command: | + if [[ $CIRCLE_BRANCH == *noci ]]; then + echo "Identifies as actively ignoring CI, no testing required." + circleci step halt + fi + + + early_return_for_forked_pull_requests: + description: >- + If this build is from a fork, stop executing the current job and return success. + This is useful to avoid steps that will fail due to missing credentials. + steps: + - run: + name: Early return if this build is from a forked PR + command: | + if [[ -n "$CIRCLE_PR_NUMBER" ]]; then + echo "Nothing to do for forked PRs, so marking this step successful" + circleci step halt + fi + jobs: build: docker: - image: circleci/openjdk:8u171-jdk - - image: redislabs/rejson:edge - port: 6379:6379 working_directory: ~/repo @@ -18,7 +50,41 @@ jobs: MAVEN_OPTS: -Xmx3200m steps: + - abort_for_docs + - abort_for_noci + - checkout + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "pom.xml" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: mvn dependency:go-offline + + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "pom.xml" }} + + # run tests! + - run: mvn integration-test + - early_return_for_forked_pull_requests + - run: mvn cobertura:cobertura + - run: bash <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t ${CODECOV_TOKEN} + + build-and-publish: + docker: + - image: circleci/openjdk:8u171-jdk + + environment: + # Customize the JVM maximum heap limit + MAVEN_OPTS: -Xmx3200m + + steps: + - abort_for_docs + - abort_for_noci - checkout # Download and cache dependencies @@ -40,15 +106,38 @@ jobs: - run: mvn cobertura:cobertura - run: bash <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov) -t ${CODECOV_TOKEN} + - run: mvn -s .circleci.settings.xml -DskipTests -Dgpg.skip deploy + +on-master: &on-master + filters: + branches: + only: master + tags: + ignore: /.*/ + +not-on-master: ¬-on-master + filters: + branches: + ignore: master + tags: + ignore: /.*/ + + workflows: version: 2 commit: jobs: - build: + <<: *not-on-master context: - common + - build-and-publish: + <<: *on-master + context: + - common + nightly: triggers: - schedule: