CI/CD for solutions
Use Instabase APIs to implement a continuous integration (CI) and continuous delivery (CD) approach to solution development, also known as continuous development.
Solution promotion workflow
Solution development typically occurs across three environments (also called deployments), such as DEV, UAT, and PROD. Solutions are developed in DEV, tested in UAT, and executed in PROD. While it’s possible to use the Instabase UI to export and import solutions across environments, a programmatic approach enables continuous development.
Assuming you have DEV, UAT, and PROD environments, the typical solution promotion process involves development, system integration testing, and production stages. Many of the steps in each stage can be strung together and automated using scripting.
-
During the development stage in the DEV environment:
-
Develop the solution and create any necessary supporting files, such as a
package.json
file that describes the solution and anicon.png
file. -
Either deploy the solution or publish the solution to Marketplace.
-
Copy the solution files and any dependencies from the DEV environment to the UAT environment.
-
-
During the system integration testing stage in the UAT environment:
-
Either deploy the solution or publish the solution to Marketplace.
-
Perform solution testing to validate functionality.
-
Copy the solution files and any dependencies from the UAT environment to the PROD environment.
-
-
During the production stage in the PROD environment:
-
Either deploy the solution or publish the solution to Marketplace.
-
Execute the solution.
-
CI/CD Toolkit
CI/CD Toolkit is an Instabase tool that uses Python scripting and Instabase APIs to automate compiling and copying a solution from a source environment to a target environment. CI/CD Toolkit can be launched from a CI/CD pipeline and includes samples for integration with GitHub Actions.
CI/CD Toolkit includes scripts for promoting solutions built with or without using Solution Builder. The promote_solution.py
script, designed for solutions not built with Solution Builder, automates the majority of the steps in the solution promotion process, with the exception of development, testing, and execution in production. To promote a solution built in Solution Builder, use the promote_sb_solution.py
script to automate those steps. The following diagram provides an overview of how CI/CD Toolkit can be used to help automate solution promotion between environments.
Environment variables
The following environment variables are referenced by the promote_solution.py
script.
Environment variable | Description |
---|---|
SOURCE_IB_API_TOKEN | An OAuth API token for source environment. Ideally, the token belongs to a service account.
Note
For security purposes, this value can be set as a secret rather than as a variable in GitHub.
|
TARGET_IB_API_TOKEN | An OAuth API token for target environment. Ideally, the token belongs to a service account.
Note
For security purposes, this value can be set as a secret rather than as a variable in GitHub.
|
SOURCE_IB_HOST | The URL of the source Instabase environment. |
SOURCE_WORKING_DIR | The file path in the source Instabase environment’s file system to use for downloading dependencies. |
SOURCE_SOLUTION_DIR | The file path to the solution directory in the source Instabase environment. |
LOCAL_SOLUTION_DIR | The directory in the local repository that contains IB solution code. This variable is used for local source flows. If using a remote source flow, leave an empty string. |
REL_FLOW_PATH | The file path to the solution’s flow, relative to the solution directory. For example, if the complete file path to the flow is path/to/solution/Flow/some_flow.ibflow . SOURCE_SOLUTION_DIR is path/to/solution and REL_FLOW_PATH is Flow/some_flow.ibflow . |
SOURCE_COMPILED_SOLUTIONS_PATH | The file path to where .ibsolution files are generated. This is usually one level higher than the SOURCE_SOLUTION_DIR path. |
TARGET_IB_HOST | The URL of the target Instabase environment. |
TARGET_IB_PATH | The file path in the target Instabase environment where the solution is uploaded. |
The following environment variables are referenced by the promote_sb_solution.py
script.
Environment variable | Description |
---|---|
SOURCE_IB_API_TOKEN | An OAuth API token for source environment. Ideally, the token belongs to a service account.
Note
For security purposes, this value can be set as a secret rather than as a variable in GitHub.
|
TARGET_IB_API_TOKEN | An OAuth API token for target environment. Ideally, the token belongs to a service account.
Note
For security purposes, this value can be set as a secret rather than as a variable in GitHub.
|
SOURCE_IB_HOST | The URL of the source Instabase environment. |
SOURCE_WORKING_DIR | The file path in the source Instabase environment’s file system to use for downloading dependencies. |
SOLUTION_BUILDER_NAME | The name of the Solution Builder project. |
WORKSPACE_DRIVE_PATH | Path in source Instabase environment’s filesystem to the drive where the Solution Builder project is stored, such as space/subspace/fs/Instabase Drive . |
FLOW_NAME | The name of the flow in the Solution Builder project. |
DEPENDENCIES | A string representation of list of model and marketplace package dependencies in the format model_name==0.0.1,package_name==0.4.5,second_package==0.0.1 |
TARGET_IB_HOST | The URL of the target Instabase environment. |
TARGET_IB_PATH | The file path in the target Instabase environment where the solution is uploaded. |
For example, for a remote source flow, set these environment variables before running promote_solution.py
:
export SOURCE_IB_API_TOKEN="OAUTH_TOKEN"
export TARGET_IB_API_TOKEN="OAUTH_TOKEN"
export SOURCE_IB_HOST="https://dev.domain.tld"
export SOURCE_WORKING_DIR="space/subspace/fs/Instabase Drive/Temp"
export SOURCE_SOLUTION_DIR="space/subspace/fs/Instabase Drive/Solution"
export REL_FLOW_PATH="Flows/Flow.ibflow"
export SOURCE_COMPILED_SOLUTIONS_PATH="space/subspace/fs/Instabase Drive"
export LOCAL_SOLUTION_DIR=""
export TARGET_IB_HOST="https://uat.domain.tld"
export TARGET_IB_PATH="space/subspace/fs/Instabase Drive/Solution"
Flags
The CI/CD Toolkit promote_solution.py
script calls Instabase APIs to execute the steps required for automated solution promotion between environments. When executing the script, you can use flags to run a series of pre-selected subroutines or to select specific steps to run. For example, you can specify optional steps like compiling the .ibflow
file to an .ibsolution
file, or downloading the compiled .ibsolution
file for use with environment pipelines and artifact repositories.
Workflow flags
Workflow flags run all required promotion steps for a local or remote source.
Option | Description |
---|---|
--local_flow |
Performs all required promotion steps for a local source (local repository). This workflow assumes the solution is deployed and copied to the Solution Dashboard, not published to Marketplace; use the --marketplace option if otherwise. |
--remote_flow |
Performs all required promotion steps for a remote source (Instabase environment). The steps --compile_source_solution and --set_github_actions_env_var aren’t included by default and must be specified. This workflow also assumes the solution is deployed and copied to the Solution Dashboard, not published to Marketplace; use the --marketplace option if otherwise. |
Promotion flags
Promotion flags execute specific steps in the promotion process. Workflow flags let you execute multiple steps.
The following flags are used with the promote_solution.py
script.
Option | Description |
---|---|
--compile_source_solution |
Compiles the solution in the source environment, referencing the path specified in the SOURCE_SOLUTION_DIR environment variable. |
--publish_source_solution |
Publishes the latest version of the solution found in the source environment as a deployed solution to the Solution Dashboard. |
--promote_solution_to_target |
Uploads the solution to the target environment. |
--publish_target_solution |
Publishes the latest version of the solution in the target environment as a deployed solution to the Solution Dashboard. Use the --local source option to upload code from a repository. |
--upload_dependencies |
Uploads and publishes the solution dependencies to the target environment based on dependencies listed in package.json . |
--download_ibsolution |
Downloads the .ibsolution file to the local file system. |
--set_github_actions_env_var |
Sets the PACKAGE_VERSION environment variable. This option is used in later steps in the GitHub Actions pipeline. |
--marketplace |
Publishes the solution to Marketplace. If this option isn’t specified, the default is to publish to the Solution Dashboard as a deployed solution. |
The following flags are used with the promote_sb_solution.py
script when promoting Solution Builder projects.
Option | Description |
---|---|
--compile_source_solution |
Compiles the solution in the source environment, referencing the path specified in the SOURCE_SOLUTION_DIR environment variable. |
--deploy_source_solution |
Publishes the latest version of the solution found in the source environment as a deployed solution to the Solution Dashboard. |
--promote_solution_to_target |
Uploads the solution to the target environment. |
--upload_dependencies |
Uploads and publishes the solution dependencies to the target environment based on dependencies listed in package.json . |
--download_ibsolution |
Downloads the .ibsolution file to the local file system. |
--set_github_actions_env_var |
Sets the PACKAGE_VERSION environment variable. This option is used in later steps in the GitHub Actions pipeline. |
Source flags
Source flags can be used along with promotion flags to indicate the source location of the solution: a local repository or a remote Instabase environment.
Option | Description |
---|---|
--local |
Promotes a solution from the local repository specified in the LOCAL_SOLUTION_DIR environment variable. |
--remote |
Promotes a solution from a source Instabase environment. |
Integration with common workflows
There are many ways to integrate CI/CD Toolkit into your software development lifecycle. These are some common examples.
For promoting solutions that were not built using Solution Builder, you must have:
-
At least two Instabase environments, one for the source of the solution (typically DEV) and one that is the target for promotion (typically UAT or PROD).
-
Your solution’s
.ibflow
file. This file is compiled into an.ibsolution
file in the target environment. -
A
package.json
file describing the solution to be promoted. Reference the example in this guide when creating your own. -
An
icon.png
file, to use as the solution’s image in the Marketplace of the target environment. The recommended size is 120 x 120 px. -
The CI/CD Toolkit package, downloadable from the Instabase GitHub Repository.
-
The
requests
Python library. Seerequirements.txt
in CI/CD Toolkit for the latest requirements.
For promoting solutions that were built using Solution Builder, you must have:
-
A solution containing a flow that was built in Solution Builder.
-
The CI/CD Toolkit package, downloadable from the Instabase GitHub Repository.
-
The
requests
Python library. Seerequirements.txt
in CI/CD Toolkit for the latest requirements.
Workflow between remote Instabase clusters
Use this flow to migrate a solution from one Instabase cluster to another, such as from DEV to UAT.
-
Develop your solution on Instabase.
-
Save the
package.json
file at the root level of your solution.TipOn subsequent promotions, be sure to update the solution’s version number in the
package.json
file. -
Save the
icon.png
file at the root of your solution. -
Configure your environment variables according to the provided template. Don’t include a
LOCAL_SOLUTION_DIR
variable. -
Execute the following script:
python cicd/promote_solution.py --remote-flow
-
Save the downloaded
.ibsolution
file as an artifact in your artifact repository.
Workflow between a local repository and Instabase cluster using GitHub Actions
You can use GitHub Actions to leverage a local GitHub repository and migrate the solution from that repo to an Instabase cluster.
-
In GitHub, set the environment variables according to the provided template. Make sure to include a
LOCAL_SOLUTION_DIR
environment variable. -
Copy the
local-github-actions-workflow.yml
from CI/CD Toolkit to a.GitHub/workflows
folder at the root level of your solution. -
Copy the
promote_solution.py script
from CI/CD Toolkit to the root level of your solution. -
Develop your solution on Instabase.
-
Create a new feature branch and copy the solution directory to the local
repo
folder. -
Save the
package.json
file at the root level of your solution. -
Save the
icon.png
file at the root level of your solution. -
Push the solution to a feature branch of your GitHub repository.
-
Create a pull request to your main branch.
-
Merge the pull request.
When merged, the GitHub Action automatically performs these steps:
-
Runs the command
promote_solution.py --local_flow --download_ibsolution --set_github_actions_env_var
. -
Creates a GitHub release tag with the version specified in the
package.json
file. -
Uploads the
.ibsolution
file to the release artifacts.
Workflow between remote Instabase clusters promoting a Solution Builder project
-
Develop your solution on Instabase.
-
Configure your environment variables according to the provided template. Don’t include a
LOCAL_SOLUTION_DIR
variable. -
Execute the following script:
python cicd/promote_sb_solution.py --remote_flow --download_ibsolution
-
Save the downloaded
.ibsolution
file as an artifact in your artifact repository.
Sample package.json
Solution packages require a package.json
file that describes the solution. You can reference the examples here when creating your own. Packages used for continuous development have additional requirements beyond typical solution packages, including:
-
A
"dependencies"
object which lists any models or packages that are linked to the solution. If there are no dependencies, you must still include the"dependencies"
object and its fields, but with empty arrays as the values. -
The fields
"owner"
and"visibility"
, if the solution is deployed and copied to the Solution Dashboard (Deployed Solutions) rather than being published to Marketplace. Set"owner"
to"IB_DEPLOYED"
and"visibility"
to"PUBLIC"
.
Example 1: A Form W-2 solution, with dependencies, that’s deployed and copied to the Solution Dashboard.
{
"name": "Form W-2",
"version": "0.0.2",
"short_description": "Automatically process Form W-2",
"long_description": "Extract key fields from Tax Form W-2 in the United States",
"authors": [
"Instabase"
],
"solution_type": "ibflowbin",
"accelerator_type": [
"solution"
],
"industry": [
"Financial Services"
],
"business_vertical": [
"Retail & Consumer Banking"
],
"use_case": [
"Account Opening"
],
"icon_file": "icon.png",
"beta": true,
"encryption_config": {
"encryption_type": "v1"
},
"dependencies": {
"models": ["model_for_cicd==0.0.1"],
"dev_exchange_packages": ["package_for_cicd==0.0.1"]
},
"owner": "IB_DEPLOYED",
"visibility": "PUBLIC"
}
Example 2: A Form W-2 solution, without dependencies, that’s published to Marketplace.
{
"name": "Form W-2",
"version": "0.0.2",
"short_description": "Automatically process Form W-2",
"long_description": "Extract key fields from Tax Form W-2 in the United States",
"authors": [
"Instabase"
],
"solution_type": "ibflowbin",
"accelerator_type": [
"solution"
],
"industry": [
"Financial Services"
],
"business_vertical": [
"Retail & Consumer Banking"
],
"use_case": [
"Account Opening"
],
"icon_file": "icon.png",
"beta": true,
"encryption_config": {
"encryption_type": "v1"
},
"dependencies": {
"models": [],
"dev_exchange_packages": []
}
}