Coder Social home page Coder Social logo

usage in travis-ci about chandler HOT 17 CLOSED

mattbrictson avatar mattbrictson commented on July 17, 2024
usage in travis-ci

from chandler.

Comments (17)

mattbrictson avatar mattbrictson commented on July 17, 2024

Hi, thanks for the suggestion!

As currently designed, chandler relies on a ~/.netrc file to authenticate to GitHub. For a Travis CI build, I'm not sure if this is possible. I don't know enough about Travis to say whether you can do this in a way that does not expose the password or OAuth token.

However, assuming the netrc thing can be solved, then it should just be a matter of adding these commands to the build steps:

gem install chandler
chandler push

That will sync the release notes for all tags to GitHub.

If anyone wants to suggest a solution, feel free to open a PR for the README or add your comments here.

from chandler.

typekpb avatar typekpb commented on July 17, 2024

Thanks for response. Will give it a try and let you know.

On Sep 3, 2016 02:07, "Matt Brictson" [email protected] wrote:

Hi, thanks for the suggestion!

As currently designed, chandler relies on a ~/.netrc file to authenticate
to GitHub. For a Travis CI build, I'm not sure if this is possible. I don't
know enough about Travis to say whether you can do this in a way that does
not expose the password or OAuth token.

However, assuming the netrc thing can be solved, then it should just be a
matter of adding these commands to the build steps:

gem install chandler
chandler push

That will sync the release notes for all tags to GitHub.

If anyone wants to suggest a solution, feel free to open a PR for the
README or add your comments here.

β€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#14 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAegbPNckeREXNi6qf6avB2vJ3ouhWScks5qmLpLgaJpZM4JzrrB
.

from chandler.

orta avatar orta commented on July 17, 2024

In theory, this could use the deploy section on the travis.yml - which sets up the .netrc

Note that travis' deploy script is run on ruby 1.9.3 - so you may have to update, then gem install

from chandler.

orta avatar orta commented on July 17, 2024

Another option is to run it as a part of a GitHub Releases script, which I don't know enough about to give useful advice on, however you can run pre-release scripts ( and maybe the setup github token is accessible in the ENV during that stage? )

from chandler.

mattbrictson avatar mattbrictson commented on July 17, 2024

@orta Thanks for the tips and ideas!

@typekpb If you'd like to try this out, you could create a simple script and reference it in the deploy section of your travis.yml. The script would need to do this:

  • gem install chandler
  • Create a .netrc file so that it contains the desired GitHub username and OAuth token
  • chandler push $TRAVIS_TAG

Also, I'm guessing you'd probably only want the script to run when $TRAVIS_TAG is present.

TRAVIS_TAG: If the current build is for a git tag, this variable is set to the tag’s name.

You could store the OAuth token as an encrypted environment variable.

And, as @orta mentioned, you'll need to run the deploy script in a newer version of Ruby, since chandler requires Ruby 2.1+ and the default Ruby used by Travis is 1.9.3.

One way we could make this slightly simpler is if chandler could use environment variables for the GitHub credentials, and bypass the need to set up a .netrc file. Perhaps it could check for the presence of $GITHUB_USERNAME and $GITHUB_TOKEN or something like that.

Anyway, let me know if you get this working, and if you need my help to make any modifications to chandler itself. Thanks!

from chandler.

typekpb avatar typekpb commented on July 17, 2024

@mattbrictson @orta thanks a lot guys for your help!

I finally managed it. However it's been rather a painful process, let me document the steps required:

  1. relevant .travis.yml chunks (please note I'm using go with sudo: false, not sure about other setups):

    language: go
    sudo: false 
    ...
    before_deploy:
      # chandler needs ruby version >= 2.2 => install it via rvm (reuse travis installed one)
      - ruby -v && rvm install 2.3.1 && rvm use --default 2.3.1 && ruby -v
      - ./travis/before_deploy.sh
    
  2. ./travis/before_deploy.sh chunk:

    #!/bin/bash
    ...
    gem install --no-ri --no-rdoc chandler
    
    # setup credentials
    cp -f travis/.netrc ~/.netrc
    chmod 600 ~/.netrc
    sed -i.bak "s/###OAUTH_LOGIN###/${OAUTH_LOGIN}/" ~/.netrc
    sed -i.bak "s/###OAUTH_TOKEN###/${OAUTH_TOKEN}/" ~/.netrc
    
    chandler --changelog=$(pwd)/docs/CHANGELOG.md --github=foo/foo push
    
  3. ./travis/.netrc contents:

    machine api.github.com
      login ###OAUTH_LOGIN###
      password ###OAUTH_TOKEN###
    
  4. moreover I had to setup environment variables in the travis-ci, namely: OAUTH_LOGIN and OAUTH_TOKEN

Well, as you mentioned, it would be really nice, if we could skip ~/.netrc part and use env vars only. Any chance to use the secured ones directly in the .travis.yml (via: secure: ...) ? As I'm worried about getting them exposed somehow anyway in a way I use those.

from chandler.

orta avatar orta commented on July 17, 2024

Secured tokens would work - I have a branch that would work with it, but I'm finding it really hard to test my changes.

from chandler.

typekpb avatar typekpb commented on July 17, 2024

if you need a test volunteer, I'd be happy give it a try on my project, the only issue would be: how to install the version you're referring to on travis?

from chandler.

orta avatar orta commented on July 17, 2024

You'd have to use a Gemfile:

gem 'chandler', :git => "https://github.com/orta/chandler.git", :branch => "token"

pretty arduous

from chandler.

typekpb avatar typekpb commented on July 17, 2024

well, it's a golang project, but if you provide me with a steps, I'd be happy to (as I hope this could find it's way to official release)

from chandler.

orta avatar orta commented on July 17, 2024

Until it's shipped as a part of chandler, it's arguably more effort to do than what you have right now ( suddenly you have ruby dependency management to handle on-top of your usual bits ) - I'd recommend against it for this second

from chandler.

typekpb avatar typekpb commented on July 17, 2024

OK, thanks for info, will wait then.

On Wed, Sep 7, 2016 at 9:36 PM, Orta [email protected] wrote:

Until it's shipped as a part of chandler, it's arguably more effort to do
than what you have right now ( suddenly you have ruby dependency management
to handle on-top of your usual bits ) - I'd recommend against it for this
second

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#14 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAegbCyU1jSk11fkFPVJRFdRMtXfhtWYks5qnxI6gaJpZM4JzrrB
.

from chandler.

mattbrictson avatar mattbrictson commented on July 17, 2024

@orta Your branch is looking great so far! Is there any way I can help you get it ready to merge?

Perhaps to make testing easier, you could put the Octokit logic in Chandler::Configuration, like this:

module Chandler
  class Configuration
    # ...

    def octokit
      @octokit ||= begin
        # construct with :access_token or :netrc, based on ENV
      end
    end
  end
end

And then change Chandler::GitHub to use config.octokit instead of calling Octokit::Client.new.

That way you can unit test the ENV-based logic independently in configuration_test.rb; that should be sufficient without needing to do an integration test, IMO.

from chandler.

mattbrictson avatar mattbrictson commented on July 17, 2024

@typekpb I merged #16 and released chandler 0.5.0 with GitHub auth token environment variable support, thanks to @orta's contribution. Give it a shot!

from chandler.

orta avatar orta commented on July 17, 2024

And this is how we do it on Danger in Travis too: danger/danger#620

Thanks @mattbrictson

from chandler.

mattbrictson avatar mattbrictson commented on July 17, 2024

@typekpb Did you get this working? I'd like to close this issue, unless there is more that Chandler needs to do to support Travis.

from chandler.

mattbrictson avatar mattbrictson commented on July 17, 2024

I'm considering this solved. Closing.

from chandler.

Related Issues (20)

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.