| 
1 | 1 | version: 2.1  | 
2 | 2 | 
 
  | 
3 |  | -# Declare the orbs that we'll use in our config.  | 
4 |  | -# read more about orbs: https://circleci.com/docs/2.0/using-orbs/  | 
5 | 3 | orbs:  | 
6 | 4 |  | 
 | 5 | +  node: circleci/node@2  | 
 | 6 | +  cst: cst/framework@1  | 
7 | 7 | 
 
  | 
8 |  | -common_envs: &common_envs  | 
9 |  | -  environment:  | 
10 |  | -    APP_BUNDLER_VERSION: "2.3.8"  | 
11 |  | -    REDIS_URL: "redis://127.0.0.1"  | 
12 |  | - | 
13 |  | -executors:  | 
14 |  | -  gem:  | 
15 |  | -    parameters:  | 
16 |  | -      ruby-version:  | 
17 |  | -        default: "3.0.0"  | 
18 |  | -        type: string  | 
19 |  | -    docker:  | 
20 |  | -      - image: cimg/ruby:<< parameters.ruby-version >>  | 
21 |  | -      - image: circleci/redis:6.0  | 
22 |  | - | 
23 |  | -    <<: *common_envs  | 
24 |  | - | 
25 |  | -commands:  | 
26 |  | -  bundler-preamble:  | 
27 |  | -    description: "Install ruby and the Gemfile dependencies"  | 
28 |  | -    parameters:  | 
29 |  | -      ruby-version:  | 
30 |  | -        type: string  | 
31 |  | -        default: "3"  | 
32 |  | -        description: "Ruby Gem version"  | 
33 |  | -      key-name:  | 
34 |  | -        type: string  | 
35 |  | -        default: ""  | 
36 |  | -        description: Custom name to add to the cache key  | 
37 |  | -      cache-breaker:  | 
38 |  | -        type: string  | 
39 |  | -        default: "0"  | 
40 |  | -        description: "Cache breaker to force new cache instantiation"  | 
41 |  | -      keep-lock-file:  | 
42 |  | -        type: boolean  | 
43 |  | -        default: false  | 
44 |  | -        description: "Retain lock file when bit is set to true. Otherwise generate a new one specific for this build"  | 
45 |  | -    steps:  | 
46 |  | -      - checkout  | 
47 |  | -      - attach_workspace:  | 
48 |  | -          at: workspace  | 
49 |  | -      - unless:  | 
50 |  | -            condition:  | 
51 |  | -              equal: [ true, << parameters.keep-lock-file >> ]  | 
52 |  | -            steps:  | 
53 |  | -              - run:  | 
54 |  | -                  name: Remove Gemfile.lock  | 
55 |  | -                  command: rm Gemfile.lock  | 
56 |  | -      - restore_cache:  | 
57 |  | -          key: bundle-<< parameters.ruby-version >>-<< parameters.key-name >>-{{ checksum "Gemfile" }}-<< parameters.cache-breaker >>  | 
58 |  | -      - ruby/install-deps:  | 
59 |  | -          path: vendor/bundle  | 
60 |  | -          with-cache: false  | 
61 |  | -      - run:  | 
62 |  | -          name: "Update dependencies"  | 
63 |  | -          command: bundle update  | 
64 |  | -      - save_cache:  | 
65 |  | -          key: bundle-<< parameters.ruby-version >>-<< parameters.key-name >>-{{ checksum "Gemfile" }}-<< parameters.cache-breaker >>  | 
66 |  | -          paths:  | 
67 |  | -            - vendor/bundle  | 
68 |  | - | 
69 |  | -jobs:  | 
70 |  | -  publish-rubygems:  | 
71 |  | -    executor: gem  | 
72 |  | -    steps:  | 
73 |  | -      - bundler-preamble:  | 
74 |  | -          keep-lock-file: true  | 
75 |  | -      - run:  | 
76 |  | -          name: Publish to Ruby Gems  | 
77 |  | -          command: |  | 
78 |  | -            if [ -z "$GEM_HOST_API_KEY" ]; then  | 
79 |  | -              echo 'Environment variable GEM_HOST_API_KEY is not present'  | 
80 |  | -              exit 1  | 
81 |  | -            fi  | 
82 |  | -            gem_output=$(gem build json_schematize.gemspec)  | 
83 |  | -            VERSION=$(printf "$gem_output" | awk '/Version: / {print $2}')  | 
84 |  | -            FILE=$(printf "$gem_output" | awk '/File: / {print $2}')  | 
85 |  | -
  | 
86 |  | -            gem push ${FILE}  | 
87 |  | -
  | 
88 |  | -  publish-github:  | 
89 |  | -    executor: gem  | 
90 |  | -    steps:  | 
91 |  | -      - bundler-preamble:  | 
92 |  | -          keep-lock-file: true  | 
93 |  | -      - run:  | 
94 |  | -          name: 'Get Go'  | 
95 |  | -          command: |  | 
96 |  | -            sudo apt-get update -qq  | 
97 |  | -            sudo apt-get -y --no-install-recommends install golang-go  | 
98 |  | -      - run:  | 
99 |  | -          name: 'Set Git stats'  | 
100 |  | -          command: |  | 
101 |  | -            git config user.name $GITHUB_USER  | 
102 |  | -            git config user.email $GITHUB_EMAIL  | 
103 |  | -      - run:  | 
104 |  | -          name: Publish Git Release  | 
105 |  | -          command: |  | 
106 |  | -            curl -sSL https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz | tar xz -f - -C . ghr_v0.13.0_linux_amd64/ghr  | 
107 |  | -            mv ghr_v0.13.0_linux_amd64/ghr .  | 
108 |  | -            rm -rf ghr_v0.13.0_linux_amd64  | 
109 |  | -            chmod 0755 ghr  | 
110 |  | -
  | 
111 |  | -            if [ -z "$GITHUB_TOKEN" ]; then  | 
112 |  | -              echo 'Environment variable GITHUB_TOKEN is not present'  | 
113 |  | -              exit 1  | 
114 |  | -            fi  | 
115 |  | -
  | 
116 |  | -            if [ -z "$GITHUB_USER" ]; then  | 
117 |  | -              echo 'Environment variable GITHUB_USER is not present'  | 
118 |  | -              exit 1  | 
119 |  | -            fi  | 
120 |  | -
  | 
121 |  | -            if [ $(git tag -l "$VERSION") ]; then  | 
122 |  | -              echo "Pre existing version $VERSION, not tagging."  | 
123 |  | -              exit 0  | 
124 |  | -            fi  | 
125 |  | -
  | 
126 |  | -            gem_output=$(gem build json_schematize.gemspec)  | 
127 |  | -            VERSION=$(printf "$gem_output" | awk '/Version: / {print $2}')  | 
128 |  | -            FILE=$GEM_PATH$(printf "$gem_output" | awk '/File: / {print $2}')  | 
129 |  | -
  | 
130 |  | -            git tag -a $VERSION -m "$VERSION"  | 
131 |  | -
  | 
132 |  | -            SHA=$(git rev-parse HEAD)  | 
133 |  | -            ./ghr -soft -t ${GITHUB_TOKEN} -u ${GITHUB_USER} -r json_schematize -c ${SHA} ${VERSION} ${FILE}  | 
134 |  | -
  | 
135 |  | -  test:  | 
136 |  | -    parameters:  | 
137 |  | -      ruby-version:  | 
138 |  | -        default: "3.0.0"  | 
139 |  | -        type: string  | 
140 |  | -        description: "Ruby version to test against"  | 
141 |  | -    executor:  | 
142 |  | -      name: gem  | 
143 |  | -      ruby-version: << parameters.ruby-version >>  | 
144 |  | -    steps:  | 
145 |  | -      - bundler-preamble:  | 
146 |  | -          ruby-version: "<< parameters.ruby-version >>"  | 
147 |  | -      - run:  | 
148 |  | -          name: Setup Climate Control test-reporter  | 
149 |  | -          command: |  | 
150 |  | -            curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter  | 
151 |  | -            chmod +x ./cc-test-reporter  | 
152 |  | -      - run:  | 
153 |  | -          name: Waiting for Redis to be ready  | 
154 |  | -          command: |  | 
155 |  | -            for i in `seq 1 10`;  | 
156 |  | -            do  | 
157 |  | -              nc -z localhost 6379 && echo Success && exit 0  | 
158 |  | -              echo -n .  | 
159 |  | -              sleep 1  | 
160 |  | -            done  | 
161 |  | -            echo Failed waiting for Redis to be available && exit 1  | 
162 |  | -      - run:  | 
163 |  | -          name: Run and Report tests  | 
164 |  | -          command: |  | 
165 |  | -            ./cc-test-reporter before-build  | 
166 |  | -            SIMPLE_COV_RUN=true bundle exec rspec --format RspecJunitFormatter --out test-results/rspec/rspec.xml --format progress --color  | 
167 |  | -      - when:  | 
168 |  | -          condition:  | 
169 |  | -            equal:  | 
170 |  | -              [  | 
171 |  | -                required-test-ruby2.7.5,  | 
172 |  | -                required-test-ruby<< parameters.ruby-version >>,  | 
173 |  | -              ]  | 
174 |  | -          steps:  | 
175 |  | -            - run:  | 
176 |  | -                name: Report CodeClimate Coverage  | 
177 |  | -                command: ./cc-test-reporter after-build --coverage-input-type simplecov  | 
178 | 8 | workflows:  | 
179 | 9 |   version: 2  | 
180 | 10 |   yeet-le-jobs:  | 
181 | 11 |     jobs:  | 
182 |  | -      - test:  | 
 | 12 | +      - cst/enforce-gem-version-bump  | 
 | 13 | +      - cst/rspec-ruby:  | 
 | 14 | +          rspec-system-args: "SIMPLE_COV_RUN=true"  | 
 | 15 | +          cc-report-collect-ruby: "2.7.5"  | 
183 | 16 |           matrix:  | 
184 | 17 |             parameters:  | 
185 | 18 |               ruby-version: ["2.7.5" , "3.0.0", "3.0.3"]  | 
186 | 19 |             alias: required-matrix-tests  | 
187 |  | -          name: required-test-ruby<< matrix.ruby-version >>  | 
188 |  | -      - publish-github:  | 
189 |  | -          requires:  | 
190 |  | -            - required-matrix-tests  | 
191 |  | -          filters:  | 
192 |  | -            branches:  | 
193 |  | -              only:  | 
194 |  | -                - main  | 
195 |  | -      - publish-rubygems:  | 
 | 20 | +          name: test-ruby<< matrix.ruby-version >>  | 
 | 21 | +      - cst/publish-gem:  | 
 | 22 | +          publish-git: true  | 
 | 23 | +          publish-default-gem: true  | 
196 | 24 |           requires:  | 
197 | 25 |             - required-matrix-tests  | 
198 | 26 |           filters:  | 
199 | 27 |             branches:  | 
200 | 28 |               only:  | 
201 | 29 |                 - main  | 
202 |  | - | 
0 commit comments