Skip to content

Commit 2801e5b

Browse files
authored
Merge pull request #54 from elasticio/test_ci
CI/CD pipeline to build component docker image
2 parents 57bddeb + 2cdc885 commit 2801e5b

File tree

2 files changed

+118
-20
lines changed

2 files changed

+118
-20
lines changed

.circleci/config.yml

Lines changed: 118 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,124 @@
1-
version: 2 # use CircleCI 2.0
2-
jobs: # a collection of steps
3-
test: # runs not using Workflows must have a `build` job as entry point
1+
version: 2.1
2+
parameters:
3+
node-version:
4+
type: string
5+
default: "16.13.2"
6+
orbs:
7+
node: circleci/node@5.0.0
8+
slack: circleci/slack@4.5.3
9+
commands:
10+
notify_on_failure:
11+
steps:
12+
- slack/notify:
13+
event: fail
14+
custom: |
15+
{
16+
"blocks": [
17+
{
18+
"type": "section",
19+
"fields": [
20+
{
21+
"type": "mrkdwn",
22+
"text": ":red_circle: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* build failed"
23+
}
24+
]
25+
},
26+
{
27+
"type": "actions",
28+
"elements": [
29+
{
30+
"type": "button",
31+
"text": {
32+
"type": "plain_text",
33+
"text": "View Job"
34+
},
35+
"url": "${CIRCLE_BUILD_URL}"
36+
}
37+
]
38+
}
39+
]
40+
}
41+
notify_on_pass:
42+
steps:
43+
- slack/notify:
44+
event: pass
45+
custom: |
46+
{
47+
"blocks": [
48+
{
49+
"type": "section",
50+
"fields": [
51+
{
52+
"type": "mrkdwn",
53+
"text": ":tada: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* was successfully built and published"
54+
}
55+
]
56+
},
57+
{
58+
"type": "actions",
59+
"elements": [
60+
{
61+
"type": "button",
62+
"text": {
63+
"type": "plain_text",
64+
"text": "View Job"
65+
},
66+
"url": "${CIRCLE_BUILD_URL}"
67+
}
68+
]
69+
}
70+
]
71+
}
72+
73+
jobs:
74+
test:
475
docker: # run the steps with Docker
5-
- image: circleci/node:12-stretch # ...with this image as the primary container; this is where all `steps` will run
6-
steps: # a collection of executable commands
7-
- checkout # special step to check out source code to working directory
8-
- restore_cache: # special step to restore the dependency cache
9-
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
10-
key: dependency-cache-{{ checksum "package.json" }}
76+
- image: cimg/base:stable
77+
steps:
78+
- checkout
79+
- node/install:
80+
node-version: << pipeline.parameters.node-version >>
81+
- node/install-packages:
82+
cache-path: ./node_modules
83+
override-ci-command: npm install
1184
- run:
12-
name: Installing Dependencies
13-
command: npm install
14-
- save_cache: # special step to save the dependency cache
15-
key: dependency-cache-{{ checksum "package.json" }}
16-
paths:
17-
- node_modules
18-
- run: # run tests
1985
name: test
2086
command: npm test
87+
88+
build:
89+
docker:
90+
- image: cimg/base:stable
91+
user: root
92+
steps:
93+
- checkout
94+
- node/install:
95+
node-version: << pipeline.parameters.node-version >>
96+
- setup_remote_docker:
97+
version: 19.03.13
98+
docker_layer_caching: true
99+
# build and push Docker image
100+
- run:
101+
name: Install component-build-helper lib
102+
command: npm install -g @elastic.io/component-build-helper
103+
- run:
104+
name: Build and publish docker image
105+
command: build_component_docker
106+
- notify_on_failure
107+
- notify_on_pass
21108
workflows:
22-
version: 2
23-
build_and_test:
109+
test:
110+
jobs:
111+
- test:
112+
name: "Running tests"
113+
filters:
114+
tags:
115+
ignore: /.*/
116+
publish_release:
24117
jobs:
25-
- test
118+
- build:
119+
name: "Build and publish docker image"
120+
filters:
121+
branches:
122+
ignore: /.*/
123+
tags:
124+
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/

component.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"title": "Node.js Code",
33
"version": "1.2.6",
44
"description": "You can write your own code and deploy it as part of integration process.",
5-
"buildType": "docker",
65
"docsUrl": "http://go2.elastic.io/code-component",
76
"fields": {
87
"code": {

0 commit comments

Comments
 (0)