{{announcement.body}}
{{announcement.title}}

DevOps Your Skill

DZone 's Guide to

DevOps Your Skill

In this article, we discuss how create a full-blown CI/CD pipeline to enhance your Alexa Skill development.

· DevOps Zone ·
Free Resource

"DevOps is the union of people, process, and products to enable continuous delivery of value to our end users." - Donovan Brown, Microsoft

DevOps is a "culture", which has a set of practices that combine software development (Dev) and information-technology operations (Ops), which aims to shorten the systems development life cycle and provide continuous delivery with high software quality. DevOps culture develops "production-first mindset". In terms of Alexa, DevOps can help us to quickly ship the highest quality of our Skill to the end customers. 

This post contains materials from different resources that can be seen on Resources section.

Prerequisites

Here you have the technologies used in this project

  1. Amazon Developer Account — How to get it.
  2. AWS Account — Sign up here for free.
  3. ASK CLI — Install and configure ASK CLI.
  4. CircleCI Account — Sign up here.
  5. Visual Studio Code.

The Alexa Skills Kit Command Line Interface (ASK CLI) is a tool for you to manage your Alexa skills and related resources, such as AWS Lambda functions. With ASK CLI, you have access to the Skill Management API, which allows you to manage Alexa skills programmatically from the command line. If you want how to create your Skill with the ASK CLI, please follow the first step explained in my Node.js Skill sample. We are going to use this powerful tool to do some steps in our pipeline. 

Let's DevOps!

Dockerfile

Before explaining the pipeline, it is important to explain the Docker image we are going to use in this pipeline. You can find all the explanations in this post.

Pipeline

Before explaining the pipeline, it is worth noting the common part of the pipeline, the executor. An executor defines the underlying technology or environment in which to run a job. Set up your jobs to run in Docker, a machine, macOS, or Windows executor and specify an image with the tools and packages you need. In our case, we will use a docker executor using the docker image explained above:

YAML
 




xxxxxxxxxx
1


 
1
  executors:
2
    ask-executor:
3
      docker:
4
        - image: xavidop/alexa-ask-aws-cli:1.0



Let's explain job-by-job what is happening in our powerful pipeline. First of all, each box represented in the image above is a job, and they will be defined below the job node in the CircleCI configuration file:

Checkout

The checkout job will execute the following tasks:

  1. Check out the code in /home/node/project
  2. Bring execution permission to node user to be able to execute all the hooks.
  3. Persist the code in order to reuse it in the next job.
YAML
 




xxxxxxxxxx
1


 
1
  checkout:
2
    executor: ask-executor
3
    steps:
4
      - checkout
5
      - run: chmod +x -R ./hooks
6
      - persist_to_workspace:
7
          root: /home/node/
8
          paths:
9
            - project



Build

The build job will execute the following tasks:

  1. Restore the code that we have downloaded in the previous step in /home/node/project folder.
  2. Run npm install in order to download all the Node.js dependencies.
  3. Persist again the code that we will reuse in the next job.
YAML
 




xxxxxxxxxx
1
11


 
1
  build:
2
    executor: ask-executor
3
    steps:
4
      - attach_workspace:
5
          at: /home/node/
6
      - run: ls -la
7
      - run: cd lambda/custom && npm install
8
      - persist_to_workspace:
9
          root: /home/node/
10
          paths:
11
            - project



Pretests

The pretest job will execute the static code quality check. Check the full explanation here.


Unit Tests

The test job will execute the unit tests. Check the full explanation here.


Code Coverage

The codecov job will execute the code coverage report. Check the full explanation here.


Deploy

The deploy job will deploy the Alexa Skill to the Alexa cloud in the development stage. Check the full explanation here.


Testing the Voice User Interface

These jobs will check our interaction model. Check the full explanation here.


Integration tests

These jobs will check the interaction model and our backend as well. Check the full explanation here.


End to end tests

These jobs will check the full system using the voice as input. Check the full explanation here.


Validation tests

These jobs will validate your Alexa Skill before submitting it to certification. Check the full explanation here.


Store-Artifacts

The store-artifacts job will execute the following tasks:

  1. Restore the code that we have used in the previous step in /home/node/project folder.
  2. Clean node_modules folder.
  3. Store the entire code of our Alexa Skill as an artifact. It will be accessible in CircleCI whenever we want to check it out.
YAML
 




xxxxxxxxxx
1


 
1
  store-artifacts:
2
    executor: ask-executor
3
    steps:
4
      - attach_workspace:
5
          at: /home/node/
6
      - run: ls -la
7
      - run: rm -rf lambda/custom/node_modules
8
      - store_artifacts:
9
          path: ./


Wait for Approval

For times when you'd prefer to keep manual approvals in place, easily configure the manual approval process by adding to your workflow a special job containing a type: approvalentry. This job it is needed in order to check whatever you want of your Alexa Skill before submitting it to certification and when everything is checked, you can approve or decline the execution.

This job is a different job that only exists down the workflows node in the config file. It is not needed to add it as a job.


YAML
 




x


1
  - wait-for-decision:
2
      type: approval
3
      requires:
4
        - store-artifacts



Submit

These jobs will submit your Alexa Skill to certification. Check the full explanation here.


Workflow

At the end of the CircleCi configuration file, we will define our pipeline as a CircleCI Workflow, which will execute the jobs explained above:

YAML
 







The CircleCI configuration file is located in .circleci/config.yml.

Resources

Conclusion

This is the first step to know how to DevOps your Alexa Skills using CircleCI. As you have seen in this example, the Alexa Tools like ASK CLI can help us a lot.

I hope this example project is useful to you.

That’s all, folks!  

You can find the code in my GitHub.

I hope it will be useful! If you have any doubts or questions, do not hesitate to contact me or put a comment below.

Happy coding!

Topics:
alexa, alexa skill, alexa skill development, alexa skills, alexa skills developer, alexa skills development, circleci, devops, docker, pipeline

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}