Giter Club home page Giter Club logo

now-pipeline's Introduction

now-pipeline

Single CI command to deploy new code to Zeit Now Includes e2e tests and the alias switch

NPM

Build status semantic-release js-standard-style first-timers-only next-update-travis badge

First time contributors

This repo is first time OSS contributor friendly. See these issues to contribute in meaningful way.

What and why

I am super excited about Zeit Now tool; this is the "missing CI tool" for it. A single command now-pipeline

  • deploys new version
  • tests it
  • switches alias to the new deployment
  • takes down the old deployment

Should be enough to automatically update the server or service running in the cloud without breaking anything.

Install and use

npm i -g now-pipeline

Set NOW_TOKEN CI environment variable with a token that you can get from Zeit account page

Add CI command to now-pipeline. By default it will execute npm test and will pass the deployed url as NOW_URL environment variable. You can customize everything.

Example

Simple Travis commands

script:
  # after unit tests
  - npm i -g now-pipeline
  - now-pipeline

Prune existing deploys (if they do not have an alias) and show the deploy.

script:
  - npm i -g now-pipeline
  - now-pipeline-prune
  - now-pipeline
  - now-pipeline-list

Set domain alias if there is no existing one

script:
  - npm i -g now-pipeline
  - now-pipeline --alias foo.domain.com

Pass in path to be used as deploy directory

script:
  - npm i -g now-pipeline
  - now-pipeline --dir your/directory

Pass test command and name of the environment variable for deployed url

script:
  - npm i -g now-pipeline
  - now-pipeline --as HOST --test "npm run e2e"

Example projects

Additional bin commands

  • now-pipeline-list - see the current deploys for the current project
  • now-pipeline-prune - remove all non-aliased deploys for the current project

You can pass custom test command to the pipeline to be used after deploying fresh install using --test "command" argument. The command will get NOW_URL environment variable with new install. For example

npm i -g now-pipeline
now-pipeline --test "npm run prod-test"

where the package.json has

{
  "scripts": {
    "prod-test": "e2e-test $NOW_URL"
  }
}

Debugging

You can see verbose log messages by running this tool with environment variable DEBUG=now-pipeline

Details

t="$(npm pack .)"; wc -c "${t}"; tar tvf "${t}"; rm "${t}"
  • file .npmignore is considered an optional file

Related

  • next-update is a similar "if tests pass, upgrade" tool for your NPM dependencies.

Small print

Author: Gleb Bahmutov <[email protected]> ยฉ 2016

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2016 Gleb Bahmutov <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

now-pipeline's People

Contributors

bahmutov avatar wulfmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

now-pipeline's Issues

Cannot deploy using API

$ NOW_AUTH=<token> node src/index.js 
deploying files [ '/now-pipeline/test/package.json',
  '/now-pipeline/test/index.js' ]
{ 'index.js': 'const port = process.env.PORT || 6000\nrequire(\'http\').Server((req, res) => {\n  res.setHeader("Content-Type", "text/plain; charset=utf-8");\n  res.end(require("sign-bunny")("Hi there!"));\n}).listen(port);\nconsole.log(\'listening on port\', port)\n',
  package: 
   { name: 'now-pipeline-test',
     dependencies: { 'sign-bunny': '1.0.0' },
     scripts: { start: 'node index.js' } } }
error
{ err: 
   { code: 'internal_server_error',
     url: 'https://zeit.co/errors/internal_server_error',
     message: 'An unexpected error occurred' } }

Add shutdown bin command

Or a flag --everything to prune? To shutdown every deploy for a project and remove the aliases

skip test

Hi!
Is there any way to skip the test step of now-pipeline and just use deploy/alias/prune?

Error: cannot find file .npmignore

Trying to use now-pipeline and get:

Something went wrong
Sometimes restarting pipeline can help
Error: cannot find file .npmignore
at lazyAssLogic (/usr/local/lib/node_modules/now-pipeline/node_modules/lazy-ass/index.js:110:14)
at lazyAss (/usr/local/lib/node_modules/now-pipeline/node_modules/lazy-ass/index.js:115:28)
at filenames.forEach.name (/usr/local/lib/node_modules/now-pipeline/src/index.js:118:9)
at Array.forEach (native)
at deploy (/usr/local/lib/node_modules/now-pipeline/src/index.js:117:17)

per now doc (https://zeit.co/docs/features/now-cli#selecting-files-and-directories-to-be-uploaded) .npmignore file is optional. Please advise.

Support "BUILDING" state

Current deploys have state BUILDING which right now causes an error

$ now-pipeline --test "cypress run --config baseUrl=$NOW_URL"
BOOTED todomvc-swtllwnzbh.now.sh limit 600 seconds
BOOTED todomvc-swtllwnzbh.now.sh limit 595 seconds
BOOTED todomvc-swtllwnzbh.now.sh limit 590 seconds
BUILDING todomvc-swtllwnzbh.now.sh limit 585 seconds
error during deployment
Something went wrong with the deploy
{"uid":"EJjhnjS1PeV5BoFpitOXCWV8","host":"todomvc-swtllwnzbh.now.sh","state":"BUILDING","stateTs":"2017-05-26T16:32:15.245Z","scale":{"min":0,"max":1,"auto":true}}
Something went wrong
Sometimes restarting pipeline can help
Error: Something went wrong with the deploy
{"uid":"EJjhnjS1PeV5BoFpitOXCWV8","host":"todomvc-swtllwnzbh.now.sh","state":"BUILDING","stateTs":"2017-05-26T16:32:15.245Z","scale":{"min":0,"max":1,"auto":true}}
    at checkDeploy.then.r (/usr/local/lib/node_modules/now-pipeline/src/index.js:77:15)
    at process._tickCallback (internal/process/next_tick.js:109:7)

When doing list of deploys handle scale property

Will prune deploys
-------------------------------------------------------------------------------------------------------------------
uid                       name     url                        created        state   type  scale            when   
------------------------  -------  -------------------------  -------------  ------  ----  ---------------  -------
tLjU85YDyy3s9BCqOD0EM8BG  todomvc  todomvc-rclscjhvff.now.sh  1495812641963  FROZEN  NPM   [object Object]  3 hours
hpV4gyrtlosweBtUmJDPYJoZ  todomvc  todomvc-ghjikbacda.now.sh  1495813240535  FROZEN  NPM   [object Object]  3 hours
I2JOUOcWTynJI7cIkCjE5HdP  todomvc  todomvc-jodtvxbtuh.now.sh  1495813416951  FROZEN  NPM   [object Object]  3 hours

Detail on configuration

Hi @bahmutov,

Thank so much for this, I was hoping to find something for CI so I didn't have to install Ruby, now-pipeline appears to be it ๐Ÿ˜€๐Ÿ‘

I'm still pretty noob when it comes to this sort of thing so was wondering if you could explain/give a bit more detail on set up.

I have installed npm i -g now-pipeline on my machine, I'm guessing now at the time of writing this that there's probably not much use in that if the package is being installed on Travis ๐Ÿ™ƒ

I have my blog which I'd like to set up for use with Travis, so I've enabled it on Travis CI and added in the new environment variable from my Zeit dashboard

image

Then I've set up my .travis.yml with some of the examples from your README.md now I thought I could run now-pipeline from my terminal, but I'm guessing it happens on Travis, right?

now-pipeline doesn't deploy to now

Tried just over 70 builds now with this, not one has resulted in something being pushed to now

If you take a look at the latest build here you can see that it was successful but doing a now ls doesn't show anything as being deployed.

I have tried using a new token, tried with and without cache, tried installing specific versions and nothing seems to be working.

Here is the .travis.yaml I'm using:

sudo: false

language: node_js

cache:
  directories:
    - node_modules

notifications:
  email: false

node_js:
  - '9'

before_script:
  - npm prune

script:
  - npm run build
  - cd public
  - npm i -g [email protected]
  - now-pipeline

  # - now-pipeline-list
  # - now-pipeline --alias scottspence.now.sh

after_success:
  # - ls -la

I'm changing dir to public as using the --dir arg doesn't seem to work either.

Let me know if there's anything else you need from me, I'm going to try this with another project just to make sure it's nothing specifically relating to Gatsby

Thanks

Specify folder to use

Hi, I'm using the - DEBUG=now-pipeline now-pipeline script trying to get to grips with this tool

From the output here:

Mon, 08 Jan 2018 09:19:36 GMT now-pipeline [ 'package.json',
  '.npmignore',
  'README.md',
  'LICENSE',
  'gatsby-config.js',
  'gatsby-browser.js',
  'gatsby-node.js',
  'gatsby-ssr.js',
  '.travis.yml',
  'src/layouts/index.js',
  'src/layouts/components/Button.js',
  ....

I'm still not completely clear on what the command now-pipeline does, because the output appears to be reading from the root of the project and I want to only deploy the public folder in my Gatsby project I'm cd'ing to that folder then running the now-pipeline command and getting errors because there's no package.json ๐Ÿคทโ€โ™‚๏ธ

There shouldn't be a package.json it's a static site, does that need to be configured as well?

It's not the clearest on how to use, even with the README.md

Seems not every error path is handled

Sometimes fresh deploy just exits after sending the now client the deploy command.
The problem could be in the now client. Work around is just restarting the deploy again.

Add a test project

To make sure this project is still working - the now-client is seriously behind.

Maybe even use semantic-action to only deploy if there is a meaningful change

Add "prune" method

Should delete all deployments for the current project that do not have an alias

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.