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:
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.-
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
-
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:
-
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
-
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 ofruby
to 3.0.2.neetoci-version
supportsruby
andnode
. -
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
supportsruby
andredis
. -
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. -
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
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.
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