-
Notifications
You must be signed in to change notification settings - Fork 135
Travis ci #308
base: master
Are you sure you want to change the base?
Travis ci #308
Changes from all commits
5c7a93d
8c0b64d
3dde9eb
b55c072
143c310
e5e4e14
07db9a8
6d4e230
8a18d52
cb45d58
91e338f
082c583
1309950
17154f8
985c3f2
614be1d
7a336de
ed7086a
afb75ef
072bd1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # top-most EditorConfig file | ||
| root = true | ||
|
|
||
| # Unix-style newlines with a newline ending every file | ||
| [*] | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
|
|
||
| [*.rb] | ||
| indent_style = space | ||
| indent_size = 2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| language: ruby | ||
| rvm: | ||
| - 2.2 | ||
| script: rake test:one_by_one |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| # ghi | ||
|
|
||
| [](https://travis-ci.org/shubhamshuklaer/ghi) | ||
|
|
||
| GitHub Issues on the command line. Use your `$EDITOR`, not your browser. | ||
|
|
||
| `ghi` was originally created by [Stephen Celis](https://github.com/stephencelis), and is now maintained by [Alex Chesters](https://github.com/alexchesters). | ||
|
|
@@ -69,3 +71,47 @@ FAQs can be found in the [wiki](https://github.com/stephencelis/ghi/wiki/FAQ) | |
| ## Screenshot | ||
|
|
||
|  | ||
|
|
||
| ## Testing Guidlines | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: |
||
| * You are encouraged to add tests if you are adding new feature or solving some | ||
| problem which do not have a test. | ||
| * A test file should be named as `something_test.rb` and should be kept in the | ||
| `test` folder. A test class should be named `Test_something` and a test | ||
| function `test_something`. Helper functions must not start with `test`. | ||
| * Before running tests `GITHUB_USER` and `GITHUB_PASSWORD` environment | ||
| variables must be exported. It is best to use a fake account as a bug can mess | ||
| up your original account. You can either export these 2 environment variables | ||
| through `~/.bashrc`(As ghi only uses these while generating its token, so after | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing before |
||
| you generate the token for your original account(for regular use), fake account | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing before |
||
| details can be exported) or you can pass it on command line, eg. `rake | ||
| test:one_by_one GITHUB_USER='abc' GITHUB_PASSWORD='xyz'`. | ||
| * Run `rake test:one_by_one` to run all the tests | ||
| * Check [Single Test](https://github.com/grosser/single_test) for better | ||
| control over which test to run. Eg. `rake test:assign:un_assign` will run a | ||
| test function matching `/un_assign/` in file `assign_test.rb`. One more eg. | ||
| `rake test:edit test:assign` will run tests `edit_test.rb` and | ||
| `assign_test.rb`. Or you can also use `ruby -I"lib:test" test/file_name.rb -n | ||
| method_name` | ||
| * By default, the repo and token created while testing will be deleted. But if | ||
| you want to see the state of repo and tokens after the test has run, then add | ||
| `NO_DELETE_REPO=1` and `NO_DELETE_TOKEN=1` to the command. For eg. `rake | ||
| test:assign NO_DELETE_REPO=1 NO_DELETE_TOKEN=1`. | ||
| * If you don't wanna run the tests locally use travis-ci. See section below. | ||
|
|
||
| ## Enable Travis CI in fork | ||
|
|
||
| * Open a Travis CI account and activate travis-ci for the fork | ||
| * Create a fake github account for testing. The username, password and token | ||
| will be available to the tests and if by mistake the test prints it, it will be | ||
| available in public log. So its best to create a fake account and use a | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
| password you are not using for anything else. Apart from security reasons, | ||
| bugs in tests or software can also mess up your original account, so to be | ||
| on safe side use a fake account. | ||
| * At Travis-CI, on the settings page for the fork, add environment variables | ||
| `GITHUB_USER` and `GITHUB_PASSWORD`. Ensure that the "Display value in build | ||
| log" is set to false. It is possible to add these in ".travis.yml", but don't | ||
| as all forks as well as original repo will be using different accounts(We cannot | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing before |
||
| provide the details of a common account for testing because of security reasons) for | ||
| testing, so it will cause problems during merge. | ||
| * Note that the build status badge in the README points to the travis-ci page | ||
| for this repo, not the fork. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| require 'single_test/tasks' | ||
|
|
||
| desc 'Build the standalone script' | ||
| task :build do | ||
| manifest = %w( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,9 @@ def options | |
| opts.on '--local', 'set for local repo only' do | ||
| assigns[:local] = true | ||
| end | ||
| opts.on '--just_print_token', "Just print the token don't add it to ~/.gitconfig(Useful while testing)" do | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space missing before |
||
| assigns[:just_print_token] = true | ||
| end | ||
| opts.on '--auth [<username>]' do |username| | ||
| self.action = 'auth' | ||
| assigns[:username] = username || Authorization.username | ||
|
|
@@ -27,7 +30,7 @@ def execute | |
| if action == 'auth' | ||
| assigns[:password] = Authorization.password || get_password | ||
| Authorization.authorize!( | ||
| assigns[:username], assigns[:password], assigns[:local] | ||
| assigns[:username], assigns[:password], assigns[:local], assigns[:just_print_token] | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| require "test/unit" | ||
| require "helper" | ||
| require "pp" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| class Test_assign < Test::Unit::TestCase | ||
| def setup | ||
| gen_token | ||
| @repo_name=create_repo | ||
| end | ||
|
|
||
| def un_assign issue_no=1 | ||
| `#{ghi_exec} assign -d #{issue_no} -- #{@repo_name}` | ||
|
|
||
| response_issue = get_body("repos/#{@repo_name}/issues/#{issue_no}","Issue does not exist") | ||
|
|
||
| assert_equal(nil,response_issue["assignee"],"User not unassigned") | ||
| end | ||
|
|
||
| def test_un_assign | ||
| open_issue @repo_name | ||
|
|
||
| un_assign | ||
| end | ||
|
|
||
| def test_assign | ||
| open_issue @repo_name | ||
|
|
||
| un_assign | ||
|
|
||
| `#{ghi_exec} assign -u "#{ENV['GITHUB_USER']}" 1 -- #{@repo_name}` | ||
|
|
||
| response_issue=get_body("repos/#{@repo_name}/issues/1","Issue does not exist") | ||
|
|
||
| assert_not_equal(nil,response_issue["assignee"],"No user assigned") | ||
| assert_equal(ENV['GITHUB_USER'],response_issue["assignee"]["login"],"Not assigned to proper user") | ||
| end | ||
|
|
||
| def teardown | ||
| delete_repo(@repo_name) | ||
| delete_token | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| require "test/unit" | ||
| require "helper" | ||
| require "pp" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| class Test_close < Test::Unit::TestCase | ||
| def setup | ||
| gen_token | ||
| @repo_name=create_repo | ||
| end | ||
|
|
||
| def test_close_issue | ||
| open_issue @repo_name | ||
| comment=get_comment | ||
|
|
||
| `#{ghi_exec} close -m "#{comment}" 1 -- #{@repo_name}` | ||
|
|
||
| response_issue=get_body("repos/#{@repo_name}/issues/1","Issue does not exist") | ||
|
|
||
| assert_equal("closed",response_issue["state"],"Issue not closed") | ||
|
|
||
| response_body=get_body("repos/#{@repo_name}/issues/1/comments","Issue does not exist") | ||
|
|
||
| assert_equal(comment,response_body[-1]["body"],"Close comment text not proper") | ||
| end | ||
|
|
||
| def teardown | ||
| delete_repo(@repo_name) | ||
| delete_token | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| require "test/unit" | ||
| require "helper" | ||
| require "pp" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| class Test_comment < Test::Unit::TestCase | ||
| def setup | ||
| gen_token | ||
| @repo_name=create_repo | ||
| end | ||
|
|
||
| def test_comment | ||
| open_issue @repo_name | ||
| create_comment @repo_name | ||
| end | ||
|
|
||
| def test_comment_amend | ||
| open_issue @repo_name | ||
| create_comment @repo_name | ||
|
|
||
| comment=get_comment 1 | ||
|
|
||
| `#{ghi_exec} comment --amend "#{comment}" 1 -- #{@repo_name}` | ||
|
|
||
| response_body=get_body("repos/#{@repo_name}/issues/1/comments","Issue does not exist") | ||
|
|
||
| assert_equal(1,response_body.length,"Comment does not exist") | ||
| assert_equal(comment,response_body[-1]["body"],"Comment text not proper") | ||
| end | ||
|
|
||
| def test_comment_delete | ||
| open_issue @repo_name | ||
| create_comment @repo_name | ||
|
|
||
| `#{ghi_exec} comment -D 1 -- #{@repo_name}` | ||
|
|
||
| response_body=get_body("repos/#{@repo_name}/issues/1/comments","Issue does not exist") | ||
|
|
||
| assert_equal(0,response_body.length,"Comment not deleted") | ||
| end | ||
|
|
||
| def teardown | ||
| delete_repo(@repo_name) | ||
| delete_token | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| require "helper" | ||
| require "json" | ||
| require "pp" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # This is helpful if your account(fake) gets littered with repos. | ||
| # You need to run ruby -I. delete_all_repos.rb. If you are executing from a | ||
| # different directory then you need to change the parameter of -I | ||
| # appropriately. | ||
|
|
||
| puts "Warning this will delete ALL repositories from the account pointed by GITHUB_USER environment variable" | ||
| puts "The account name(login) is #{ENV["GITHUB_USER"]}" | ||
| puts "Do you want to continue [N/y]" | ||
| option = gets | ||
| if option.chop == "y" | ||
| puts "Deleting" | ||
| while true | ||
| response=request("users/#{ENV["GITHUB_USER"]}/repos",:get,{},true) | ||
| repos=JSON.load(response.body) | ||
| if repos.length == 0 | ||
| puts "Exiting" | ||
| break | ||
| end | ||
| repos.each do |repo| | ||
| puts "Deleting #{repo["full_name"]}" | ||
| delete_repo(repo["full_name"]) | ||
| end | ||
| end | ||
| else | ||
| puts 'Not deleting' | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link needs to be changed after merge.