Git Product home page Git Product logo

serverless-ci-cd's Introduction

Serverless CI/CD Tutorial

Building, testing, and deploying Serverless apps using CodeBuild and CodePipeline

This repo is the demo code for a three-part tutorial on managing unit testing, integration testing, and deployment of apps built using the Serverless framework.

To play with this code locally, clone this repo and do the following:

1. Install global npm modules

npm install -g serverless eslint jest

2. Install local npm modules

Navigate to the app directory, and run

npm install

3. Bring up the DB

sls dynamodb install --stage dev
sls dynamodb start --stage dev
sls dynamodb migrate --stage dev

This series of commands installs a local DynamoDB, starts it, and creates any tables specified in the serverless.yml. Check your shell at http://localhost:8000/shell/ to interact with the db and view the created table.

4. Start the offline app

sls offline start --stage dev

The app is now available at http://localhost:3000.

The app has two endpoints:

GET /todos

Returns a list of todos:

[
    {
        "id": "9b3c415f-ceaa-49e3-b5af-0e335bfd4635",
        "completed": false,
        "title": "do things!",
        "updatedAt": 1513817875660
    }
]

POST /todos

Accepts an object in this format:

{
	"title": "do things!",
	"completed": false
}

Returns a status of 200. The created object is not returned; you can see it with a GET /todos.

5. Run Tests

To run unit tests, use

npm test

To lint, use

npm run-script lint

To run integration tests, use

npm run-script integration

6. Make Changes

If you change the serverless.yml file, you'll need to restart your local app:

  • Stop the offline app; ctrl-c in the terminal where it's running is all you need. It's fine to leave the db running.
  • Uncomment the line in the serverless.yml file that says noStart: true. This will prevent serverless offline from trying to start a new database.
  • Run sls offline start --stage dev again.

Changes to any other file in the app (e.g. a handler) will be reflected immediately, and don't require a restart.

serverless-ci-cd's People

Contributors

stephanielingwood avatar jiravani avatar seyedk avatar

Stargazers

Summsitup.eth avatar Ankit Singh avatar Ciro Bessa avatar Oksana Tozhovez avatar Dmytro avatar Eriberto Lopez avatar gsk308 avatar Mike Ryan avatar Jeremy T. Bouse avatar Teresa M Knowles avatar DS avatar uuushiro avatar Ryan Sullivan avatar Chris Bell avatar Kevin Old avatar Roland Quast avatar Sagar avatar supaket wongkampoo avatar Denis Denisov avatar Petar Bojinov avatar Chew Chit Siang avatar Naeem avatar

Watchers

James Cloos avatar  avatar Sophia Hudson avatar  avatar  avatar Ankit Singh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.