Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #23 from irgalamarr/cd-pipeline
Browse files Browse the repository at this point in the history
CI pipeline
  • Loading branch information
irgalamarr authored Dec 17, 2023
2 parents 0f15708 + 2e906d3 commit 42195aa
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
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-irgalamarr/accounts:1
- image: IMAGE_NAME_HERE
name: accounts
resources: {}
env:
Expand Down
48 changes: 48 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 Down Expand Up @@ -50,3 +51,50 @@ spec:
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
34 changes: 34 additions & 0 deletions tekton/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,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)

0 comments on commit 42195aa

Please sign in to comment.