Merge branch 'master' into cronjobs
This commit is contained in:
commit
13aa741e57
45
Gemfile.lock
45
Gemfile.lock
|
@ -48,7 +48,7 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-core.git
|
remote: git://github.com/travis-ci/travis-core.git
|
||||||
revision: 9978518236afb520c8fff68bebe7beb62f8ad776
|
revision: f1d4c3246ea7a5434076fdc7026aa11a2c90bdac
|
||||||
specs:
|
specs:
|
||||||
travis-core (0.0.1)
|
travis-core (0.0.1)
|
||||||
actionmailer (~> 3.2.19)
|
actionmailer (~> 3.2.19)
|
||||||
|
@ -56,6 +56,7 @@ GIT
|
||||||
coder (~> 0.4.0)
|
coder (~> 0.4.0)
|
||||||
data_migrations (~> 0.0.1)
|
data_migrations (~> 0.0.1)
|
||||||
gh
|
gh
|
||||||
|
google-api-client (~> 0.9.4)
|
||||||
hashr
|
hashr
|
||||||
metriks (~> 0.9.7)
|
metriks (~> 0.9.7)
|
||||||
multi_json
|
multi_json
|
||||||
|
@ -66,7 +67,7 @@ GIT
|
||||||
rollout (~> 1.1.0)
|
rollout (~> 1.1.0)
|
||||||
s3 (~> 0.3)
|
s3 (~> 0.3)
|
||||||
simple_states (~> 1.0.0)
|
simple_states (~> 1.0.0)
|
||||||
thor (~> 0.14.6)
|
thor
|
||||||
travis-config (~> 0.1.0)
|
travis-config (~> 0.1.0)
|
||||||
virtus (~> 1.0.0)
|
virtus (~> 1.0.0)
|
||||||
|
|
||||||
|
@ -191,6 +192,24 @@ GEM
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
net-http-persistent (>= 2.7)
|
net-http-persistent (>= 2.7)
|
||||||
net-http-pipeline
|
net-http-pipeline
|
||||||
|
google-api-client (0.9.4)
|
||||||
|
addressable (~> 2.3)
|
||||||
|
googleauth (~> 0.5)
|
||||||
|
httpclient (~> 2.7)
|
||||||
|
hurley (~> 0.1)
|
||||||
|
memoist (~> 0.11)
|
||||||
|
mime-types (>= 1.6)
|
||||||
|
representable (~> 2.3.0)
|
||||||
|
retriable (~> 2.0)
|
||||||
|
thor (~> 0.19)
|
||||||
|
googleauth (0.5.1)
|
||||||
|
faraday (~> 0.9)
|
||||||
|
jwt (~> 1.4)
|
||||||
|
logging (~> 2.0)
|
||||||
|
memoist (~> 0.12)
|
||||||
|
multi_json (~> 1.11)
|
||||||
|
os (~> 0.9)
|
||||||
|
signet (~> 0.7)
|
||||||
hashr (0.0.22)
|
hashr (0.0.22)
|
||||||
hike (1.2.3)
|
hike (1.2.3)
|
||||||
hitimes (1.2.3)
|
hitimes (1.2.3)
|
||||||
|
@ -198,20 +217,27 @@ GEM
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
multi_xml (>= 0.5.2)
|
multi_xml (>= 0.5.2)
|
||||||
httpclient (2.7.1)
|
httpclient (2.7.1)
|
||||||
|
hurley (0.2)
|
||||||
i18n (0.7.0)
|
i18n (0.7.0)
|
||||||
ice_nine (0.11.2)
|
ice_nine (0.11.2)
|
||||||
jemalloc (1.0.1)
|
jemalloc (1.0.1)
|
||||||
journey (1.0.4)
|
journey (1.0.4)
|
||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
|
jwt (1.5.4)
|
||||||
kgio (2.9.2)
|
kgio (2.9.2)
|
||||||
listen (1.0.3)
|
listen (1.0.3)
|
||||||
rb-fsevent (>= 0.9.3)
|
rb-fsevent (>= 0.9.3)
|
||||||
rb-inotify (>= 0.9)
|
rb-inotify (>= 0.9)
|
||||||
rb-kqueue (>= 0.2)
|
rb-kqueue (>= 0.2)
|
||||||
|
little-plugger (1.1.4)
|
||||||
|
logging (2.1.0)
|
||||||
|
little-plugger (~> 1.1)
|
||||||
|
multi_json (~> 1.10)
|
||||||
mail (2.5.4)
|
mail (2.5.4)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
memcachier (0.0.2)
|
memcachier (0.0.2)
|
||||||
|
memoist (0.14.0)
|
||||||
metaclass (0.0.4)
|
metaclass (0.0.4)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
metriks (0.9.9.6)
|
metriks (0.9.9.6)
|
||||||
|
@ -229,6 +255,7 @@ GEM
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
net-http-persistent (2.9.4)
|
net-http-persistent (2.9.4)
|
||||||
net-http-pipeline (1.0.1)
|
net-http-pipeline (1.0.1)
|
||||||
|
os (0.9.6)
|
||||||
pg (0.18.2)
|
pg (0.18.2)
|
||||||
polyglot (0.3.5)
|
polyglot (0.3.5)
|
||||||
proxies (0.2.1)
|
proxies (0.2.1)
|
||||||
|
@ -270,8 +297,11 @@ GEM
|
||||||
redis (3.2.2)
|
redis (3.2.2)
|
||||||
redis-namespace (1.5.1)
|
redis-namespace (1.5.1)
|
||||||
redis (~> 3.0, >= 3.0.4)
|
redis (~> 3.0, >= 3.0.4)
|
||||||
|
representable (2.3.0)
|
||||||
|
uber (~> 0.0.7)
|
||||||
rerun (0.8.2)
|
rerun (0.8.2)
|
||||||
listen (~> 1.0.3)
|
listen (~> 1.0.3)
|
||||||
|
retriable (2.1.0)
|
||||||
rollout (1.1.0)
|
rollout (1.1.0)
|
||||||
rspec (2.99.0)
|
rspec (2.99.0)
|
||||||
rspec-core (~> 2.99.0)
|
rspec-core (~> 2.99.0)
|
||||||
|
@ -292,6 +322,11 @@ GEM
|
||||||
json
|
json
|
||||||
redis (>= 3.0.6)
|
redis (>= 3.0.6)
|
||||||
redis-namespace (>= 1.3.1)
|
redis-namespace (>= 1.3.1)
|
||||||
|
signet (0.7.2)
|
||||||
|
addressable (~> 2.3)
|
||||||
|
faraday (~> 0.9)
|
||||||
|
jwt (~> 1.5)
|
||||||
|
multi_json (~> 1.10)
|
||||||
simple_states (1.0.1)
|
simple_states (1.0.1)
|
||||||
activesupport
|
activesupport
|
||||||
hashr (~> 0.0.10)
|
hashr (~> 0.0.10)
|
||||||
|
@ -320,7 +355,7 @@ GEM
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
stackprof (0.2.7)
|
stackprof (0.2.7)
|
||||||
thor (0.14.6)
|
thor (0.19.1)
|
||||||
thread_safe (0.3.5)
|
thread_safe (0.3.5)
|
||||||
tilt (1.4.1)
|
tilt (1.4.1)
|
||||||
timecop (0.8.0)
|
timecop (0.8.0)
|
||||||
|
@ -333,6 +368,7 @@ GEM
|
||||||
polyglot
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.48)
|
tzinfo (0.3.48)
|
||||||
|
uber (0.0.15)
|
||||||
unicorn (4.8.3)
|
unicorn (4.8.3)
|
||||||
kgio (~> 2.6)
|
kgio (~> 2.6)
|
||||||
rack
|
rack
|
||||||
|
@ -390,6 +426,3 @@ DEPENDENCIES
|
||||||
travis-yaml!
|
travis-yaml!
|
||||||
unicorn
|
unicorn
|
||||||
yard-sinatra!
|
yard-sinatra!
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
1.12.0.pre.1
|
|
||||||
|
|
78
README.md
78
README.md
|
@ -4,50 +4,68 @@ This is the app running on https://api.travis-ci.org/
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
You will need the following packages to get travis-api to work:
|
||||||
|
|
||||||
1. PostgreSQL 9.3 or higher
|
1. PostgreSQL 9.3 or higher
|
||||||
1. Redis
|
2. Bundler
|
||||||
1. RabbitMQ
|
3. Redis Server
|
||||||
1. Nginx *NB: If working on Ubuntu please install Nginx manually from source. [This guide](http://www.rackspace.com/knowledge_center/article/ubuntu-and-debian-installing-nginx-from-source) is helpful but make sure you install the [latest stable version](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/#stable), include the user name on your ubuntu machine when compiling (add `--user=[yourusername]` as an option when running `./configure`), and don't follow any subsequent server configuration steps. Travis-api will start and configure its own nginx server when run locally.
|
4. *Optional:* RabbitMQ Server
|
||||||
|
5. Nginx -
|
||||||
|
*If working in Ubuntu please install nginx manually from source: Download and extract latest nginx version, open a terminal in extracted folder and then run the following:*
|
||||||
|
```sh-session
|
||||||
|
$ sudo apt-get install libpcre3 libpcre3-dev
|
||||||
|
$ auto/configure --user=$USER
|
||||||
|
$ make
|
||||||
|
$ sudo make install
|
||||||
|
$ sudo ln -s /usr/local/nginx/sbin/nginx /bin/nginx
|
||||||
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Setup
|
### Setup
|
||||||
|
```sh-session
|
||||||
$ bundle install
|
$ bundle install
|
||||||
|
```
|
||||||
### Database setup
|
### Database setup
|
||||||
|
|
||||||
|
*You might need to create a role first. For this you should run the following:*
|
||||||
|
```sh-session
|
||||||
|
$ sudo -u postgres psql -c "CREATE USER yourusername WITH SUPERUSER PASSWORD 'yourpassword'"
|
||||||
|
```
|
||||||
|
|
||||||
NB detail for how `rake` sets up the database can be found in the `Rakefile`. In the `namespace :db` block you will see the database name is configured using the environment variable RAILS_ENV. If you are using a different configuration you will have to make your own adjustments.
|
NB detail for how `rake` sets up the database can be found in the `Rakefile`. In the `namespace :db` block you will see the database name is configured using the environment variable RAILS_ENV. If you are using a different configuration you will have to make your own adjustments.
|
||||||
|
|
||||||
1. `bundle exec rake db:create`
|
|
||||||
2. for testing 'RAILS_ENV=test bundle exec rake db:create --trace'
|
|
||||||
1. Clone `travis-logs` and copy the `logs` database (assume the PostgreSQL user is `postgres`):
|
|
||||||
```sh-session
|
```sh-session
|
||||||
cd ..
|
$ RAILS_ENV=development bundle exec rake db:create
|
||||||
git clone https://github.com/travis-ci/travis-logs.git
|
$ RAILS_ENV=test bundle exec rake db:create
|
||||||
cd travis-logs
|
```
|
||||||
rvm jruby do bundle exec rake db:migrate # `travis-logs` requires JRuby
|
#### Optional
|
||||||
psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_development
|
Clone `travis-logs` and copy the `logs` database (assume the PostgreSQL user is `postgres`):
|
||||||
pg_dump -t logs travis_logs_development | psql -U postgres travis_development
|
```sh-session
|
||||||
|
$ cd ..
|
||||||
|
$ git clone https://github.com/travis-ci/travis-logs.git
|
||||||
|
$ cd travis-logs
|
||||||
|
$ rvm jruby do bundle exec rake db:migrate # `travis-logs` requires JRuby
|
||||||
|
$ psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_development
|
||||||
|
$ pg_dump -t logs travis_logs_development | psql -U postgres travis_development
|
||||||
|
|
||||||
|
$ RAILS_ENV=test bundle exec rake db:create
|
||||||
|
$ pushd ../travis-logs
|
||||||
|
$ RAILS_ENV=test rvm jruby do bundle exec rake db:migrate
|
||||||
|
$ psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_test
|
||||||
|
$ pg_dump -t logs travis_logs_test | psql -U postgres travis_test
|
||||||
|
$ popd
|
||||||
```
|
```
|
||||||
|
|
||||||
Repeat the database steps for `RAILS_ENV=test`.
|
|
||||||
```sh-session
|
|
||||||
RAILS_ENV=test bundle exec rake db:create
|
|
||||||
pushd ../travis-logs
|
|
||||||
RAILS_ENV=test rvm jruby do bundle exec rake db:migrate
|
|
||||||
psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_test
|
|
||||||
pg_dump -t logs travis_logs_test | psql -U postgres travis_test
|
|
||||||
popd
|
|
||||||
```
|
|
||||||
|
|
||||||
### Run tests
|
### Run tests
|
||||||
|
```sh-session
|
||||||
$ rake spec
|
$ bundle exec rspec
|
||||||
|
```
|
||||||
### Run the server
|
### Run the server
|
||||||
|
```sh-session
|
||||||
$ bundle exec script/server
|
$ bundle exec script/server
|
||||||
|
```
|
||||||
|
If you have problems with Nginx because the websocket is already in use, try restarting your computer.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,20 @@
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Models::Request < Model
|
class Models::Request < Model
|
||||||
|
BRANCH_REF = %r{refs/heads/(.*?)$}
|
||||||
|
|
||||||
belongs_to :commit
|
belongs_to :commit
|
||||||
belongs_to :repository
|
belongs_to :repository
|
||||||
belongs_to :owner, polymorphic: true
|
belongs_to :owner, polymorphic: true
|
||||||
has_many :builds
|
has_many :builds
|
||||||
serialize :config
|
serialize :config
|
||||||
serialize :payload
|
serialize :payload
|
||||||
|
|
||||||
|
def branch_name
|
||||||
|
ref =~ BRANCH_REF and $1
|
||||||
|
end
|
||||||
|
|
||||||
|
def ref
|
||||||
|
payload['ref'] if payload
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,6 @@ require 'travis/api/v3/renderer/model_renderer'
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Renderer::Request < Renderer::ModelRenderer
|
class Renderer::Request < Renderer::ModelRenderer
|
||||||
representation(:minimal, :id)
|
representation(:minimal, :id)
|
||||||
representation(:standard, :id, :repository, :commit, :owner, :created_at, :result, :message, :event_type)
|
representation(:standard, :id, :repository, :branch_name, :commit, :owner, :created_at, :result, :message, :event_type)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ module Travis::API::V3
|
||||||
|
|
||||||
def limit(repository)
|
def limit(repository)
|
||||||
if repository.settings.nil?
|
if repository.settings.nil?
|
||||||
LIMIT
|
Travis.config.requests_create_api_limit || LIMIT
|
||||||
else
|
else
|
||||||
repository.settings["api_builds_rate_limit"] || Travis.config.requests_create_api_limit || LIMIT
|
repository.settings["api_builds_rate_limit"] || Travis.config.requests_create_api_limit || LIMIT
|
||||||
end
|
end
|
||||||
|
|
60
spec/v3/services/requests/find_spec.rb
Normal file
60
spec/v3/services/requests/find_spec.rb
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Travis::API::V3::Services::Requests::Find do
|
||||||
|
let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
|
||||||
|
let(:request) { repo.requests.first }
|
||||||
|
|
||||||
|
describe "fetching requests on a public repository" do
|
||||||
|
before { get("/v3/repo/#{repo.id}/requests") }
|
||||||
|
example { expect(last_response).to be_ok }
|
||||||
|
example { expect(JSON.load(body).to_s).to include(
|
||||||
|
"@type",
|
||||||
|
"requests",
|
||||||
|
"/v3/repo/#{repo.id}/requests",
|
||||||
|
"repository",
|
||||||
|
"commit",
|
||||||
|
"message",
|
||||||
|
"the commit message",
|
||||||
|
"branch_name",
|
||||||
|
"representation",
|
||||||
|
"@pagination",
|
||||||
|
"owner",
|
||||||
|
"created_at",
|
||||||
|
"result",
|
||||||
|
"sha",
|
||||||
|
"svenfuchs/minimal",
|
||||||
|
"event_type",
|
||||||
|
"push")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "fetching requests on private repository, private API, authenticated as user with access" do
|
||||||
|
let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) }
|
||||||
|
let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}" }}
|
||||||
|
before { Travis::API::V3::Models::Permission.create(repository: repo, user: repo.owner, pull: true) }
|
||||||
|
before { repo.update_attribute(:private, true) }
|
||||||
|
before { get("/v3/repo/#{repo.id}/requests", {}, headers) }
|
||||||
|
after { repo.update_attribute(:private, false) }
|
||||||
|
example { expect(last_response).to be_ok }
|
||||||
|
example { expect(JSON.load(body).to_s).to include(
|
||||||
|
"@type",
|
||||||
|
"requests",
|
||||||
|
"/v3/repo/#{repo.id}/requests",
|
||||||
|
"repository",
|
||||||
|
"commit",
|
||||||
|
"message",
|
||||||
|
"the commit message",
|
||||||
|
"branch_name",
|
||||||
|
"representation",
|
||||||
|
"@pagination",
|
||||||
|
"owner",
|
||||||
|
"created_at",
|
||||||
|
"result",
|
||||||
|
"sha",
|
||||||
|
"svenfuchs/minimal",
|
||||||
|
"event_type",
|
||||||
|
"push")
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user