Neurelo Build Docs
Neurelo Build Docs
  • Introduction
    • Core Concepts
    • Key Features
  • Getting Started
    • Sign-in/Sign-up
    • Dashboard
      • Collapsible Sidebar
      • Light/Dark Mode
      • Account Settings
      • Audit Events
      • User Management
        • Permissions (Member v/s Admin)
      • Org Settings
    • Starting your Neurelo Project
      • Quick Start Guide
      • Step 1 - Add a Data Source
      • Step 2 - Build Definitions
      • Step 3 - Create an Environment
      • Step 4 - Create an API Key
      • Step 5 - Start Runners
      • Try your Neurelo APIs
  • "How to" Videos
    • Product Overview
    • Neurelo APIs & SDKs
    • Project Setup
    • Definitions
    • Environments
    • Data Sources
    • Organization Management
    • Creating and Using Custom Queries
    • Using the Schema Builder to build Relationships
    • Mock Data Generation
  • Definitions
    • Neurelo Schema Editor
      • Schema Builder
      • JSON/YAML Editor
      • Schema Visualization: Entity-Relationship Diagram (ERD)
    • Custom APIs for Complex Queries
      • Write and Commit Custom Queries
      • AI-Assisted Query Generation
      • Deploying Custom API Endpoints
      • Using Variables in your Custom Query
    • Branches and Commits
    • API Docs
  • Environments
    • Creating a new Environment
    • API Playground
    • Observability
    • Migrations
    • API Keys
  • Data Sources
    • PostgreSQL
    • MySQL
    • MongoDB
  • Guides
    • Provisioning Cloud Databases for using with Neurelo
      • PostgreSQL
        • AWS RDS (PostgreSQL)
      • MySQL
        • AWS RDS (MySQL)
      • MongoDB Atlas
    • Mock Data Generation
    • Wipe Data Source
    • Remote Git Repository for Definitions
      • Connecting a Remote Git Repo
      • Creating Commits from Neurelo
      • Syncing Branches
    • Data Viewer
    • Environment/Data Source Tags
    • How to work with Embedded documents and References in MongoDB
    • How to download and use the Postman Collection for your Project
    • Building Python applications with Postgres and FastAPI
    • CI Integration using Neurelo CLI
    • Schema Migrations
    • Schema AI Assist
    • Auto-Introspection
    • Access Policies
    • User Auth
      • Google
      • GitHub
      • GitLab
    • MongoDB Atlas - Migrate GraphQL to Neurelo
    • MongoDB Atlas - Migrate REST Data APIs to Neurelo
  • MongoDB Atlas - Migrate REST Data APIs to Neurelo
  • MongoDB Atlas - Migrate GraphQL APIs to Neurelo
  • Neurelo Schema Language (NSL)
    • Example 1 - DVD Rentals
    • Example 2 - Simple "Posts" App
    • Example 3 - Bookstore
  • Neurelo API Reference (REST)
    • Examples of Neurelo Auto-Generated REST API endpoints
      • Example 1 - Simple “Posts” application
      • Example 2 - "DVD Rentals" application
      • Example 3 - "Bookstore” application
      • cURL API Examples
  • Neurelo API Reference (GraphQL)
  • SDKs
    • TypeScript / JavaScript SDK
    • Go SDK
    • Python SDK
      • Python SDK Tutorial -- News Application
        • News Application using Neurelo’s Python SDKs
  • CLI (Preview Version)
  • Self-Hosted Neurelo Gateways
  • Tutorials
    • Building a Real Time Chat Application with Neurelo and MongoDB using Python
    • Building A Financial Terminal with Neurelo and MongoDB in Rust
    • Building a Restaurant Management System with Neurelo and MongoDB using GraphQL in just a few minutes
    • Bringing Neurelo’s Data APIs to Life Instantly with MySQL
  • Project Examples
  • References
    • Supported Databases
    • Supported OS and Browsers
  • Support
Powered by GitBook
On this page
  • Overview
  • Creating a Machine User
  • Using the machine user in the CLI
  • Using the CLI for CI tests
  • Sample Script
  1. Guides

CI Integration using Neurelo CLI

PreviousBuilding Python applications with Postgres and FastAPINextSchema Migrations

Last updated 10 months ago

Overview

Testing is a critical step in the software development lifecycle. 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

  • 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

Using the machine user in the CLI

Before running the CLI,

  • Setup environment variables NEURELO_CLIENT_ID and NEURELO_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

neurelo ci start --projectId=.. --commitId=.. --region=.. --connectionString=.. --runId=.. --resetDb

which will do multiple things:

  • Use the project configured with the --projectId= value

  • Create a Data Source pointing to the provided --connectionString= value

  • Create an Environment using the provided --region= and --commitId= values and attaching the previously created Data Source to it

  • Create 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 similar

  • The --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:

#####################################################
#                    SET UP                         #
#####################################################

NEURELO_CLIENT_ID=3cf50a07...
NEURELO_CLIENT_SECRET=jj2h...

NEURELO_PROJECT_ID=prj_613d3826...
NEURELO_COMMIT_ID=cmt_e020f328...
DS_CONN_STRING=postgres://user:pass@psqlinstance:5432/cli
CI_IDENTIFIER=my-unique-identifier

neurelo login

ci_start_output=$(neurelo ci start --projectId=$NEURELO_PROJECT_ID --commitId=$NEURELO_COMMIT_ID --region=us-west-2 --connectionString=$DS_CONN_STRING --runId=$CI_IDENTIFIER)

NEURELO_API_KEY=$(echo $ci_start_output | grep 'Key: neurelo_' | cut -d ' ' -f 2| cut -b 1-245)

#####################################################
#                    RUN TESTS                      #
#####################################################

npm run test

#####################################################
#                   TEAR DOWN                       #
#####################################################

neurelo ci stop
Neurelo CLI
Org members page
here