Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mpw5 committed Oct 25, 2023
1 parent f0fa25f commit 46c0b06
Showing 1 changed file with 23 additions and 37 deletions.
60 changes: 23 additions & 37 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ orbs:
slack: circleci/slack@3.4.1

references:
_attach-tmp-workspace: &attach-tmp-workspace
_attach-coverage-workspace: &attach-coverage-workspace
attach_workspace:
at: ~/repo/tmp
at: ~/repo/coverage

_create-tmp-dir: &create-tmp-dir
run:
name: Create workspace temporary directories
command: |
mkdir -p tmp/
mkdir -p tmp/coverage/
# mkdir -p tmp/
mkdir -p coverage/
mkdir -p /tmp/test-results/rspec
mkdir -p /tmp/test-results/cucumber
_install-codeclimate: &install-codeclimate
run:
name: Install Code Climate test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > tmp/cc-test-reporter
chmod +x tmp/cc-test-reporter
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > coverage/cc-test-reporter
chmod +x coverage/cc-test-reporter
_persist-codeclimate: &persist-codeclimate
persist_to_workspace:
root: tmp
root: coverage
paths:
- cc-test-reporter

Expand Down Expand Up @@ -190,36 +190,22 @@ commands:
description: >
Run rspec tests and store results
steps:
- *attach-tmp-workspace
- *attach-coverage-workspace
- precompile-assets
- run:
name: Run rspec tests
command: |
tmp/cc-test-reporter before-build
coverage/cc-test-reporter before-build
circleci tests glob "spec/**/*_spec.rb" | circleci tests run --command="xargs bundle exec rspec --format progress --format RspecJunitFormatter -o /tmp/test-results/rspec/rspec.xml" --split-by=timings --timings-type=filename
# For a rerun that succeeds, restore the coverage files from the failed run
- restore_cache:
key: coverage-{{.Revision}}-{{.Environment.CIRCLE_NODE_INDEX}}

- run:
name: Code Climate test coverage
command: |
tmp/cc-test-reporter format-coverage -t simplecov -o "tmp/coverage/codeclimate.*.json"
# Save the coverage for rerunning failed tests. CircleCI will skip saving if this revision key has already been saved.
- save_cache:
key: coverage-{{.Revision}}-{{.Environment.CIRCLE_NODE_INDEX}}
paths:
- tmp/coverage/coverage.*.json
when: always
coverage/cc-test-reporter format-coverage -t simplecov -o "./coverage/coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
- persist_to_workspace:
root: tmp
root: coverage
paths:
- coverage/codeclimate.*.json
- codeclimate.*.json
- store_artifacts:
path: tmp/coverage
path: coverage
- store_test_results:
path: /tmp/test-results/rspec

Expand Down Expand Up @@ -429,13 +415,13 @@ jobs:
parallelism: 6
steps:
- checkout
# - run:
# name: Halt if no tests to run
# command: |
# mkdir -p ./tmp && \
# >./tmp/tests.txt && \
# circleci tests glob "spec/**/*_spec.rb" | circleci tests run --command ">./tmp/tests.txt xargs echo" --split-by=timings
# [ -s tmp/tests.txt ] || circleci-agent step halt
- run:
name: Halt if no tests to run
command: |
mkdir -p ./tmp && \
>./tmp/tests.txt && \
circleci tests glob "spec/**/*_spec.rb" | circleci tests run --command ">./tmp/tests.txt xargs echo" --split-by=timings
[ -s tmp/tests.txt ] || circleci-agent step halt
- build-base
- *wait-for-db
- *load-db
Expand Down Expand Up @@ -475,11 +461,11 @@ jobs:
executor: test-executor
resource_class: small
steps:
- *attach-tmp-workspace
- *attach-coverage-workspace
- run:
name: Upload coverage results to Code Climate
command: |
tmp/cc-test-reporter sum-coverage --output - --parts 6 tmp/coverage/codeclimate.*.json | tmp/cc-test-reporter upload-coverage --debug --input -
coverage/cc-test-reporter sum-coverage --output - --parts 6 coverage/codeclimate.*.json | coverage/cc-test-reporter upload-coverage --debug --input -
build-app-container:
executor: cloud-platform-executor
Expand Down

0 comments on commit 46c0b06

Please sign in to comment.