Skip to content

Commit 7ea41b2

Browse files
authored
Upgrade monochart, add tests (#7)
* Upgrade monochart * Add compose
1 parent ccaf864 commit 7ea41b2

File tree

6 files changed

+100
-19
lines changed

6 files changed

+100
-19
lines changed

codefresh/deploy.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ steps:
1818
ask_for_permission:
1919
type: pending-approval
2020
title: Deploy release?
21+
stage: Prepare
2122

2223
wait:
2324
title: Wait
2425
stage: Prepare
2526
image: codefresh/cli:latest
2627
commands:
27-
- codefresh get builds --pipeline=deploy --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id'
28+
- codefresh get builds --pipeline=deploy-${{STAGE}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id'
2829
retry:
2930
maxAttempts: 10
3031
delay: 20
@@ -45,3 +46,14 @@ steps:
4546
- name: ask_for_permission
4647
on:
4748
- approved
49+
50+
send_slack_notification:
51+
title: Send notification to Slack channel
52+
stage: Deploy
53+
image: cloudposse/build-harness:${{BUILD_HARNESS_VERSION}}
54+
working_directory: /build-harness
55+
environment:
56+
- PIPELINE_ENV=${{STAGE}}
57+
commands:
58+
- make codefresh/notify/slack/deploy/webapp
59+

codefresh/pull-request.yaml

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: '1.0'
33
stages:
44
- Prepare
55
- Build
6-
- Push
6+
- Test
77
- Deploy
88

99
steps:
@@ -32,23 +32,54 @@ steps:
3232
- cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}
3333
- cf_export IMAGE_TAG=${{CF_REVISION}}
3434

35-
build_image:
36-
title: Build image
35+
build:
36+
type: parallel
3737
stage: Build
38-
type: build
39-
description: Build app
40-
image_name: ${{CF_REPO_NAME}}
41-
dockerfile: Dockerfile
42-
no_cache: false
43-
no_cf_cache: false
38+
steps:
39+
build_image:
40+
title: Build image
41+
type: build
42+
description: Build app
43+
image_name: ${{CF_REPO_NAME}}
44+
tag: ${{CF_SHORT_REVISION}}
45+
dockerfile: Dockerfile
46+
no_cache: false
47+
no_cf_cache: false
4448

45-
push_image_commit:
46-
title: Push image with commit tag
47-
stage: Push
48-
type: push
49-
candidate: ${{build_image}}
50-
tags:
51-
- "${{CF_REVISION}}"
49+
build_test:
50+
title: "Build test image"
51+
type: build
52+
description: "Build test image"
53+
dockerfile: Dockerfile
54+
image_name: ${{CF_REPO_NAME}}
55+
tag: ${{CF_SHORT_REVISION}}-test
56+
when:
57+
condition:
58+
all:
59+
testsEnabled: "'${{INTEGRATION_TESTS_ENABLED}}' == 'true'"
60+
61+
test:
62+
title: "Run tests"
63+
stage: Test
64+
type: composition
65+
fail_fast: true
66+
# Run the docker-composition defined in the file
67+
composition: codefresh/test/docker-compose.yml
68+
# Run tests against the composition
69+
composition_candidates:
70+
app:
71+
image: ${{build_test}}
72+
entrypoint: /bin/sh -c
73+
command: codefresh/test/test.sh
74+
env_file:
75+
- codefresh/test/test.env
76+
volumes:
77+
- '${{CF_VOLUME_NAME}}:${{CF_VOLUME_PATH}}'
78+
working_dir: '${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}'
79+
when:
80+
condition:
81+
all:
82+
testsEnabled: "'${{INTEGRATION_TESTS_ENABLED}}' == 'true'"
5283

5384
set_github_deployment_status_to_pending:
5485
title: Set GitHub deployment status to "pending"
@@ -69,6 +100,14 @@ steps:
69100
all:
70101
githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'"
71102

103+
push_image_commit:
104+
title: Push image with commit tag
105+
stage: Deploy
106+
type: push
107+
candidate: ${{build_image}}
108+
tags:
109+
- "${{CF_REVISION}}"
110+
72111
deploy_helmfile:
73112
title: Deploy with helmfile
74113
stage: Deploy
@@ -103,5 +142,13 @@ steps:
103142
title: Send notification to Slack channel
104143
stage: Deploy
105144
image: cloudposse/build-harness:${{BUILD_HARNESS_VERSION}}
145+
working_directory: /build-harness
146+
environment:
147+
- GIT_COMMIT_SHORT=${{CF_SHORT_REVISION}}
148+
- GIT_COMMIT_URL=${{CF_COMMIT_URL}}
149+
- GIT_COMMIT_MESSAGE=${{CF_COMMIT_MESSAGE}}
150+
- GIT_COMMIT_AUTHOR=${{CF_COMMIT_AUTHOR}}
151+
- GIT_BRANCH_TAG=${{CF_BRANCH_TAG_NORMALIZED}}
106152
commands:
107-
- make codefresh/notify/slack/deploy/webapp
153+
- make codefresh/notify/slack/deploy/webapp GIT_COMMIT_TIMESTAMP=$((${{CF_BUILD_TIMESTAMP}}/1000))
154+

codefresh/test/docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3'
2+
services:
3+
app:
4+
environment:
5+
- "COLOR=#0099ff"
6+
ports:
7+
- "8080:8080"

codefresh/test/test.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
COLOR=\#0099ff

codefresh/test/test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
apk add --update curl
6+
7+
/app/example-app&
8+
9+
sleep 3
10+
11+
set -o pipefail
12+
13+
14+
curl -fsSL http://app:8080/ | grep "background-color: ${COLOR}"

deploy/releases/app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ releases:
1313
color: "{{ requiredEnv "COLOR" }}"
1414
pull-request: "true"
1515
chart: "cloudposse-incubator/monochart"
16-
version: "0.7.0"
16+
version: "0.12.0"
1717
wait: true
1818
force: true
1919
recreatePods: false

0 commit comments

Comments
 (0)