|
| 1 | +--- |
| 2 | + |
| 3 | +version: 2.1 |
| 4 | + |
| 5 | +defaults: &defaults |
| 6 | + working_directory: ~/ruby-rspec-mock |
| 7 | + docker: |
| 8 | + - image: cimg/ruby:<< parameters.ruby-version >> |
| 9 | + |
| 10 | +orbs: |
| 11 | + |
| 12 | + |
| 13 | +references: |
| 14 | + bundle_install: &bundle_install |
| 15 | + run: |
| 16 | + name: Installing gems |
| 17 | + command: | |
| 18 | + bundle config set --local path '~/vendor/bundle' |
| 19 | + bundle install |
| 20 | +
|
| 21 | + install_linters: &install_linters |
| 22 | + run: |
| 23 | + name: Installing bunch of linters |
| 24 | + command: | |
| 25 | + curl -1sLf 'https://dl.cloudsmith.io/public/evilmartians/lefthook/setup.deb.sh' | sudo -E bash |
| 26 | + sudo apt-get update -y |
| 27 | + sudo apt-get install -y lefthook shellcheck yamllint |
| 28 | + npm install --prefix='~/.local' --global --save-dev git+https://github.com/streetsidesoftware/cspell-cli markdownlint-cli |
| 29 | + cp .circleci/linter_configs/.fasterer.yml .fasterer.yml |
| 30 | + cp .circleci/linter_configs/.lefthook.yml lefthook.yml |
| 31 | +
|
| 32 | + install_codeclimate_reporter: &install_codeclimate_reporter |
| 33 | + run: |
| 34 | + name: Installing CodeClimate test reporter |
| 35 | + command: | |
| 36 | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter |
| 37 | + chmod +x ./cc-test-reporter |
| 38 | +
|
| 39 | + use_latest_bundler: &use_latest_bundler |
| 40 | + run: |
| 41 | + name: Using latest bundler |
| 42 | + command: gem install bundler |
| 43 | + |
| 44 | + use_latest_gemspec: &use_latest_gemspec |
| 45 | + run: |
| 46 | + name: Using latest gemspec |
| 47 | + command: cp .circleci/gemspecs/latest rspec-mock.gemspec |
| 48 | + |
| 49 | + use_compatible_gemspec: &use_compatible_gemspec |
| 50 | + run: |
| 51 | + name: Using compatible gemspec |
| 52 | + command: cp .circleci/gemspecs/compatible rspec-mock.gemspec |
| 53 | + |
| 54 | +jobs: |
| 55 | + linters-ruby: |
| 56 | + parameters: |
| 57 | + ruby-version: |
| 58 | + type: string |
| 59 | + |
| 60 | + <<: *defaults |
| 61 | + |
| 62 | + steps: |
| 63 | + - checkout |
| 64 | + |
| 65 | + - <<: *use_latest_bundler |
| 66 | + - <<: *use_latest_gemspec |
| 67 | + - <<: *bundle_install |
| 68 | + - <<: *install_linters |
| 69 | + |
| 70 | + - run: |
| 71 | + name: Running commit linters |
| 72 | + command: lefthook run commit-linters |
| 73 | + |
| 74 | + - run: |
| 75 | + name: Running code style linters |
| 76 | + command: lefthook run code-style-linters |
| 77 | + |
| 78 | + - run: |
| 79 | + name: Running code performance linters |
| 80 | + command: lefthook run code-performance-linters |
| 81 | + |
| 82 | + - run: |
| 83 | + name: Running code vulnerability linters |
| 84 | + command: lefthook run code-vulnerability-linters |
| 85 | + |
| 86 | + - run: |
| 87 | + name: Running code documentation linters |
| 88 | + command: lefthook run code-documentation-linters |
| 89 | + |
| 90 | + - run: |
| 91 | + name: Running release linters |
| 92 | + command: lefthook run release-linters |
| 93 | + |
| 94 | + tests-ruby: |
| 95 | + parameters: |
| 96 | + ruby-version: |
| 97 | + type: string |
| 98 | + |
| 99 | + <<: *defaults |
| 100 | + |
| 101 | + steps: |
| 102 | + - checkout |
| 103 | + |
| 104 | + - <<: *use_latest_bundler |
| 105 | + - <<: *use_latest_gemspec |
| 106 | + - <<: *bundle_install |
| 107 | + - <<: *install_codeclimate_reporter |
| 108 | + |
| 109 | + - run: |
| 110 | + name: Running RSpec |
| 111 | + command: | |
| 112 | + ./cc-test-reporter before-build |
| 113 | + bundle exec rspec |
| 114 | +
|
| 115 | + - run: |
| 116 | + name: Creating CodeClimate test coverage report |
| 117 | + command: | |
| 118 | + ./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json" |
| 119 | +
|
| 120 | + - store_artifacts: |
| 121 | + name: Saving Simplecov coverage artifacts |
| 122 | + path: ~/ruby-rspec-mock/coverage |
| 123 | + destination: coverage |
| 124 | + |
| 125 | + - deploy: |
| 126 | + name: Uploading CodeClimate test coverage report |
| 127 | + command: | |
| 128 | + ./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input - |
| 129 | +
|
| 130 | + compatibility-ruby: |
| 131 | + parameters: |
| 132 | + ruby-version: |
| 133 | + type: string |
| 134 | + |
| 135 | + <<: *defaults |
| 136 | + |
| 137 | + steps: |
| 138 | + - checkout |
| 139 | + |
| 140 | + - <<: *use_compatible_gemspec |
| 141 | + |
| 142 | + - ruby/install-deps: |
| 143 | + bundler-version: "2.3.26" |
| 144 | + with-cache: false |
| 145 | + path: '~/vendor/custom_bundle' |
| 146 | + |
| 147 | + - run: |
| 148 | + name: Running compatibility tests |
| 149 | + command: bundle exec rspec |
| 150 | + |
| 151 | + rubygems-deps-ruby: |
| 152 | + parameters: |
| 153 | + ruby-version: |
| 154 | + type: string |
| 155 | + |
| 156 | + <<: *defaults |
| 157 | + |
| 158 | + steps: |
| 159 | + - checkout |
| 160 | + |
| 161 | + - run: |
| 162 | + name: Building rubygems dependencies from default gemspec on minimal Ruby version |
| 163 | + command: bundle install |
| 164 | + |
| 165 | + releasing-gem-from-ruby: |
| 166 | + parameters: |
| 167 | + ruby-version: |
| 168 | + type: string |
| 169 | + |
| 170 | + <<: *defaults |
| 171 | + |
| 172 | + steps: |
| 173 | + - checkout |
| 174 | + |
| 175 | + - add_ssh_keys: |
| 176 | + fingerprints: |
| 177 | + - "SHA256:4Lk72FCartM+nybIinFywO/2wfXf3MqDcVKz0aGq/6I" |
| 178 | + |
| 179 | + - run: |
| 180 | + name: Publishing new release |
| 181 | + command: ./.circleci/scripts/release.sh |
| 182 | + |
| 183 | +workflows: |
| 184 | + build_test_deploy: |
| 185 | + jobs: |
| 186 | + - linters-ruby: |
| 187 | + matrix: |
| 188 | + parameters: |
| 189 | + ruby-version: ["3.3-node"] |
| 190 | + - tests-ruby: |
| 191 | + matrix: |
| 192 | + parameters: |
| 193 | + ruby-version: ["3.3"] |
| 194 | + - compatibility-ruby: |
| 195 | + matrix: |
| 196 | + parameters: |
| 197 | + ruby-version: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2"] |
| 198 | + - rubygems-deps-ruby: |
| 199 | + matrix: |
| 200 | + parameters: |
| 201 | + ruby-version: ["2.5"] |
| 202 | + - releasing-gem-from-ruby: |
| 203 | + requires: |
| 204 | + - linters-ruby |
| 205 | + - tests-ruby |
| 206 | + - compatibility-ruby |
| 207 | + - rubygems-deps-ruby |
| 208 | + matrix: |
| 209 | + parameters: |
| 210 | + ruby-version: ["2.5"] |
| 211 | + filters: |
| 212 | + branches: |
| 213 | + only: master |
0 commit comments