Skip to content

Commit c8464d7

Browse files
committed
Add circleci config
1 parent 620bc1a commit c8464d7

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.circleci/config.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
version: 2.1
2+
executors:
3+
docker-executor:
4+
environment:
5+
IMAGE_NAME: peterevans/smoke-testing-helloworld
6+
IMAGE_TAG: latest
7+
DOCKERFILE_PATH: .
8+
docker:
9+
- image: circleci/openjdk:8-stretch
10+
jobs:
11+
build:
12+
executor: docker-executor
13+
steps:
14+
- checkout
15+
- restore_cache:
16+
key: gradle-{{ checksum "build.gradle.kts" }}
17+
- run:
18+
name: Build and test
19+
command: ./gradlew -q build
20+
- save_cache:
21+
paths:
22+
- ~/.gradle
23+
key: gradle-{{ checksum "build.gradle.kts" }}
24+
- store_test_results:
25+
path: build/test-results/
26+
- setup_remote_docker:
27+
docker_layer_caching: true
28+
- run:
29+
name: Build Docker image
30+
command: |
31+
docker build -t $IMAGE_NAME:$IMAGE_TAG $DOCKERFILE_PATH
32+
- run:
33+
name: Cache Docker image
34+
command: docker save -o $IMAGE_TAG.tar $IMAGE_NAME
35+
- persist_to_workspace:
36+
root: .
37+
paths:
38+
- ./*.tar
39+
test:
40+
executor: docker-executor
41+
steps:
42+
- checkout
43+
- attach_workspace:
44+
at: /tmp/workspace
45+
- setup_remote_docker
46+
- run:
47+
name: Load cached Docker image
48+
command: |
49+
docker load -i /tmp/workspace/$IMAGE_TAG.tar
50+
- run:
51+
name: Smoke test Docker container
52+
command: |
53+
docker run -d --name smoke-testing-helloworld $IMAGE_NAME:$IMAGE_TAG
54+
# Dummy container to store tests
55+
#docker create -v /etc/newman --name tests alpine:3.4 /bin/true
56+
#docker cp tests/. tests:/etc/newman
57+
# Run tests
58+
docker run --network container:smoke-testing-helloworld jwilder/dockerize -wait http://localhost:8081/healthcheck -timeout 120s -wait-retry-interval 5s
59+
#docker run --network container:smoke-testing-helloworld --volumes-from tests -t postman/newman:4.4.0-alpine run smoke-testing-helloworld.postman_collection.json
60+
workflows:
61+
version: 2
62+
build:
63+
jobs:
64+
- build
65+
- test:
66+
requires:
67+
- build
68+
# Implement to push your container to a repository
69+
# - publish:
70+
# requires:
71+
# - test

0 commit comments

Comments
 (0)