|
| 1 | +# CircleCI 2.0 configuration file |
1 | 2 | version: 2
|
2 |
| -jobs: |
3 |
| - build: |
| 3 | + |
| 4 | +# Re-usable blocks to reduce boilerplate in job definitions. |
| 5 | +references: |
| 6 | + host_environment_defaults: &host_environment_defaults |
| 7 | + # Customize the JVM maximum heap limit |
| 8 | + JAVA_OPTS: -Xmx3200m |
| 9 | + docker_environment_defaults: &docker_environment_defaults |
| 10 | + # Customize the JVM to read correct memory values |
| 11 | + JAVA_OPTS: '-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1' |
| 12 | + |
| 13 | + default_java_job: &default_java_job |
4 | 14 | docker:
|
5 |
| - - image: hseeberger/scala-sbt:8u151-2.12.5-1.1.2 |
| 15 | + - image: circleci/openjdk:8-jdk |
| 16 | + environment: |
| 17 | + <<: *docker_environment_defaults |
| 18 | + environment: |
| 19 | + <<: *host_environment_defaults |
6 | 20 | working_directory: ~/workdir
|
| 21 | + |
| 22 | + restore_source_code: &restore_source_code |
| 23 | + restore_cache: |
| 24 | + keys: |
| 25 | + - source-code-1.0.0-{{ .Branch }}-{{ .Revision }} |
| 26 | + - source-code-1.0.0-{{ .Branch }} |
| 27 | + - source-code-1.0.0 |
| 28 | + restore_dependencies: &restore_dependencies |
| 29 | + restore_cache: |
| 30 | + keys: |
| 31 | + - sbt-ivy2-dependencies-1.0.0-{{ checksum "/tmp/dependencies.cache.tmp" }} |
| 32 | + - sbt-ivy2-dependencies-1.0.0 |
| 33 | + restore_build: &restore_build |
| 34 | + restore_cache: |
| 35 | + keys: |
| 36 | + - sbt-build-1.0.0-{{ .Branch }}-{{ .Revision }} |
| 37 | + - sbt-build-1.0.0 |
| 38 | + |
| 39 | + setup_dependencies_key: &setup_dependencies_key |
| 40 | + run: |
| 41 | + name: Generate cache key |
| 42 | + command: | |
| 43 | + shasum build.sbt \ |
| 44 | + project/plugins.sbt \ |
| 45 | + project/build.properties > /tmp/dependencies.cache.tmp |
| 46 | +
|
| 47 | +jobs: |
| 48 | + checkout_code: |
| 49 | + <<: *default_java_job |
7 | 50 | steps:
|
| 51 | + - *restore_source_code |
8 | 52 | - checkout
|
9 |
| - - restore_cache: |
10 |
| - key: scala-library-dependencies-{{ checksum "build.sbt" }} |
11 |
| - - run: sbt compile |
12 |
| - - run: sbt test:compile |
13 | 53 | - save_cache:
|
14 |
| - key: scala-library-dependencies-{{ checksum "build.sbt" }} |
15 |
| - paths: [ "~/.m2", "~/.ivy2", "~/.cache/coursier" ] |
16 |
| - - run: ./scripts/test.sh |
| 54 | + key: source-code-1.0.0-{{ .Branch }}-{{ .Revision }} |
| 55 | + paths: |
| 56 | + - ~/workdir |
| 57 | + |
| 58 | + sbt_dependencies: |
| 59 | + <<: *default_java_job |
| 60 | + steps: |
| 61 | + - *restore_source_code |
| 62 | + - *setup_dependencies_key |
| 63 | + - *restore_dependencies |
| 64 | + - run: |
| 65 | + name: Resolve dependencies |
| 66 | + command: | |
| 67 | + sbt update |
| 68 | + - save_cache: |
| 69 | + paths: |
| 70 | + - ~/.ivy2 |
| 71 | + - ~/.sbt |
| 72 | + key: sbt-ivy2-dependencies-1.0.0-{{ checksum "/tmp/dependencies.cache.tmp" }} |
| 73 | + |
| 74 | + compile: |
| 75 | + <<: *default_java_job |
| 76 | + steps: |
| 77 | + - *restore_source_code |
| 78 | + - *setup_dependencies_key |
| 79 | + - *restore_dependencies |
| 80 | + - *restore_build |
| 81 | + - run: |
| 82 | + name: Compile |
| 83 | + command: ./scripts/compile.sh |
| 84 | + - save_cache: |
| 85 | + paths: |
| 86 | + - ~/workdir/target |
| 87 | + - ~/workdir/project/target |
| 88 | + key: sbt-build-1.0.0-{{ .Branch }}-{{ .Revision }} |
| 89 | + |
| 90 | + test: |
| 91 | + <<: *default_java_job |
| 92 | + steps: |
| 93 | + - *restore_source_code |
| 94 | + - *setup_dependencies_key |
| 95 | + - *restore_dependencies |
| 96 | + - *restore_build |
| 97 | + - run: |
| 98 | + name: Test |
| 99 | + command: ./scripts/test.sh |
| 100 | + - run: |
| 101 | + name: Store test reports |
| 102 | + working_directory: ~/ |
| 103 | + command: | |
| 104 | + mkdir -p ~/coverage-reports/scoverage |
| 105 | + cp -f ~/workdir/target/scala-2.11/coverage-report/cobertura.xml ~/coverage-reports/scoverage/results.xml |
| 106 | + - store_test_results: |
| 107 | + path: ~/coverage-reports |
| 108 | + - store_artifacts: |
| 109 | + path: ~/workdir/target/scala-2.11/coverage-report |
| 110 | + - store_artifacts: |
| 111 | + path: ~/workdir/target/scala-2.11/scoverage-report |
| 112 | + - store_artifacts: |
| 113 | + path: ~/workdir/target/scala-2.11/scoverage-data |
| 114 | + |
| 115 | + publish: |
| 116 | + <<: *default_java_job |
| 117 | + steps: |
| 118 | + - *restore_source_code |
| 119 | + - *setup_dependencies_key |
| 120 | + - *restore_dependencies |
| 121 | + - *restore_build |
| 122 | + - run: |
| 123 | + name: Install AWS CLI |
| 124 | + command: | |
| 125 | + sudo apt -y update |
| 126 | + sudo apt -y install python3-pip |
| 127 | + sudo python3 -m pip install awscli |
| 128 | + - run: |
| 129 | + name: Setup AWS Credentials |
| 130 | + command: ./scripts/setup-aws-credentials.sh |
| 131 | + - run: |
| 132 | + name: Retrieve GPG Keys |
| 133 | + command: | |
| 134 | + mkdir -p ~/.gnupg |
| 135 | + aws s3 sync --profile shared-services --include '*.gpg' s3://$AWS_CREDENTIALS_BUCKET/gnupg/ ~/.gnupg |
| 136 | + - run: |
| 137 | + name: Publish to Sonatype |
| 138 | + command: ./scripts/publish.sh 3.0.$CIRCLE_BUILD_NUM |
| 139 | + |
| 140 | +workflows: |
| 141 | + version: 2 |
| 142 | + test-and-publish: |
| 143 | + jobs: |
| 144 | + - checkout_code |
| 145 | + - sbt_dependencies: |
| 146 | + requires: |
| 147 | + - checkout_code |
| 148 | + - compile: |
| 149 | + requires: |
| 150 | + - checkout_code |
| 151 | + - sbt_dependencies |
| 152 | + - test: |
| 153 | + requires: |
| 154 | + - compile |
| 155 | + - publish: |
| 156 | + context: CodacyAWS |
| 157 | + requires: |
| 158 | + - test |
| 159 | + filters: |
| 160 | + branches: |
| 161 | + only: |
| 162 | + - master |
0 commit comments