Skip to content

Commit

Permalink
Merge pull request #35 from navarasu/fix_28_document_exclude_test_dev…
Browse files Browse the repository at this point in the history
…_gem

#28 Added document and test case for exclude test development gems
  • Loading branch information
navarasu authored Dec 23, 2020
2 parents f647df1 + 438b71f commit 63fcd59
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 14 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) [![npm](https://img.shields.io/npm/v/serverless-ruby-layer.svg)](https://www.npmjs.com/package/serverless-ruby-layer) [![Build Status](https://img.shields.io/circleci/build/github/navarasu/serverless-ruby-layer)](https://circleci.com/gh/navarasu/serverless-ruby-layer) [![Coverage Status](https://coveralls.io/repos/github/navarasu/serverless-ruby-layer/badge.svg?branch=master)](https://coveralls.io/github/navarasu/serverless-ruby-layer?branch=master) [![MIT License](https://img.shields.io/npm/l/serverless-ruby-layer)](https://github.com/navarasu/serverless-ruby-layer/blob/master/LICENSE)

A Serverless Plugin to bundle ruby gems from Gemfile and deploy it to the lambda layer automatically while running `serverless deploy`.
A Serverless Plugin which bundles ruby gems from Gemfile and deploys them to the lambda layer automatically while running `serverless deploy`.

It auto-configures the AWS lambda layer and RUBY_PATH to all the functions.

Expand Down Expand Up @@ -71,18 +71,18 @@ custom:
use_docker: true
```

For more details, refer the docs [here](https://navarasu.github.io/serverless-ruby-layer/#/configuration)
For more detailse refer the docs [here](https://navarasu.github.io/serverless-ruby-layer/#/configuration)


## Usage

Using the custom configuration, the plugin can be utilized for below cases,
* Using locallly installed bundler for gems which native extensions - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/basic) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_local_bundler)
* Using Docker for gems with OS native C extensions or system libraries like `http`, `Nokogiri` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker)
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker_with_yums) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_with_yums)
* Using Dockerfile for gems which with other OS Linux image or system libraries and utilities - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker_file) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_file)
* Include / Exclude specific functions from layer configuration - [Include Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/include_functions) , [Exclude Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/exclude_functions) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/include_exclude)

* Using locally installed bundler for gems without any native extensions - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/basic) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_local_bundler)
* Using Docker for gems with OS native C extensions or system libraries like `http`, `Nokogiri` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use-docker)
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker_with_yums) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use-docker-with-yums)
* Using Dockerfile for gems which with other OS Linux image or system libraries and utilities - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use-docker-file) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/use_docker_file)
* Include / Exclude specific functions from layer configuration - [Include Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/include-functions) , [Exclude Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/exclude-functions) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/include_exclude)
* Exclude test and development related gems from layer - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/exclude-dev-test-gems) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/exclude_dev_test_gems)

## Contributing

Expand All @@ -94,4 +94,4 @@ Refer [Guidelines](https://github.com/navarasu/serverless-ruby-layer/blob/master

## License

[MIT](https://choosealicense.com/licenses/mit/)
[MIT](https://choosealicense.com/licenses/mit/)
3 changes: 2 additions & 1 deletion docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
* [Docker with Yums installed](use_docker_with_yums)
* [Using Custom Dockerfile](use_docker_file)
* [Include / Exclude functions](include_exclude)
* [Exclude test gems / development gems](exclude_dev_test_gems)
* [Configuration](/configuration.md)
* [Release Notes](/release_notes.md)
* [Release Notes](/release_notes.md)
3 changes: 2 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
'/use_docker': '/usage_examples/use_docker',
'/use_docker_with_yums': '/usage_examples/use_docker_with_yums',
'/use_docker_file': '/usage_examples/use_docker_file',
'/include_exclude': '/usage_examples/include_exclude'
'/include_exclude': '/usage_examples/include_exclude',
'/exclude_dev_test_gems': '/usage_examples/exclude_dev_test_gems'
},
search: {
noData: {
Expand Down
30 changes: 29 additions & 1 deletion docs/release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Release notes

### [1.4.0](https://www.npmjs.com/package/serverless-ruby-layer/v/1.4.0)
### Docker Inside Docker Release
* Replaced docker volume mount with docker cp to support CI (Docker inside Docker) environment.
* Handled the bundle flag deprecated for bundler version greater than 2.1
* Added docker related test case to run in circle-ci
* Improved test coverage to 88 %
* Documented exclude test and development gem example

### [1.3.0](https://www.npmjs.com/package/serverless-ruby-layer/v/1.3.0)
#### Specify Functions Release
* Option to include / exlude functions from attaching layers
* To reduce layer zip size, the gem cache files are excluded in zipping than removing it from the bundle folder
(To avoid unnecessary error while removing and also for upcoming reuse gem options)

### [1.2.1](https://www.npmjs.com/package/serverless-ruby-layer/v/1.2.0)
#### Validated Release
* Fixed issue in removing Cache dir #17
* Handled all edge-case errors and thrown user informative message
* Added logs message for future issue debugging
* Added issue template with necessary details

### [1.2.0](https://www.npmjs.com/package/serverless-ruby-layer/v/1.2.0)
#### Native Libs Release
* Specify yums to be preinstalled before doing a bundle install for gems with os native extension like pg, mysql.
* Pack and Deploy native library files to the lambda layer along with gems. for e.g to pack /usr/lib64/libpq.so.5 file for pg.
* Use docker file to specify custom installation and configuration
* Added docs and examples

### [1.1.0](https://www.npmjs.com/package/serverless-ruby-layer/v/1.1.0)
#### Use-Docker Release
* Added option to use docker to bundle gem with os specific C extensions
Expand All @@ -12,4 +40,4 @@
#### First Release
* Auto deploy the gems to AWS layer while doing serverless deploy
* Also configure the layer to make the gem available to all functions declared in the serverless.yml
* Uses local bundler to install the gem
* Uses local bundler to install the gem
54 changes: 54 additions & 0 deletions docs/usage_examples/exclude_dev_test_gems.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

## Exclude test and development related gems

<!-- tabs:start -->

#### ** Gemfile **

```ruby
source 'https://rubygems.org'
gem 'httparty'

group :development do
gem 'rubocop'
end

group :test do
gem 'rspec'
end

```

#### ** serverless.yml **

```yml
service: basic

plugins:
- serverless-ruby-layer

provider:
name: aws
runtime: ruby2.5

functions:
hello:
handler: handler.hello
```
#### ** handler.rb **
```ruby
require 'httparty'

def hello(event:, context:)
body = HTTParty.get("https://github.com").body

{ statusCode: 200, body: body }
end

```

<!-- tabs:end -->
Running `sls deploy` automatically deploys the required gems as in Gemfile by excluding the test and development related gems by default to AWS lambda layer

2 changes: 1 addition & 1 deletion docs/usage_examples/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Using the custom configuration, the plugin can be utilized for below cases,
* Using Docker for gems with C extensions or system libraries like `http`, `Nokogiri` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker) - [Docs](use_docker)
* Preinstall OS packages (yum packages) for gems which requires OS native system libraries like `pg`, `mysql`, `RMagick` - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker_with_yums) - [Docs](use_docker_with_yums)
* Using Dockerfile for gems which requires other system libraries and configuration - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/use_docker_file) - [Docs](use_docker_file)

* Exclude test and development related gems from layer - [Example](https://github.com/navarasu/serverless-ruby-layer/blob/master/examples/exclude-dev-test-gems) - [Docs](https://navarasu.github.io/serverless-ruby-layer/#/exclude_dev_test_gems)
10 changes: 10 additions & 0 deletions examples/exclude-dev-test-gems/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'
gem 'httparty'

group :development do
gem 'rubocop'
end

group :test do
gem 'rspec'
end
7 changes: 7 additions & 0 deletions examples/exclude-dev-test-gems/handler.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'httparty'

def hello(event:, context:)
body = HTTParty.get("https://github.com").body

{ statusCode: 200, body: body }
end
12 changes: 12 additions & 0 deletions examples/exclude-dev-test-gems/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
service: exclude-dev-test-gems

plugins:
- serverless-ruby-layer

provider:
name: aws
runtime: ruby2.5

functions:
hello:
handler: handler.hello
7 changes: 6 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ let test_data = [
{folder: 'exclude-functions', gem_zip_dirs: ['/','/bin/','/build_info/','/doc/','/extensions/', '/gems/',
'/specifications/','/gems/httparty/', '/gems/mime-types-data/', '/gems/multi_xml/', '/gems/mime-types/'],
function_files: ['handler1.rb', 'handler2.rb', 'handler3.rb'], include_functions: ['Hello1', 'Hello2'],
exclude_functions: ['Hello3']}
exclude_functions: ['Hello3']},

{ folder: 'exclude-dev-test-gems', gem_zip_dirs: ['/','/bin/','/build_info/','/doc/','/extensions/', '/gems/',
'/specifications/','/gems/httparty/', '/gems/mime-types-data/', '/gems/multi_xml/', '/gems/mime-types/'],
function_files: ['handler.rb'], include_functions: ['Hello'], exclude_functions:[] },

]

describe('serverless package', function () {
Expand Down

0 comments on commit 63fcd59

Please sign in to comment.