Your First Workflow in Kraken CI
Kraken CI is a new Continuous Integration tool. It is a modern, open-source, on-premise CI/CD system that is highly scalable and focused on testing. It is licensed under Apache 2.0 license. Its source code is available on Kraken CI GitHub page.
This tutorial is the second installment of the series of articles about Kraken CI. Part 1, Kraken CI, New Kid on the CI block, presented the installation of Kraken. This time we will cover how to prepare a workflow for a simple Python project.
The workflow will:
- fetch sources from GitHub,
- run tests using Pytest,
- build a wheel package,
- upload built package to Kraken’s artifacts storage.
Here we are using fresh Kraken installation using Docker Compose with built-in Kraken Agent running in Docker container. Installation procedure details can be found in part 1 or in the installation manual from https://kraken.ci project web page.
Project Preparation
Details about a new project setup in Kraken CI can be found in the previous article, part 1 as well.
Here, in short, let’s do:
- Create a project with a name: Demo
- Create a branch with a name: main
- Use a pre-created stage and rename it to: Hello World
Stage Hello World
The stage should look as follows:
And the original workflow schema code looks as follows:
Now let’s try if it works. Click Run CI Flow button.
Git Repo Checkout Step
Ok, let’s start extending our schema to make it more real life. First, let’s add a step for checking out a Git repository:
Now run new CI flow. The output should look like this:
The logs show that the repository has been cloned and ls -al shows sample-project-python folder.
Run Tests Step
Now let’s replace the step with listing the current directory with something more interesting, like running tests. Kraken provides several built-in tools for running tests. In the case of our Python sample project, we will use pytest built-in tool.
Change the steps in schema editor, save it and run new CI flow. And the job output should be:
Building Step
So if tests succeeded we could build a package of our Python project. Add step for building a wheel package using project’s setup.py script:
Now run CI flow again. The output should look as follows:
It seems that there is missing a package that provides wheel support for Python. Let’s install it.
New output with building:
Storing Artifacts Step
The results of building the sample project are two packages:
- dist/sampleproject-2.0.0-py3-none-any.whl
- dist/sampleproject-2.0.0.tar.gz
We could store it Kraken storage and make it available for user for downloading. For that purpose there is another built-in tool: artifacts.
And the job output:
Here the log shows that artifacts have been stored. Now, as they were marked as public in artifacts step, they are available in the UI:
This is it. In this installment we learn how to clone Git repository, how to run tests using Pytest, how to install dependencies and how to build artifacts and store them in Kraken’s storage. More about Kraken CI you can find on https://kraken.ci.