Serverless glue proxy for calling Travis upon Netlify deployment.
Makes it easy to run e2e tests after Netlify deployment preview is generated.
Typical workflow:
- Netlify deployment is triggered upon creating/updating pull request
netlify-travis-integration
is called after Netlify deploymentnetlify-travis-integration
triggers a Travis build to perform e2e tests
You can deploy and manage netlify-travis-integration locally or which every CI environment you prefer, below is an example how to do it with Travis.
- Fork this repository.
- Setup Travis for your forked repository.
- Set the following env variables in your Travis Settings.
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
GITHUB_OAUTH_TOKEN
TARGET_REPO=username/repository-with-e2e-tests
TRAVIS_ACCESS_TOKEN
- Set the accurate IAM permissions, see
aws-permissions.json
. - Trigger a Travis build on master branch.
- Verify that the deploy succeeds.
- Copy the travis-caller URL provided by serverless in the deploy stage and use it to add a Netlify deploy notification.
- Additionaly you can add support for GitHub statuses by adding the github-status URL to Travis notifications.
Since Travis doesn't support reading env vars for conditional builds from the API call, we have to use type = api
for conditional checks.
- stage: lint
if: type != api
script: yarn lint
- stage: test
if: type != api
script: yarn test && codecov
- stage: e2e
if: type = api
script: yarn install-selenium && yarn e2e
By adding webhook notifications to your target repo .travis.yml you can create statuses for the corresponding git commit.
The webhook will search for stage e2e in the triggering build. If stage e2e isn't found, no status will be created.
notifications:
webhooks:
urls:
- https://fdyg78nn.execute-api.eu-west-1.amazonaws.com/dev/github-status # endpoint provided from *yarn deploy*
on_start: always # will create GH status `pending`
on_success: always # will create GH status `success`
on_failure: always # will create GH status `failure`
on_cancel: always # will create GH status `failure`
on_error: always # will create GH status `error`
Works only for AWS for the moment. It's possible to configure the serverless.yml file to use other providers.