Giter Club home page Giter Club logo

netlify-travis-integration's Introduction

netlify-travis-integration Build Status codecov.io

Serverless glue proxy for calling Travis upon Netlify deployment.

netlify-travis-integration screenshot

Why?

Makes it easy to run e2e tests after Netlify deployment preview is generated.

How?

Typical workflow:

  1. Netlify deployment is triggered upon creating/updating pull request
  2. netlify-travis-integration is called after Netlify deployment
  3. netlify-travis-integration triggers a Travis build to perform e2e tests

netlify-travis-proxy sequence diagram

Getting started

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.

  1. Fork this repository.
  2. Setup Travis for your forked repository.
  3. 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
  1. Set the accurate IAM permissions, see aws-permissions.json.
  2. Trigger a Travis build on master branch.
  3. Verify that the deploy succeeds.
  4. Copy the travis-caller URL provided by serverless in the deploy stage and use it to add a Netlify deploy notification.
  5. Additionaly you can add support for GitHub statuses by adding the github-status URL to Travis notifications.

Target repo .travix.yml example

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

GitHub statuses

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`

Limitations

Works only for AWS for the moment. It's possible to configure the serverless.yml file to use other providers.

netlify-travis-integration's People

Contributors

kontrollanten avatar

Stargazers

Vladimir Skok avatar Andrejs Agejevs avatar Maxi Ferreira avatar Diego Nascimento avatar GAURAV avatar  avatar Mike Delucchi avatar

Watchers

James Cloos avatar  avatar

netlify-travis-integration's Issues

Create GH status when Travis is first triggered

Today the GH status for NTI i created when Travis starts to build, which can lead to an delay before the status i shown in the PR. Instead, create the status at the same time as Travis is triggered.

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.