CI Integration using Neurelo CLI
Overview
Testing is a critical step in the software development lifecycle. Neurelo CLI makes it really easy to set up a "CI" environment that can be used for testing purposes.
Creating a Machine User
The first step to automating your testing process with Neurelo is to create a new "Machine User" for your Organization. This user will have access to all projects in your Organization, and can be removed at any time.
To create one,
Go to the Org members page
Click on the dropdown next to "Invite User" on the top right
Click "Create Machine User"
Set an identifier for your "Machine User" and click "Submit".
Once the "Machine User" has been created, you will be shown two pieces of information: the "client id" and the "client secret", make sure to store them safely and don't lose them, as the "client secret" won't be shown again.
This "client id" and "client secret" can now be used to authenticate the CLI and execute commands without any human interaction. For more details on the Neurelo CLI, please refer here
Using the machine user in the CLI
Before running the CLI,
Setup environment variables
NEURELO_CLIENT_ID
andNEURELO_CLIENT_SECRET
using the "client_id" and "client_secret" from the prior step
Then,
Run
neurelo login
The CLI will look for the environment variables NEURELO_CLIENT_ID
and NEURELO_CLIENT_SECRET
, and will use them automatically when neurelo login
is invoked.
Using the CLI for CI tests
Once the CLI is authenticated, you can invoke
which will do multiple things:
Use the project configured with the
--projectId=
valueCreate a Data Source pointing to the provided
--connectionString=
valueCreate an Environment using the provided
--region=
and--commitId=
values and attaching the previously created Data Source to itCreate an API Key for the created Environment
Start the Environment runners and wait for them to be ready
Present the API Key as the output for it to be used in your tests
The
--runId=
value is used to generate the Data Source, Environment, and API Key names. It is recommended to use unique and easy-to-identify values for this, like the short version of a commit hash or similarThe
--resetDb
flag indicates that a full reset of the database should be applied before the runners are started. This means, delete the existing db schema and execute the available migrations for the environment
Note - Mock Data Generation support is coming soon which will also enable you to generate mock data for your testing automatically as part of this piepline
After your tests have finished executing, by just invoking neurelo ci stop
, all the previously created resources will be deleted.
Sample Script
Here is a sample bash script that makes use of the Neurelo CLI to execute tests for a nodejs project:
Last updated