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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![Build Status](https://github.com/Moon-Knight13/devops-capstone-project/actions/workflows/ci-build.yaml/badge.svg)


This is my captsone project for IBM.
This is my capstone project for IBM.


# DevOps Capstone Template
Expand Down
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-chrism2013/accounts:1
- image: IMAGE_NAME_HERE
name: accounts
resources: {}

Expand Down
263 changes: 263 additions & 0 deletions pipelinerun.txt

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions tekton/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
- name: repo-url
- name: branch
default: main
- name: build-image
tasks:
- name: init
workspaces:
Expand All @@ -36,3 +37,64 @@ spec:
value: $(params.branch)
runAfter:
- init

- name: lint
workspaces:
- name: source
workspace: pipeline-workspace
taskRef:
name: flake8
params:
- name: image
value: "python:3.9-slim"
- name: args
value: ["--count","--max-complexity=10","--max-line-length=127","--statistics"]
runAfter:
- clone

- 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
- lint

- 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: 35 additions & 0 deletions tekton/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,39 @@ 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)

9 changes: 3 additions & 6 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ def test_unsupported_media_type(self):
def test_get_account(self):
"""It should Read a single Account"""
account = self._create_accounts(1)[0]
response = self.client.get(f"{BASE_URL}/{account.id}", content_type="application/json"
)
response = self.client.get(f"{BASE_URL}/{account.id}", content_type="application/json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
data = response.get_json()
self.assertEqual(data["name"], account.name)
Expand All @@ -140,17 +139,15 @@ def test_get_account_not_found(self):
response = self.client.get(f"{BASE_URL}/0")
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

# update the account
# update the account
def test_update_account(self):
"""It should Update an existing Account"""
test_account = AccountFactory()
response = self.client.post(
BASE_URL,
json=test_account.serialize(),
content_type="application/json"
)
content_type="application/json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED)

new_account = response.get_json()
new_account["name"] = "Something Known"
response = self.client.put(f"{BASE_URL}/{new_account['id']}", json=new_account)
Expand Down
Loading