Configure travis.yml

Let us define the flow of the desired build and test specifications in travis.yml. We will also install the required dependencies for the components of the application, such as node modules, through it.

As mentioned in the Introduction, the source code of Cat.ly that you downloaded will contain an already configured travis.yml file in it. Copy the file from it and paste it in the root folder of your Cat.ly’s project directory.

travis.yml will contain the following code:

    
travis.yml
copy
language: node_js node_js: - 8 install: - npm install -g zcatalyst-cli jobs: include: - stage: functions before_script: - cd functions/catly/server script: - echo 'function!!' - echo 'Installing Deps!' - npm install after_success: - echo 'deploying function!' - catalyst deploy --only functions --project 700000000045014 --verbose - stage: client script: - echo 'deploying client!!' - catalyst deploy --only client --project700000000045014 --verbose
View more
Note: Replace the Project ID on lines 17 and 21 with the Project ID of your project. You can obtain this by navigating to Settings -> General in your Catalyst console.

Let’s understand the code.

This YAML text file dictates the terms of the tasks to be performed at various stages. We can break the execution of the test specifications down in the following way:

  1. The first two lines of the YAML file specify the programming language and the version of the configuration.
  2. The install parameter specifies the npm command for installing Catalyst CLI as a global module.
  3. The tasks to be performed are defined under the jobs parameter. There are essentially two tasks to be performed: deploying the function and deploying the client. These are defined in two different stages. These stages work independently of each other, so even if the execution of one stage fails, the other can run and be successful.

Deploying the Advanced I/O function

Deploying the Advanced I/O function of the Cat.ly application is straightforward.

The process of installing the node modules and dependencies, and deploying the function is divided into three parts: before_script, script, and after_success in the function stage:

  • The before_script lists the task to be performed before executing the catalyst run-script command: navigating to the server folder inside the functions directory that contains the function’s code.

  • The script indicates the action to be executed while running the script: installing the npm package and dependencies inside the server folder.

  • The after_success specifies the command to be executed after the success of the script execution: deploy the function specifying the Project ID in the debug (–verbose) mode.


Deploying the client

The next stage in the process is to deploy the client component.

The script under the client stage specifies the catalyst deploy command to be executed. We specify the Project ID of the project and execute the command in the debug (–verbose) mode.

Note: As with all React apps, the client component must be compiled into a production-ready build before being deployed. The scripts configured in the catalyst.json file in the primary tutorial define the actions to be executed for that purpose, using yarn install and yarn build commands. A build folder then becomes the root folder of the client component, containing all the same application files, configuration files, and dependencies as the original client folder. The deploy command here deploys the contents of the build folder.

Last Updated 2023-12-15 18:54:08 +0530 +0530