Skip to content

Commit

Permalink
update instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Jun 21, 2020
1 parent 17af96c commit 646b37c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ up:
layer-pact:
./local/scripts/build-pact.sh

layer-deploy:
cd layer && serverless deploy

local-lambda-curl:
./local/scripts/curlLambda.sh

Expand Down
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# serverless-pact

POC of using serverless alongside a pre-generated PACT contract file
A template project to allow the use of a pact stub service in combination with pre-generated PACT contract file, hosted inside a lambda function backed by API gateway.

- Accepts requests on any path via API gateway
- Spawns a pact-stub-server process and waits for it to start up
- Forwards any GET request to the pact stub server
- Forwards any http request to the pact stub server
- Sends response from pact stub server, to client

## Pre-Req

For local running, pact-stub-service must be available on your command line. (TODO - use the local version rather than requiring the user to install? - would we need to check platform)
Note:- Comment out the following to run locally. (TODO - stop this erroring depedant on stage)
For local running, pact-stub-service must be available on your command line.

you can download it here :-
[pact-ruby-standalone](https://github.com/pact-foundation/pact-ruby-standalone/releases)

Note:- Comment out the following to run locally in `serverless.yml`

```
layers:
- ${cf:pact-standalone-${self:provider.stage}.PactStandaloneLayerExport}
```


## Instructions
## Instructions to run locally

To run:

Expand All @@ -28,3 +31,11 @@ make local-pact-service
make local-lambda-curl
```

## Instructions to run in aws

1. Add you required pact file, as `pact.json` in the base of the repository
2. Run `make layer-pact` to build the pact standalone layer
3. Run `make layer-deploy` to deploy the pact-standalone layer
4. Run `serverless deploy` to deploy the service

Note:- Dont forget to uncomment the `layers` section in the `serverless.yml` when performing step 4.
2 changes: 1 addition & 1 deletion src/functions/utils/pact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const spawnPactServerAndWait = async (
if (errorMessage.includes('EADDRINUSE')){
return resolve({
started: true,
pactStubProcess: null,
pactStubProcess,
});
}
return reject(`Pact Stub Service: ${errorMessage}`);
Expand Down

0 comments on commit 646b37c

Please sign in to comment.