/lovable-issues

Adding CI/CD Workflows for Lovable Projects

Explore manual CI/CD workflows for lovable projects: learn why they matter, build pipelines, and apply best practices.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

Why CI/CD Workflows Must Be Manually Configured for Lovable

 
Understanding the Importance of Manual Configuration
 

This approach means that, instead of relying on generic, one-size-fits-all pipelines set up automatically, developers create a unique process that fits the project’s exact needs. In a manually configured CI/CD workflow, every step—from testing to deployment—is carefully selected and defined according to the specific characteristics of the project, ensuring that the final product feels “lovable” because it has been fine-tuned over time.

 
Enhanced Flexibility and Customization
 

When workflows are manually configured, it gives the team the power to adjust processes as the software evolves. This flexibility is key because every project has its quirks, and pre-built pipelines might force developers into a rigid structure. With manual configuration, they can include custom rules, tailor tests, and decide the order of operations to match what the project truly needs. This customization often leads to smoother releases and fewer surprises during deployment.

 
Complete Ownership and Transparency
 

Manual setup makes all the automated steps fully visible and understandable. Instead of having a “black box” where details are hidden, every part of the process is written explicitly in the configuration file. This visibility helps teams understand why a step might fail or take longer than expected, as the reasoning behind each command is laid out clearly.

 
Dealing with Unusual Scenarios
 

Each project may face unique challenges that automatic tools might not cover. Manual configuration allows for creating custom logic to handle these scenarios. For example, you might write a step in the pipeline that deals with particular dependencies or environment variables in a way that the generic setup would not support.

 
Example Configuration Snippet
 

  • This snippet shows a simplified version of a manually configured pipeline that defines the stages explicitly:
    
    stages:
    - lint
    - test
    - build
    - deploy
    
    

    lint_job:
    stage: lint
    script:
    - echo "Running code style checks"

    test_job:
    stage: test
    script:
    - echo "Executing unit tests"

    build_job:
    stage: build
    script:
    - echo "Building the application"

    deploy_job:
    stage: deploy
    script:
    - echo "Deploying to production"



  • This configuration is written by developers to match the specific actions required during each phase of their project, rather than using a preset template that may not align with their workflow.

 
Adaptability to Project Evolution
 

As a project grows or changes direction, a manually configured CI/CD pipeline can be adjusted to meet new requirements. Instead of being stuck with outdated tasks or unsuitable automation steps, the team maintains control over their tools. This adaptability is often the secret behind delivering updates that feel thoughtful and maintain a high level of quality.

How to Build CI/CD Pipelines for Lovable Projects

 
Creating Your CI/CD Pipeline Configuration File
 

  • In the Lovable code editor, create a new file in your project’s root directory named lovable-ci.yml.
  • This file will tell Lovable how to build, test, and deploy your project automatically.
  • Paste the following code into lovable-ci.yml:
    • 
      version: "1.0"
      
      

      steps:

      • name: "Install Dependencies"

        Since Lovable does not have a terminal, we add the dependency instructions here.

        run: |
        # To install dependencies, ensure you have a file named 'requirements.txt' in your project root.
        # Lovable will read this file to know which packages to install.
        pip install -r requirements.txt

      • name: "Run Tests"

        This step runs your tests to ensure everything works.

        run: |
        # Lovable looks for a test file named 'test_app.py' in the 'tests' folder.
        pytest tests/test_app.py

      • name: "Deploy"

        This is where deployment commands go.

        run: |
        # Replace the command below with your actual deployment commands.
        echo "Deploying your lovable project..."

  • Make sure you save the file. This configuration file sets the entire pipeline for your project.

 
Adding Dependencies Configuration
 

  • Create a file called requirements.txt in the project root if you don’t already have one.
  • Add the names of the libraries your project needs. For example, if you are using Flask and pytest, your file might look like:
    • 
      Flask
      pytest
            
  • This file allows Lovable to know what packages to install automatically during the "Install Dependencies" step.

 
Setting Up Your Test File
 

  • In your project’s file structure, create a folder named tests (if it does not exist already).
  • Inside the tests folder, create a new file called test\_app.py.
  • Insert the following simple test code into test\_app.py to serve as an example test:
    • 
      def test_basic_functionality():
          # This test checks that basic arithmetic works as expected.
          assert 1 + 1 == 2
            
  • This file is referenced in part of the CI/CD pipeline for running tests.

 
Linking CI/CD Pipeline with Lovable
 

  • Lovable automatically detects the lovable-ci.yml file in your project’s root directory.
  • When you push changes to your project, Lovable will read this file and follow the steps to install dependencies, run tests, and deploy your project.
  • No extra terminal commands are required; all instructions are embedded in the files you created.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Best Practices for Adding CI/CD to Lovable Projects

 
Creating the CI/CD Workflow File
 

  • Inside the project’s file structure, create a new folder called .github (if it doesn’t exist already). Within that folder, create another folder called workflows.
  • In the workflows folder, create a file named ci-cd.yml. This file defines the steps that your project will follow during Continuous Integration and Continuous Deployment.
  • Copy and paste the following code snippet into ci-cd.yml. This snippet sets up a basic pipeline that checks out your code, sets up a Python environment, installs dependencies, runs tests, and then triggers a deployment script.

name: CI/CD Pipeline

on:
  push:
    branches: [ main ]
  pull\_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Code
        uses: actions/checkout@v2

    - name: Set Up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'

    - name: Install Dependencies
        run: |
          python dependency\_manager.py

    - name: Run Tests
        run: |
          python -m pytest

    - name: Deploy Application
        run: |
          python deploy.py

 
Configuring Dependency Installation within Your Code
 

  • Because Lovable does not support terminal commands directly, add a dedicated script to handle installing dependencies.
  • Create a file named dependency\_manager.py in the root of your project.
  • Paste the code snippet below into dependency\_manager.py. This file checks if the required dependencies (listed in requirements.txt) are installed. If not, it installs them.

import subprocess

def install\_dependencies():
    try:
        # This command installs all packages listed in requirements.txt
        subprocess.check\_call(["pip", "install", "-r", "requirements.txt"])
        print("Dependencies installed successfully.")
    except Exception as error:
        print("Error installing dependencies:", error)

if **name** == "**main**":
    install\_dependencies()
  • Make sure you create a file named requirements.txt in your project root, and list all necessary libraries (for example, Flask, pytest, etc.).

 
Integrating Automated Tests
 

  • To ensure your project works correctly as changes are made, create automated tests.
  • Create a file called test\_app.py in your project directory. This file will contain simple tests to check the main functionalities.
  • Insert the following code into test\_app.py. The basic test provided always passes, but you can add more tests as needed.

def test\_example():
    # A simple test that always passes
    assert True, "This test is meant to pass"

if **name** == "**main**":
    test\_example()
    print("Tests executed successfully.")
  • The CI/CD configuration in ci-cd.yml calls these tests automatically during each build.

 
Setting Up Deployment
 

  • Deployment is the process where your project is moved to a live environment after passing all tests.
  • Create a new file called deploy.py in the project root.
  • Copy and paste the following code into deploy.py. This script simulates deployment. You can update it with your deployment logic (for example, copying files or triggering an API).

def deploy():
    try:
        # Insert your deployment logic here
        print("Deploying your application...")
        # For example, copying files or making API calls
        print("Deployment successful!")
    except Exception as error:
        print("Deployment failed:", error)

if **name** == "**main**":
    deploy()
  • The deployment step in ci-cd.yml executes deploy.py after tests pass, ensuring only tested code is deployed.

 
Adding Error Handling and Logging
 

  • For troubleshooting issues, add error handling and logging in your scripts to get more information about what went wrong.
  • Create or update a file called logger\_setup.py to include logging configurations.
  • Insert the following snippet into logger\_setup.py. This configuration enables your scripts to log errors and other helpful messages.

import logging

Configure logging to display messages in a simple format
logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s - %(levelname)s - %(message)s')

def get\_logger():
    return logging.getLogger()

if **name** == "**main**":
    logger = get\_logger()
    logger.info("Logger is set up and running.")
  • Make sure to import and use this logger in your other scripts (for example, dependency\_manager.py and deploy.py) to print useful debugging information.

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022