Creating a Workflow

A workflow consists of commands that a CI job should run and the trigger event that should create that CI Job. To create a workflow, follow these steps:

  1. In your repository that is linked to a project in NeetoCI, create a new branch to add the workflow configurations, let's say add-neetoci-config. Then create a directory .neetoci in the root directory of your project.

  2. Any valid YAML file created inside the .neetoci directory will be considered as a workflow. To start off add the configuration version to your YAML file, as shown below.

    version: v1.0
  3. To add the commands that a CI job following this workflow needs to run, add global_job_config to the YAML file, as shown below.

    version: v1.0
    global_job_config:
  4. First, you need to provide the list of commands that sets up your project. This includes commands to clone your repository, install dependencies, create databases, etc.
    To clone your repository, you can simply use the checkout command. It will use your primary GitHub Account integrated with NeetoCI to clone the repository.

    version: v1.0
    global_job_config:
      setup:
        - checkout
  5. To change the default installed version of a programming language, you can use the Neetoci-version command, as shown below.

    version: v1.0
    global_job_config:
      setup:
        - checkout
        - neetoci-version ruby 3.0.2

    The command neetoci-version ruby 3.0.2 changes the version of ruby to 3.0.2. neetoci-version supports ruby and node .

  6. Similarly, you can also use the Neetoci-service command to start a database service.

    version: v1.0
    global_job_config:
      setup:
        - checkout
        - neetoci-version ruby 3.0.2
        - neetoci-service start redis 7.0.5

    The command neetoci-service start redis 7.0.5 starts a Redis server with version 7.0.5. neetoci-service supports ruby and redis.

  7. NeetoCI also supports caching your dependencies, so that subsequent CI Jobs are faster. For example, you can install your ruby gems and cache them as shown below.

    version: v1.0
    global_job_config:
      setup:
        - checkout
        - neetoci-version ruby 3.0.2
        - neetoci-service start redis 7.0.5
        - cache restore
        - bundle install --jobs 1
        - cache store

    The cache restore command restores any previous caches. The cache store command stores the cache. Using the commands in the order as shown above, ensures that the dependencies are cached on the first CI Job and that cache is used in subsequent CI Jobs. It also ensures that any changes made to the dependencies reflect in the cache.

  8. Next, you need to provide the remaining list of commands that are not related to setting up the project under global_job_config.jobs, as shown below.

    version: v1.0
    global_job_config:
      setup:
        - checkout
        - neetoci-version ruby 3.0.2
        - neetoci-service start redis 7.0.5
        - cache restore
        - bundle install --jobs 1
        - cache store
      jobs:
        - name: CiChecks
          commands:
            - bundle exec rspec
  9. Commit these changes and create a Pull Request to merge changes from this branch to the default branch. Since you have not specified any trigger for the workflow, a CI Job will be automatically created for this Pull Request using the workflow you just created.

  10. Since this workflow exists only the add-neetoci-config branch, CI Jobs will only be created for Pull Requests of that branch. Once the Pull Request is merged to the default, a CI Job will be created for subsequent commits of the default branch.

We have not mentioned a specific event at which the CI Job will be triggered here. This will be covered in another section.

Here's another example of a workflow using node :

version: v1.0
global_job_config:
  setup:
    - checkout
    - neetoci-version node 12
    - cache restore
    - npm install
    - cache store
  jobs:
    - name: CiChecks
      commands:
        - npm test

Can't find what you're looking for?