Skip to content

Commit 009b3a6

Browse files
Merge pull request #8 from fac/allow-specifying-developer-file
Allow specifying functions.yaml file when calling the deploy command
2 parents 911a8d0 + 7bdd607 commit 009b3a6

File tree

6 files changed

+64
-26
lines changed

6 files changed

+64
-26
lines changed

Gemfile.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
serverless-tools (0.0.3)
4+
serverless-tools (0.1.0)
55
aws-sdk-lambda
66
aws-sdk-s3
77
thor
@@ -11,46 +11,46 @@ GEM
1111
specs:
1212
ast (2.4.2)
1313
aws-eventstream (1.2.0)
14-
aws-partitions (1.547.0)
15-
aws-sdk-core (3.125.3)
14+
aws-partitions (1.557.0)
15+
aws-sdk-core (3.126.2)
1616
aws-eventstream (~> 1, >= 1.0.2)
1717
aws-partitions (~> 1, >= 1.525.0)
1818
aws-sigv4 (~> 1.1)
1919
jmespath (~> 1.0)
20-
aws-sdk-kms (1.53.0)
21-
aws-sdk-core (~> 3, >= 3.125.0)
20+
aws-sdk-kms (1.54.0)
21+
aws-sdk-core (~> 3, >= 3.126.0)
2222
aws-sigv4 (~> 1.1)
23-
aws-sdk-lambda (1.77.0)
24-
aws-sdk-core (~> 3, >= 3.125.0)
23+
aws-sdk-lambda (1.78.0)
24+
aws-sdk-core (~> 3, >= 3.126.0)
2525
aws-sigv4 (~> 1.1)
26-
aws-sdk-s3 (1.111.1)
27-
aws-sdk-core (~> 3, >= 3.125.0)
26+
aws-sdk-s3 (1.112.0)
27+
aws-sdk-core (~> 3, >= 3.126.0)
2828
aws-sdk-kms (~> 1)
2929
aws-sigv4 (~> 1.4)
3030
aws-sigv4 (1.4.0)
3131
aws-eventstream (~> 1, >= 1.0.2)
32-
jmespath (1.5.0)
32+
jmespath (1.6.0)
3333
minitest (5.15.0)
3434
mocha (1.13.0)
3535
parallel (1.21.0)
36-
parser (3.1.0.0)
36+
parser (3.1.1.0)
3737
ast (~> 2.4.1)
3838
power_assert (2.0.1)
3939
rainbow (3.1.1)
4040
rake (13.0.6)
41-
regexp_parser (2.2.0)
41+
regexp_parser (2.2.1)
4242
rexml (3.2.5)
43-
rubocop (1.24.1)
43+
rubocop (1.25.1)
4444
parallel (~> 1.10)
45-
parser (>= 3.0.0.0)
45+
parser (>= 3.1.0.0)
4646
rainbow (>= 2.2.2, < 4.0)
4747
regexp_parser (>= 1.8, < 3.0)
4848
rexml
4949
rubocop-ast (>= 1.15.1, < 2.0)
5050
ruby-progressbar (~> 1.7)
5151
unicode-display_width (>= 1.4.0, < 3.0)
52-
rubocop-ast (1.15.1)
53-
parser (>= 3.0.1.1)
52+
rubocop-ast (1.16.0)
53+
parser (>= 3.1.1.0)
5454
ruby-progressbar (1.11.0)
5555
test-unit (3.5.3)
5656
power_assert

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ The deployer takes 2 arguments:
3838
The deployer uses the current git HEAD for which sha to push and update.
3939

4040
```zsh
41-
serverless deploy build # Zips the file - assumes bundle install has been run and deps are in a vendor folder
42-
serverless deploy push # Push the zip(s) to S3
43-
serverless deploy update # Update the lambda function
41+
serverless-tools deploy build # Zips the file - assumes bundle install has been run and deps are in a vendor folder
42+
serverless-tools deploy push # Push the zip(s) to S3
43+
serverless-tools deploy update # Update the lambda function
4444
```
4545

4646
### Comment
@@ -49,7 +49,7 @@ The comment tool is intended to be used as a Github Action. It takes a json hash
4949
and prints a formatted string with the Github Action expression to set an output. This output can then used to comment in a Github Issue.
5050

5151
```zsh
52-
serverless comment -f '{"function_name": "Success"}'
52+
serverless-tools comment -f '{"function_name": "Success"}'
5353
```
5454
### Github Actions
5555

lib/serverless-tools/cli.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ def comment
1212
end
1313

1414
desc "deploy", "publishes and deploys the specified lambda functions"
15+
method_option :filename, :type => :string, :aliases => "-f"
1516
def deploy(action, function=nil)
16-
Deployer.deploy(action: action, function: function)
17+
Deployer.deploy(action: action, function: function, filename: options[:filename])
1718
end
1819
end
1920
end

lib/serverless-tools/deployer.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
module ServerlessTools
77
module Deployer
8-
CONFIG_FILE = ENV["GITHUB_WORKSPACE"] ? "#{ENV["GITHUB_WORKSPACE"]}/functions.yml" : "functions.yml"
9-
10-
def self.deploy(action:, function: nil)
8+
def self.deploy(action:, function: nil, filename: nil)
119
raise "Expected to receive action but action was empty" if action.nil? || action.empty?
1210

13-
config_loader = YamlConfigLoader.new(filename: CONFIG_FILE)
11+
config_loader = YamlConfigLoader.new(
12+
filename: filename.nil? ? "functions.yml" : filename
13+
)
1414

1515
lambdas_to_deploy = function ? [function] : config_loader.functions
1616

lib/serverless-tools/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ServerlessTools
2-
VERSION = "0.0.3"
2+
VERSION = "0.1.0"
33
end

test/deployer_test.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require "minitest/autorun"
2+
require "mocha/minitest"
3+
4+
require "serverless-tools/deployer"
5+
6+
module ServerlessTools
7+
describe "Deployer" do
8+
let(:deployer) { mock() }
9+
let(:config) { mock() }
10+
11+
let(:function) { "example_function_one_v1" }
12+
let(:filename) { "functions.yml" }
13+
14+
15+
describe "#deployer" do
16+
before do
17+
Deployer::YamlConfigLoader.stubs(:new).with(filename: filename).returns(config)
18+
Deployer::Deployer.stubs(:new).returns(deployer)
19+
20+
config.expects(:lambda_config).with(function_name: function)
21+
deployer.expects(:build)
22+
end
23+
24+
it "sends the action to the created deployer" do
25+
Deployer.deploy(action: "build", function: function)
26+
end
27+
28+
describe "when specifying a different config file" do
29+
let(:filename) { "dev.functions.yml" }
30+
31+
it "loads the correct file" do
32+
Deployer.deploy(action: "build", function: function, filename: filename)
33+
end
34+
end
35+
end
36+
end
37+
end

0 commit comments

Comments
 (0)