Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
crystal: manastech/crystal@1.0.0
Use crystal
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Example for testing using latest Crystal release.
1
2
3
4
5
6
7
8
workflows:
version: 2
build:
jobs:
- crystal/test
orbs:
crystal: manastech/crystal@x.y
version: 2.1
Example for testing using nightly Crystal release.
1
2
3
4
5
6
7
8
9
10
11
12
workflows:
version: 2
build:
jobs:
- crystal/test:
name: test-on-nightly
executor:
name: crystal/default
tag: nightly
orbs:
crystal: manastech/crystal@x.y
version: 2.1
Adding binary dependencies via apt.
1
2
3
4
5
6
7
8
9
10
workflows:
version: 2
build:
jobs:
- crystal/test:
pre-steps:
- run: apt-get update && apt-get install -y libsqlite3-dev
orbs:
crystal: manastech/crystal@x.y
version: 2.1
Use docker to add external services. Define a custom executor but keep using the crystal/test job.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
executors:
crystal_mysql:
docker:
- image: crystallang/crystal:latest
environment:
DATABASE_URL: mysql://root@localhost/db
- image: mysql:5.7
environment:
MYSQL_DATABASE: db
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
workflows:
version: 2
build:
jobs:
- crystal/test:
executor: crystal_mysql
pre-steps:
- run:
name: Waiting for service to start (check dockerize)
command: sleep 5
orbs:
crystal: manastech/crystal@x.y
version: 2.1
Download dependencies, run specs and check format with specified Crystal version.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
spec-options | Additional options to crystal spec like --tag fast | No | '' | string |
junit | Store crystal spec output in JUnit format and use it as CircleCI test results | No | true | boolean |
junit-output | JUnit output location | No | ~/test-results/crystal-spec | string |
format-check | Check the format of the source code | No | true | boolean |
executor | The executor to use for this job | No | default | executor |
cache-key | File to use as a shards cache checksum | No | shard.yml | string |
cache-version | Cache version; increment this for a fresh cache | No | v1 | string |
include-branch-in-cache-key | If true, includes current branch name in cache key | No | true | boolean |
Run a set of steps with shards cache enabled.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
cache-key | File to use as a shards cache checksum | No | shard.yml | string |
cache-version | Cache version; increment this for a fresh cache | No | v1 | string |
include-branch-in-cache-key | If true, includes current branch name in cache key | No | true | boolean |
dir | Path to your shards cache | No | ~/.cache/shards | string |
steps | Input any custom steps to run with your shards cache | Yes | - | steps |
Run crystal spec with given spec options.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
spec-options | Additional options to crystal spec like --tag fast | No | '' | string |
junit | Store crystal spec output in JUnit format and use it as CircleCI test results | No | true | boolean |
junit-output | JUnit output location | No | ~/test-results/crystal-spec | string |
Use the official Crystal Docker image as executor.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
tag | crystallang/crystal Docker image tag. Valid values: latest, nightly or M.m.p.
See https://hub.docker.com/r/crystallang/crystal/
| No | latest | string |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
Common CircleCI tasks for the Crystal programming language.
display:
home_url: https://crystal-lang.org/
source_url: https://github.com/manastech/crystal-circleci-orb
executors:
default:
description: |
Use the official Crystal Docker image as executor.
parameters:
tag:
description: |
crystallang/crystal Docker image tag. Valid values: latest, nightly or M.m.p.
See https://hub.docker.com/r/crystallang/crystal/
type: string
default: latest
docker:
- image: crystallang/crystal:<< parameters.tag >>
commands:
with-shards-cache:
description: |
Run a set of steps with shards cache enabled.
parameters:
cache-key:
description: File to use as a shards cache checksum
default: shard.yml
type: string
cache-version:
description: Cache version; increment this for a fresh cache
default: v1
type: string
include-branch-in-cache-key:
description: If true, includes current branch name in cache key
default: true
type: boolean
dir:
description: Path to your shards cache
default: ~/.cache/shards
type: string
steps:
description: Input any custom steps to run with your shards cache
type: steps
steps:
- restore_cache:
keys:
- shards-cache-<<parameters.cache-version>>-<<#parameters.include-branch-in-cache-key>>{{ .Branch }}-<</parameters.include-branch-in-cache-key>>{{ checksum "<<parameters.cache-key>>" }}
- shards-cache-<<parameters.cache-version>>-<<#parameters.include-branch-in-cache-key>>{{ .Branch }}-<</parameters.include-branch-in-cache-key>>
- shards-cache-<<parameters.cache-version>>
- steps: <<parameters.steps>>
- save_cache:
key: shards-cache-<<parameters.cache-version>>-<<#parameters.include-branch-in-cache-key>>{{ .Branch }}-<</parameters.include-branch-in-cache-key>>{{ checksum "<<parameters.cache-key>>" }}
paths:
- <<parameters.dir>>
shards-install:
description: |
Install Shards dependencies.
steps:
- run:
name: Install dependencies
command: shards install
spec:
description: |
Run crystal spec with given spec options.
parameters:
spec-options:
description: Additional options to crystal spec like --tag fast
type: string
default: ""
junit:
description: Store crystal spec output in JUnit format and use it as CircleCI test results
type: boolean
default: true
junit-output:
description: JUnit output location
type: string
default: ~/test-results/crystal-spec
steps:
- run:
name: Run specs
command: crystal spec << parameters.spec-options >><<#parameters.junit>> --junit_output << parameters.junit-output >><</parameters.junit>>
- when:
condition: << parameters.junit >>
steps:
- store_test_results:
path: << parameters.junit-output >>
- store_artifacts:
path: << parameters.junit-output >>
format-check:
description: |
Check the format of the source code.
steps:
- run:
name: Check format
command: crystal tool format --check
version:
description: |
Show Crystal and Shards version.
steps:
- run:
name: Crystal and Shards version
command: |
crystal --version
shards --version
jobs:
test:
description: |
Download dependencies, run specs and check format with specified Crystal version.
parameters:
spec-options:
description: Additional options to crystal spec like --tag fast
type: string
default: ""
junit:
description: Store crystal spec output in JUnit format and use it as CircleCI test results
type: boolean
default: true
junit-output:
description: JUnit output location
type: string
default: ~/test-results/crystal-spec
format-check:
description: Check the format of the source code
type: boolean
default: true
executor:
description: The executor to use for this job
type: executor
default: default
cache-key:
description: File to use as a shards cache checksum
default: shard.yml
type: string
cache-version:
description: Cache version; increment this for a fresh cache
default: v1
type: string
include-branch-in-cache-key:
description: If true, includes current branch name in cache key
default: true
type: boolean
executor: << parameters.executor >>
steps:
- version
- checkout
- with-shards-cache:
cache-key: << parameters.cache-key >>
cache-version: << parameters.cache-version >>
include-branch-in-cache-key: << parameters.include-branch-in-cache-key >>
steps:
- shards-install
- spec:
spec-options: << parameters.spec-options >>
junit: << parameters.junit >>
junit-output: << parameters.junit-output >>
- when:
condition: << parameters.format-check >>
steps:
- format-check
examples:
latest:
description: |
Example for testing using latest Crystal release.
usage:
workflows:
version: 2
build:
jobs:
- crystal/test
orbs:
crystal: manastech/crystal@x.y
version: 2.1
nightly:
description: |
Example for testing using nightly Crystal release.
usage:
workflows:
version: 2
build:
jobs:
- crystal/test:
name: test-on-nightly
executor:
name: crystal/default
tag: nightly
orbs:
crystal: manastech/crystal@x.y
version: 2.1
binary-dependencies:
description: |
Adding binary dependencies via apt.
usage:
workflows:
version: 2
build:
jobs:
- crystal/test:
pre-steps:
- run: apt-get update && apt-get install -y libsqlite3-dev
orbs:
crystal: manastech/crystal@x.y
version: 2.1
external-services:
description: |
Use docker to add external services. Define a custom executor but keep using the crystal/test job.
usage:
executors:
crystal_mysql:
docker:
- image: crystallang/crystal:latest
environment:
DATABASE_URL: mysql://root@localhost/db
- image: mysql:5.7
environment:
MYSQL_DATABASE: db
MYSQL_ALLOW_EMPTY_PASSWORD: yes
workflows:
version: 2
build:
jobs:
- crystal/test:
executor: crystal_mysql
pre-steps:
- run:
name: Waiting for service to start (check dockerize)
command: sleep 5
orbs:
crystal: manastech/crystal@x.y
version: 2.1