Skip to content

Commit 4ba6390

Browse files
Merge pull request #20 from ImranullahKhann/cd-pipeline
Cd pipeline
2 parents db608bf + f7ce91d commit 4ba6390

File tree

4 files changed

+84
-9
lines changed

4 files changed

+84
-9
lines changed

deploy/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
app: accounts
1919
spec:
2020
containers:
21-
- image: us.icr.io/sn-labs-imranullahkh/accounts:1
21+
- image: IMAGE_NAME_HERE
2222
name: accounts
2323
resources: {}
2424

tekton/pipeline.yaml

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#
2-
# This pipeline needs the following tasks from Tekton Hub
3-
# - git-clone
4-
# - flake8
5-
#
6-
---
71
apiVersion: tekton.dev/v1beta1
82
kind: Pipeline
93
metadata:
@@ -14,6 +8,7 @@ spec:
148
params:
159
- name: repo-url
1610
- name: branch
11+
- name: build-image
1712
default: main
1813
tasks:
1914
- name: init
@@ -36,3 +31,49 @@ spec:
3631
value: $(params.branch)
3732
runAfter:
3833
- init
34+
35+
- name: tests
36+
workspaces:
37+
- name: source
38+
workspace: pipeline-workspace
39+
taskRef:
40+
name: nose
41+
params:
42+
- name: database_uri
43+
value: "sqlite:///test.db"
44+
- name: args
45+
value: "-v --with-spec --spec-color"
46+
runAfter:
47+
- clone
48+
49+
- name: build
50+
workspaces:
51+
- name: source
52+
workspace: pipeline-workspace
53+
taskRef:
54+
name: buildah
55+
kind: ClusterTask
56+
params:
57+
- name: IMAGE
58+
value: "$(params.build-image)"
59+
runAfter:
60+
- tests
61+
62+
- name: deploy
63+
workspaces:
64+
- name: manifest-dir
65+
workspace: pipeline-workspace
66+
taskRef:
67+
name: openshift-client
68+
kind: ClusterTask
69+
params:
70+
- name: SCRIPT
71+
value: |
72+
echo "Updating manifest..."
73+
sed -i "s|IMAGE_NAME_HERE|$(params.build-image)|g" deploy/deployment.yaml
74+
cat deploy/deployment.yaml
75+
echo "Deploying to OpenShift..."
76+
oc apply -f deploy/
77+
oc get pods -l app=accounts
78+
runAfter:
79+
- build

tekton/tasks.yaml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
apiVersion: tekton.dev/v1beta1
32
kind: Task
43
metadata:
@@ -49,4 +48,38 @@ spec:
4948
# Delete files and directories starting with .. plus any other character
5049
rm -rf "${WORKSPACE_SOURCE_PATH}"/..?*
5150
fi
51+
---
52+
apiVersion: tekton.dev/v1beta1
53+
kind: Task
54+
metadata:
55+
name: nose
56+
spec:
57+
description: This task will run nosetests on the provided input.
58+
workspaces:
59+
- name: source
60+
params:
61+
- name: args
62+
description: Arguments to pass to nose
63+
type: string
64+
default: "-v"
65+
- name: database_uri
66+
description: Database connection string
67+
type: string
68+
default: "sqlite:///test.db"
69+
steps:
70+
- name: nosetests
71+
image: python:3.9-slim
72+
workingDir: $(workspaces.source.path)
73+
env:
74+
- name: DATABASE_URI
75+
value: $(params.database_uri)
76+
script: |
77+
#!/bin/bash
78+
set -e
79+
80+
echo "***** Installing dependencies *****"
81+
python -m pip install --upgrade pip wheel
82+
pip install -qr requirements.txt
5283

84+
echo "***** Running nosetests with: $(params.args)"
85+
nosetests $(params.args)

tests/test_routes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,5 @@ def test_cors_security(self):
192192
response = self.client.get('/', environ_overrides=HTTPS_ENVIRON)
193193
self.assertEqual(response.status_code, status.HTTP_200_OK)
194194
# Check for the CORS header
195-
self.assertEqual(response.headers.get('Access-Control-Allow-Origin'), '*')
195+
self.assertEqual(response.headers.get('Access-Control-Allow-Origin'), '*')
196+

0 commit comments

Comments
 (0)