Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
app: accounts
spec:
containers:
- image: us.icr.io/sn-labs-imranullahkh/accounts:1
- image: IMAGE_NAME_HERE
name: accounts
resources: {}

Expand Down
53 changes: 47 additions & 6 deletions tekton/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#
# This pipeline needs the following tasks from Tekton Hub
# - git-clone
# - flake8
#
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
Expand All @@ -14,6 +8,7 @@ spec:
params:
- name: repo-url
- name: branch
- name: build-image
default: main
tasks:
- name: init
Expand All @@ -36,3 +31,49 @@ spec:
value: $(params.branch)
runAfter:
- init

- name: tests
workspaces:
- name: source
workspace: pipeline-workspace
taskRef:
name: nose
params:
- name: database_uri
value: "sqlite:///test.db"
- name: args
value: "-v --with-spec --spec-color"
runAfter:
- clone

- name: build
workspaces:
- name: source
workspace: pipeline-workspace
taskRef:
name: buildah
kind: ClusterTask
params:
- name: IMAGE
value: "$(params.build-image)"
runAfter:
- tests

- name: deploy
workspaces:
- name: manifest-dir
workspace: pipeline-workspace
taskRef:
name: openshift-client
kind: ClusterTask
params:
- name: SCRIPT
value: |
echo "Updating manifest..."
sed -i "s|IMAGE_NAME_HERE|$(params.build-image)|g" deploy/deployment.yaml
cat deploy/deployment.yaml
echo "Deploying to OpenShift..."
oc apply -f deploy/
oc get pods -l app=accounts
runAfter:
- build
35 changes: 34 additions & 1 deletion tekton/tasks.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
Expand Down Expand Up @@ -49,4 +48,38 @@ spec:
# Delete files and directories starting with .. plus any other character
rm -rf "${WORKSPACE_SOURCE_PATH}"/..?*
fi
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: nose
spec:
description: This task will run nosetests on the provided input.
workspaces:
- name: source
params:
- name: args
description: Arguments to pass to nose
type: string
default: "-v"
- name: database_uri
description: Database connection string
type: string
default: "sqlite:///test.db"
steps:
- name: nosetests
image: python:3.9-slim
workingDir: $(workspaces.source.path)
env:
- name: DATABASE_URI
value: $(params.database_uri)
script: |
#!/bin/bash
set -e

echo "***** Installing dependencies *****"
python -m pip install --upgrade pip wheel
pip install -qr requirements.txt

echo "***** Running nosetests with: $(params.args)"
nosetests $(params.args)
3 changes: 2 additions & 1 deletion tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,5 @@ def test_cors_security(self):
response = self.client.get('/', environ_overrides=HTTPS_ENVIRON)
self.assertEqual(response.status_code, status.HTTP_200_OK)
# Check for the CORS header
self.assertEqual(response.headers.get('Access-Control-Allow-Origin'), '*')
self.assertEqual(response.headers.get('Access-Control-Allow-Origin'), '*')