Compare commits

...

952 Commits

Author SHA1 Message Date
Renée Hendricksen
542592ae41 Merge pull request #313 from travis-ci/fix_sentry_errors
fix another sentry error
2016-08-14 21:22:26 -04:00
Renée Hendricksen
c2c1952d40 Merge branch 'master' into fix_sentry_errors 2016-08-14 21:06:18 -04:00
Renée Hendricksen
ca80c7f0a2 fix another sentry error 2016-08-14 21:05:56 -04:00
Renée Hendricksen
a9f84c27b0 Merge pull request #311 from travis-ci/fix_sentry_errors
Fix sentry errors
2016-08-14 20:51:11 -04:00
Renée Hendricksen
65aece922c fix another sentry error 2016-08-14 20:35:11 -04:00
Renée Hendricksen
17ccc22fbe fix the atom bug 2016-08-14 19:23:22 -04:00
Renée Hendricksen
51575bdb89 this fixes the error 2016-08-14 18:16:05 -04:00
Renée Hendricksen
b3e8b9d43b more debug output 2016-08-14 17:26:03 -04:00
Renée Hendricksen
ba6b5b7cba add some debug for testing staging 2016-08-14 16:54:34 -04:00
Joe Corcoran
8afaeb10c0 Merge pull request #310 from travis-ci/joshk-customerio-domain-data
also send the travis domain to customer.io
2016-08-12 14:41:59 +02:00
Josh Kalderimis
c7161cec81 also send the travis domain to customer.io 2016-08-12 14:37:05 +02:00
Aakriti Gupta
8a14ef827f Merge pull request #302 from travis-ci/ps-stop-using-last-deploy-sha-buildpack
Use `HEROKU_SLUG_COMMIT` instead of last-commit-sha-buildpack
2016-08-11 15:20:26 +02:00
Piotr Sarnacki
32503b0731 Use HEROKU_SLUG_COMMIT instead of last-commit-sha-buildpack
We used last-commit-sha-buildpack in order to fetch the sha of the last
deployed commit during building the app and save it to use it later.
This was done using undocumented Heroku properties, for example it
assumed a certain path to git files. It turns out that there's another
way to do it now. We can enable dyno-metadata[1] feature on heroku and
use HEROKU_SLUG_COMMIT

[1] https://devcenter.heroku.com/articles/dyno-metadata
2016-08-08 13:31:52 +02:00
Renée Hendricksen
178122e247 Merge pull request #309 from travis-ci/fix_crons
fix the reported error on crons
2016-08-04 15:13:03 -04:00
Renée Hendricksen
7655d0edd2 Merge branch 'master' into fix_crons 2016-08-04 15:06:55 -04:00
Renée Hendricksen
885ae009f4 fix the reported error on crons 2016-08-04 15:05:20 -04:00
Renée Hendricksen
614b1f5338 Merge pull request #308 from travis-ci/fix_crons
Fix crons
2016-08-03 00:41:39 -04:00
Renée Hendricksen
8655579a94 clean up the debug output 2016-08-03 00:17:11 -04:00
Renée Hendricksen
77e47bc41a don't report console errors to Sentry 2016-08-03 00:13:43 -04:00
Renée Hendricksen
779b6a569e don't allow one error to stop all crons from running 2016-08-02 23:49:47 -04:00
Renée Hendricksen
abe7b13605 better output 2016-08-02 23:16:00 -04:00
Renée Hendricksen
0dc7e2743c take intentional error out to see real errors 2016-08-02 22:56:13 -04:00
Renée Hendricksen
d42362eacc looks like Raven isn't getting the reports because the dyno doesn't exist long enough for the http request to get out :( 2016-08-02 22:49:02 -04:00
Renée Hendricksen
1788e0c0fb more output for the strange behavior on staging 2016-08-02 22:42:32 -04:00
Renée Hendricksen
20d4df8af3 test output for staging 2016-08-02 22:34:49 -04:00
Renée Hendricksen
d41ddd7171 testing console on staging 2016-08-02 22:03:31 -04:00
Renée Hendricksen
6ca063cf3d adding an error to see if I get it from Sentry 2016-08-02 21:26:04 -04:00
Renée Hendricksen
f787a96b96 Auto-merged master into fix_crons on deployment. 2016-08-02 21:03:43 -04:00
Renée Hendricksen
d0a143d76a ensure that the Time.now builds get started and tag the Sentry errors from cron 2016-08-02 19:44:33 -04:00
Ana Rosas
cdce95a508 Merge pull request #307 from travis-ci/ar-fix-request-endpoint
Restoring /requests new version
2016-08-02 10:13:00 -05:00
Ana Rosas
0f2b1edae1 Remove unnecessary sign 2016-08-02 10:02:44 -05:00
Ana Rosas
f09e9931b2 Restoring requests code 2016-08-02 09:39:00 -05:00
Brandon Ferguson
75bd65e56c Merge pull request #305 from travis-ci/backport-amqps-fix
Backport travis-core/travis-config AMQPS fix
2016-08-01 12:27:09 +02:00
bnferguson
f4cb24c4b4 fix deprecation warnings 2016-08-01 12:01:34 +02:00
bnferguson
4888c2c905 Add specs for patched in travis-config updates 2016-08-01 11:53:11 +02:00
bnferguson
edf889b55f fix typo 2016-08-01 11:33:52 +02:00
bnferguson
0dc1009ab4 Patch in AMQPS support from travis-core since its vendored here 2016-08-01 11:32:16 +02:00
Ana Rosas
255640fd4f Merge pull request #283 from travis-ci/ar-remove-unused-core-code
Remove legacy travis-core code
2016-07-28 12:17:58 -05:00
Ana Rosas
bcf08e0e7e Remove SS reference on nginx config 2016-07-28 10:29:58 -05:00
Ana Rosas
89eea1682f Merge branch 'ar-remove-unused-core-code' of github.com:travis-ci/travis-api into ar-remove-unused-core-code 2016-07-28 09:26:52 -05:00
Ana Rosas
9e1c6933f5 Use nginx buildpack 2016-07-28 15:09:09 +02:00
Ana Rosas
3f97b40914 Restore sigsci-buildpack-nginx 2016-07-28 15:09:09 +02:00
Ana Rosas
90e5d968ea Try herouku buildpack from sigsci 2016-07-28 15:09:08 +02:00
Ana Rosas
7d70f161a1 Use only nginx package 2016-07-28 15:09:08 +02:00
Ana Rosas
7f3fb70ec7 Add nginx buildpack 2016-07-28 15:09:08 +02:00
Ana Rosas
175e266a6d Rever removing signalsciences buildpack 2016-07-28 15:09:08 +02:00
Ana Rosas
e037127a9c Remove sigsci buildpack temporarily 2016-07-28 15:09:08 +02:00
Ana Rosas
5293919f3a Remove repeated gem 2016-07-28 15:09:08 +02:00
Aakriti Gupta
c6a1eda572 Move travis-core files from /vendor to /lib.
- Re-factor
- Remove code for notifications
- Remove addons
- Remove travis-core gem.
- Ignore logs directory only
- Move core tests to spec/lib
2016-07-28 15:09:08 +02:00
Ana Rosas
cb89cae39f Remove event#notify 2016-07-28 15:09:07 +02:00
Aakriti Gupta
bcbf0abf60 Remove feature flip from requests endpoint 2016-07-28 15:09:07 +02:00
Ana Rosas
9e2fff6e0a Remove specs from vendored travis-core 2016-07-28 15:09:07 +02:00
Ana Rosas
5dd513f79b Remove unused travis-core services 2016-07-28 15:09:07 +02:00
Ana Rosas
9b5893b07c Remove old code references from v3 endpoints 2016-07-28 15:09:07 +02:00
Ana Rosas
8bd4d7db5e Remove old code references from v2 endpoints 2016-07-28 15:09:07 +02:00
carlad
4254b181d4 Merge pull request #304 from travis-ci/v3-documentation
add info about developer.travis-ci.org to readme
2016-07-28 15:04:59 +02:00
carlad
8eb9811b30 add tool as dependency 2016-07-27 16:54:29 +02:00
carlad
93cfcadeef Merge pull request #303 from travis-ci/cd-sentry
Send error logging to Sentry
2016-07-27 12:50:27 +02:00
carlad
9e61d5e636 revert typo 2016-07-27 12:10:39 +02:00
carlad
c112c56664 add typo to test sending of error to sentry on staging 2016-07-27 11:59:36 +02:00
carlad
3a1b1a591f remove comment 2016-07-26 17:53:35 +02:00
carlad
72be42b88f move capture_exception to correct method, update spec 2016-07-26 17:36:02 +02:00
carlad
291fea3e07 add a cron to the test 2016-07-26 17:03:32 +02:00
carlad
1733ea69d5 remove expectation 2016-07-26 16:49:22 +02:00
carlad
543998feea update spec 2016-07-26 16:05:58 +02:00
carlad
e31976974c try to get spec to pass 2016-07-26 15:35:41 +02:00
carlad
c90991e10a update cron spec 2016-07-26 13:38:53 +02:00
carlad
c00cdbaff7 crons only 2016-07-25 19:30:45 +02:00
carlad
5e798aca6f try to fix spec 2016-07-25 15:54:26 +02:00
carlad
7107f4378c resolve conflicts 2016-07-25 14:43:19 +02:00
carlad
1e04b52f5f change raven syntax 2016-07-25 12:42:16 +02:00
carlad
20be47698a try raven.new 2016-07-22 15:19:14 +02:00
carlad
185067265c remove unnecessary requires, inital work on spec 2016-07-21 17:56:41 +02:00
carlad
27dbe9a75a require sentry, move raven capture 2016-07-21 17:24:36 +02:00
carlad
cafe40a4c3 add sentry capture to v3 router 2016-07-21 17:07:25 +02:00
Ana Rosas
e5492f77ce Use nginx buildpack 2016-07-20 13:44:26 -05:00
Ana Rosas
2df85a5068 Restore sigsci-buildpack-nginx 2016-07-20 13:28:33 -05:00
Ana Rosas
22a26580d9 Try herouku buildpack from sigsci 2016-07-20 13:23:21 -05:00
Ana Rosas
b471b92b60 Use only nginx package 2016-07-20 12:42:26 -05:00
Ana Rosas
89c96ecb95 Add nginx buildpack 2016-07-20 11:48:37 -05:00
Ana Rosas
0647dcdcb2 Rever removing signalsciences buildpack 2016-07-20 11:23:56 -05:00
Ana Rosas
11594487fb Remove sigsci buildpack temporarily 2016-07-20 10:25:42 -05:00
Ana Rosas
476e944c55 Remove repeated gem 2016-07-20 08:40:53 -05:00
Aakriti Gupta
65f1a29d86 Move travis-core files from /vendor to /lib.
- Re-factor
- Remove code for notifications
- Remove addons
- Remove travis-core gem.
- Ignore logs directory only
- Move core tests to spec/lib
2016-07-20 11:22:25 +02:00
Ana Rosas
e9b3ed308a Remove event#notify 2016-07-20 11:22:25 +02:00
Ana Rosas
bfd44e1d77 Remove specs from vendored travis-core 2016-07-20 11:22:21 +02:00
Ana Rosas
155767ea37 Remove unused travis-core services 2016-07-20 11:22:06 +02:00
Ana Rosas
70adc93a8f Remove old code references from v3 endpoints 2016-07-20 11:21:45 +02:00
Aakriti Gupta
9ab4111f33 Remove feature flip from requests endpoint 2016-07-20 11:20:19 +02:00
Ana Rosas
0ee949a846 Remove specs from vendored travis-core 2016-07-20 11:17:51 +02:00
Ana Rosas
8c512677f1 Remove unused travis-core services 2016-07-20 11:17:51 +02:00
Ana Rosas
510fb8b146 Remove old code references from v3 endpoints 2016-07-20 11:17:51 +02:00
Ana Rosas
75ef3a6367 Remove old code references from v2 endpoints 2016-07-20 11:17:50 +02:00
Renée Hendricksen
a45d53f73c Merge pull request #279 from travis-ci/jc-v3-env-vars
[WIP] Add environment variable endpoints
2016-07-14 20:02:24 -04:00
Renée Hendricksen
652439226a Merge branch 'master' into jc-v3-env-vars 2016-07-14 19:57:40 -04:00
Renée Hendricksen
b31301ac1f Merge pull request #292 from travis-ci/rlh_cleanup3
use the new method
2016-07-14 19:54:25 -04:00
Renée Hendricksen
48e4a2c589 use travis settings for encrypted columns 2016-07-14 17:47:17 -04:00
Renée Hendricksen
58cd17158c decrypt the public values for return and fix the tests 2016-07-14 17:24:49 -04:00
Renée Hendricksen
01893ba62b Merge pull request #300 from travis-ci/fix_time_dependent_test
Fix Time Dependent Tests
2016-07-13 10:10:45 -04:00
Renée Hendricksen
42b1661107 already required in the spec helper now 2016-07-12 19:27:04 -04:00
Renée Hendricksen
16968f445f freeze time for the whole suite so all the Time.now calls sprinkled through the old tests won't error if there is a delay on Travis CI 2016-07-12 19:23:24 -04:00
Renée Hendricksen
c10145cc93 builds occasionally fail when the timestamps are a second off, this should fix that 2016-07-12 17:38:55 -04:00
Renée Hendricksen
35ae19c3a0 Merge branch 'jc-v3-env-vars' into rlh_cleanup3 2016-07-12 17:08:10 -04:00
Renée Hendricksen
8cdbca925b Merge branch 'master' into jc-v3-env-vars 2016-07-12 17:07:51 -04:00
Renée Hendricksen
2783a69f89 encrpted value and working tests 2016-07-12 14:12:46 -04:00
Ana Rosas
40bff028f3 Merge pull request #299 from travis-ci/ar-fix-requests-endpoint-params
Handle build and job restarts on /requests
2016-07-12 09:17:37 -05:00
Ana Rosas
8b7a589018 Merge branch 'master' into ar-fix-requests-endpoint-params 2016-07-12 08:51:04 -05:00
Piotr Sarnacki
87a069863a Merge pull request #297 from travis-ci/ps-fix-v3-enable-repo
Upload SSL Key to GitHub when activating private repository
2016-07-12 11:37:13 +02:00
Piotr Sarnacki
14ea592cd7 Upload SSL Key to GitHub when activating private repository 2016-07-12 11:28:35 +02:00
Ana Rosas
54e9d2fd06 Get type of model in order to call correct restart event 2016-07-11 15:20:34 -05:00
Ana Rosas
f544f3b15a Requests endpoint receives build_id and job_id 2016-07-11 15:14:30 -05:00
Ana Rosas
a5480fb097 Merge pull request #298 from travis-ci/ar-fix-requests-endpoint
Fixes /requests endpoint
2016-07-11 14:44:36 -05:00
Ana Rosas
b234ad73be Use repo owner instead of current user 2016-07-11 14:29:05 -05:00
Ana Rosas
2ab8af6659 Use build:restart event 2016-07-11 14:29:05 -05:00
Ana Rosas
564e95be6b Use params instead of payload and return error message 2016-07-11 14:29:04 -05:00
Renée Hendricksen
1a36fc6195 Merge branch 'jc-v3-env-vars' into rlh_cleanup3 2016-07-11 15:14:15 -04:00
Renée Hendricksen
f8b8ef54a9 Merge branch 'master' into rlh_cleanup3 2016-07-11 15:13:24 -04:00
Renée Hendricksen
3fb7c35286 copy pasta fix 2016-07-07 01:30:35 -04:00
Renée Hendricksen
f63bb1c6a2 if this logic isn't needed we should take it out later 2016-07-07 01:16:39 -04:00
Renée Hendricksen
f1d7305e9d Merge branch 'master' into jc-v3-env-vars 2016-07-07 00:41:00 -04:00
Renée Hendricksen
b94d9c8637 use the new method 2016-07-07 00:31:35 -04:00
Konstantin Haase
f7f6478fa4 indentation 2016-07-06 10:56:14 +02:00
Renée Hendricksen
21f445ad64 Merge branch 'master' into jc-v3-env-vars 2016-07-05 18:02:29 -04:00
Renée Hendricksen
1ec8dba7e4 fix the tests 2016-07-05 13:36:31 -04:00
Ana Rosas
1d7bc10ed9 Merge pull request #291 from travis-ci/ag-ar-restart-in-request-endpoint
Use new restart service on request endpoint
2016-07-05 10:50:58 -05:00
Renée Hendricksen
ac7e610510 Merge branch 'master' into jc-v3-env-vars 2016-07-05 11:44:28 -04:00
Ana Rosas
db193cb541 Use new restart service on request endpoint 2016-07-05 10:25:54 -05:00
Igor
ff7d1dbfdd Merge pull request #290 from travis-ci/igor-update-rack-attack
Update rack-attack to 5.0.0.beta1
2016-07-05 13:11:59 +02:00
Igor
237f270708 Merge pull request #289 from travis-ci/igor-safelist-github-ips
safelist github IP range in Rack::Attack
2016-07-05 13:11:19 +02:00
Igor Wiedler
50b78a1458 Merge branch 'igor-safelist-github-ips' into igor-update-rack-attack 2016-07-05 13:03:05 +02:00
Igor Wiedler
79c14d697e only create/allocate GitHub CIDR object once 2016-07-05 13:02:00 +02:00
Igor Wiedler
d84d3983b8 update rack-attack to 5.0.0.beta1, use safelist/blocklist terminology 2016-07-05 12:58:58 +02:00
Igor Wiedler
a210cf8661 support nil ip 2016-07-05 12:46:32 +02:00
Igor Wiedler
0d90c21dbd require netaddr instead of cidr 2016-07-05 12:39:44 +02:00
Igor Wiedler
7e8b65a311 correct test case for GitHub IP check 2016-07-05 12:39:32 +02:00
Igor Wiedler
e6d7607916 safelist github IP range in Rack::Attack 2016-07-05 12:30:10 +02:00
Konstantin Haase
c1de919852 Don't run Rack::Attack for Enterprise. (#287)
On enterprise, the reverse proxy is not correctly set up, and therefore the client IP address not passed through properly. For that reason, all requests look like they originate from the same client, and if one gets blocked, everyone gets blocked.
2016-07-05 11:46:33 +02:00
Renée Hendricksen
7d52b06533 Merge branch 'jc-v3-env-vars' of github.com:travis-ci/travis-api into jc-v3-env-vars 2016-07-01 23:56:09 -04:00
Joe Corcoran
829366a554 Fix duplicate lines from rebase 2016-07-01 23:55:49 -04:00
Joe Corcoran
4b14f17cc5 Fix service specs 2016-07-01 23:55:49 -04:00
Joe Corcoran
f5bc526f25 Refactor repeated pattern into extracted method
Seems like we'll be checking login status before finding a resource
a lot, so here's a standard way to do it.
2016-07-01 23:55:49 -04:00
Joe Corcoran
1a07e199b5 Better style in error handling 2016-07-01 23:55:49 -04:00
Joe Corcoran
91e9fcebf7 Remove some duplication 2016-07-01 23:55:49 -04:00
Joe Corcoran
871b915515 Add env vars endpoints
This adds API V3 endpoints for querying, creating, modifying and
deleting environment variables.

It has no concept of encryption yet and should be considered a work in
progress.

We should also talk about the slightly off-track approach in the
EnvVars::Create service – maybe there's a way to standardise the
querying and rendering for post requests?

2016-07-01 23:55:49 -04:00
Joe Corcoran
77dcdaa482 Use travis-settings to manage JSON settings field
Since we use repository.settings as a kind of dump for all
sorts of settings, some user-facing and some not, this lets us
leave the db as it is, but pretend to have separate models for each
"kind" of setting.
2016-07-01 23:55:49 -04:00
Sven Fuchs
09806a5f93 Merge pull request #285 from travis-ci/igor-deprecate-event-notify
Add deprecation notice to Event.notify() that writes to log
2016-07-01 17:55:46 +02:00
Igor Wiedler
b5fe8f1884 Add deprecation notice to Event.notify() that writes to log 2016-07-01 17:48:34 +02:00
Igor
b9d65ff30f Merge pull request #284 from travis-ci/igor-fix-rate-limit
no longer test against user agent for github rate-limit, since it is not consistently github-camo
2016-07-01 16:39:02 +02:00
Igor Wiedler
34fbfc2ccf no longer test against user agent for github rate-limit, since it is not consistently github-camo 2016-07-01 16:27:41 +02:00
Joe Corcoran
bed317b109 Merge pull request #281 from travis-ci/igor-github-rate-limit
safelist build status image requests coming from github
2016-06-30 15:31:57 +02:00
Igor Wiedler
0156671fc8 safelist build status image requests coming from github
Currently almost all calls against API are being rate limited, including
build status images. This leads to common requesters such as GitHub's
camo proxy to get rate limited and receive a 429 response code.

This patch attempts to allow those requests.
2016-06-29 10:53:27 +02:00
Igor Wiedler
1f56dcc645 replace WHITELIST terminology with SAFELIST 2016-06-29 10:53:27 +02:00
Ana Rosas
14625ff7cb Merge pull request #282 from travis-ci/ar-add-enabled-for-all-flag
Add enable_for_all? condition on restart and cancel endpoints
2016-06-28 12:27:02 -07:00
Ana Rosas
69f0a9d33e Add enable_for_all? condition 2016-06-28 11:35:47 -07:00
Ana Rosas
0e5aa2fb7a Merge pull request #280 from travis-ci/ar-improve-feature-flag
[feature flag] Check for repository owner instead of current user
2016-06-24 13:32:26 -05:00
Ana Rosas
bfb68bf931 Merge branch 'master' into ar-improve-feature-flag 2016-06-23 17:07:36 -05:00
Ana Rosas
69cc2eef7d Check for repository owner instead of current user to validate feature flag 2016-06-23 15:15:31 -05:00
Piotr Sarnacki
16a7da54c2 Merge pull request #278 from travis-ci/ps-more-current-build-work
More `current_build` work
2016-06-23 10:05:55 +02:00
Joe Corcoran
0aeec35935 Fix duplicate lines from rebase 2016-06-22 16:59:49 +02:00
Joe Corcoran
769ae71076 Fix service specs 2016-06-22 16:50:11 +02:00
Piotr Sarnacki
32dd8d9f93 Mark current_build as experimental 2016-06-22 14:19:31 +02:00
Piotr Sarnacki
fcb0e7cde4 Rename current_build_id sort option to current_build 2016-06-22 14:19:31 +02:00
Joe Corcoran
88d9000042 Refactor repeated pattern into extracted method
Seems like we'll be checking login status before finding a resource
a lot, so here's a standard way to do it.
2016-06-21 15:34:11 +02:00
Joe Corcoran
81e93ca710 Better style in error handling 2016-06-21 15:34:11 +02:00
Joe Corcoran
00fb01bd7a Remove some duplication 2016-06-21 15:34:11 +02:00
Joe Corcoran
cae6da540f Add env vars endpoints
This adds API V3 endpoints for querying, creating, modifying and
deleting environment variables.

It has no concept of encryption yet and should be considered a work in
progress.

We should also talk about the slightly off-track approach in the
EnvVars::Create service – maybe there's a way to standardise the
querying and rendering for post requests?

2016-06-21 15:34:11 +02:00
Joe Corcoran
026dc4cb98 Use travis-settings to manage JSON settings field
Since we use repository.settings as a kind of dump for all
sorts of settings, some user-facing and some not, this lets us
leave the db as it is, but pretend to have separate models for each
"kind" of setting.
2016-06-21 15:33:05 +02:00
Sven Fuchs
cf5ea374d4 Merge pull request #277 from travis-ci/sf-cleanup-core
cleanup core
2016-06-21 15:28:39 +02:00
Sven Fuchs
dc176e0c0e remove commented callback code 2016-06-21 15:20:24 +02:00
Sven Fuchs
25f74defe5 try fixing updating github oauth scopes 2016-06-21 14:00:04 +02:00
Sven Fuchs
7250656de0 fix event notification 2016-06-21 12:16:43 +02:00
Sven Fuchs
6603990fe4 trigger sync in the auth endpoint, not the user model 2016-06-20 16:59:55 +02:00
Sven Fuchs
da4c7f26e6 fix auth endpoint 2016-06-20 15:04:38 +02:00
Sven Fuchs
060dd8aced delete github/find_or_create[org|repo|user] services 2016-06-20 11:26:47 +02:00
Sven Fuchs
84ebb6b24e move tracking github oauth scopes out of the user model, and into Travis::Github::Oauth 2016-06-19 17:33:03 +02:00
Sven Fuchs
734a7b9566 use travis-settings, remove travis/settings 2016-06-19 16:07:06 +02:00
Sven Fuchs
eb78d9df30 remove overwritable_method_definitions 2016-06-19 15:51:41 +02:00
Sven Fuchs
fb0493a33c delete commitcommand, request approval, branches, and states 2016-06-19 15:46:30 +02:00
Sven Fuchs
04cd5bea24 move travis.rb and travis/config to lib 2016-06-19 15:20:11 +02:00
Sven Fuchs
c6f6dd5f5a we can now run all specs in one go 2016-06-19 15:15:52 +02:00
Sven Fuchs
0f1e697abd delete github/services/sync_user and user_mailer, remove action_mailer 2016-06-19 15:04:39 +02:00
Sven Fuchs
a6658fa4d3 get rid of spec_helper_core 2016-06-19 14:35:54 +02:00
Sven Fuchs
a26c188822 move travis/api/serialize/* from core to lib 2016-06-18 18:01:09 +02:00
Sven Fuchs
51c6c8f58f move api/serializer to api/serialize/serializer 2016-06-18 17:58:36 +02:00
Sven Fuchs
81d8c64e98 rename api/v[0-2] to api/serialize/v[0-2] 2016-06-18 17:52:48 +02:00
Ana Rosas
4e858e3949 Merge pull request #265 from travis-ci/ar-enqueue-cancelling-jobs-builds
Enqueue messages for Hub to cancel Jobs/Builds | Modify restart endpoints
2016-06-15 16:22:05 +02:00
Ana Rosas
bf20506e09 Merge branch 'master' into ar-enqueue-cancelling-jobs-builds 2016-06-15 16:15:05 +02:00
Ana Rosas
41c274b222 Remove 'type' from payload 2016-06-15 14:36:59 +02:00
Tyranja
3cfac6a5c1 Merge pull request #267 from travis-ci/rlh-are-remove-core
Move the travis-core dependancy into vendor
2016-06-15 13:59:42 +02:00
Sven Fuchs
3508df01a9 fix rake spec task 2016-06-14 19:12:54 +02:00
Sven Fuchs
c0e57cc890 add dependencies from travis-core 2016-06-14 19:10:34 +02:00
Sven Fuchs
4155c8ebcd remove travis-core dependency from gemspec 2016-06-14 17:45:10 +02:00
Ana Rosas
5949429f75 Enqueue restart message on job/restart v3 endpoint 2016-06-14 17:39:29 +02:00
Ana Rosas
a2d1322b60 Enqueue cancel message on job/cancel v3 endpoint 2016-06-14 17:24:05 +02:00
Ana Rosas
bb7260bc9e Enqueue restart message on build restart v3 endpoint 2016-06-14 16:46:29 +02:00
Tyranja
91ca0efe03 Fix gemspec AGAIN 2016-06-14 15:31:07 +02:00
Tyranja
b36a6f8358 Fix gemspec AGAIN 2016-06-14 15:28:05 +02:00
Tyranja
06de527c63 Sort and uniq gemspec authors and emails 2016-06-14 15:20:45 +02:00
Tyranja
8f9d5e41b7 remove debugging output 2016-06-14 15:18:15 +02:00
Tyranja
2624bd9e72 Revert "Removes the unused travis-core v0 code"
This reverts commit a68c0028d8e8dfb4a0e7f965e57fbc9e8686ba86.
2016-06-14 15:18:15 +02:00
Tyranja
56a59e4cc3 Adds debugging output for canceling jobs 2016-06-14 15:18:15 +02:00
Tyranja
c4e58c3e63 Add Commit_command back to vendor 2016-06-14 15:17:47 +02:00
Tyranja
341adbae21 Removes the unused travis-core v0 code 2016-06-14 15:17:47 +02:00
Sven Fuchs
feb4bcd90f delete unused stuffz 2016-06-14 15:17:47 +02:00
Renée Hendricksen
0077b6414a fix sidekiq on this branch 2016-06-14 15:17:47 +02:00
Renée Hendricksen
489c404bbb updated gemspec 2016-06-14 15:17:47 +02:00
Renée Hendricksen
e467fa3e6d renamed the core spec directory 2016-06-14 15:17:47 +02:00
Renée Hendricksen
ce071ad728 log pattern got excluded 2016-06-14 15:17:20 +02:00
Renée Hendricksen
5776e13385 wrong ruby in travis file 2016-06-14 15:17:20 +02:00
Renée Hendricksen
62f0bf7081 this is needed too 2016-06-14 15:17:20 +02:00
Renée Hendricksen
1ca54b361f github didn't have the correct version 2016-06-14 15:17:20 +02:00
Renée Hendricksen
4b6c177311 moved travis-core to vendor 2016-06-14 15:17:20 +02:00
Renée Hendricksen
7691d04de0 all the dep warnings 2016-06-14 15:16:51 +02:00
Renée Hendricksen
a02995e357 some more dep warnings 2016-06-14 15:16:15 +02:00
Renée Hendricksen
7c3c6bd1a9 passing specs 2016-06-14 15:16:15 +02:00
Ana Rosas
e097c8889e Enqueue cancel message on build cancel v3 endpoint 2016-06-14 15:15:59 +02:00
Tyranja
0f2c7e0307 Update rspec due to deprecation warnings 2016-06-14 15:14:11 +02:00
Renée Hendricksen
cecc501255 working service specs 2016-06-14 15:14:11 +02:00
Renée Hendricksen
5a8c1e63c4 update the gemspec 2016-06-14 15:14:11 +02:00
Renée Hendricksen
692308837d use the default rake task 2016-06-14 15:11:58 +02:00
Renée Hendricksen
3b490b58cb run both tests 2016-06-14 15:11:58 +02:00
Renée Hendricksen
e77be8210f working core specs 2016-06-14 15:11:58 +02:00
Renée Hendricksen
9ed43941fd updates for v3 approved by rkh and spruce up the model tests 2016-06-14 15:11:58 +02:00
Tyranja
e1f7921223 Change Database configuration to make the test pass 2016-06-14 15:11:58 +02:00
Renée Hendricksen
ae133e649a use the core spec helper 2016-06-14 15:10:40 +02:00
Tyranja
3b6ab6fb71 Copies spec from core 2016-06-14 15:10:40 +02:00
Ana Rosas
75460b2427 Use Travis::Enqueue::Services::CancelModel on v3 build cancel endpoint 2016-06-13 18:16:16 +02:00
Ana Rosas
777e42374c Auto-merged master into ar-enqueue-cancelling-jobs-builds on deployment. 2016-06-09 14:53:10 +02:00
carlad
b67c226515 Merge pull request #275 from travis-ci/jc-v3-settings
Add settings to API V3
2016-06-09 14:51:06 +02:00
Joe Corcoran
5fee54b91b Fewer object allocations :) 2016-06-09 11:29:17 +02:00
Ana Rosas
1c99216e23 Fix merge conflicts 2016-06-08 17:51:48 +02:00
Joe Corcoran
eb0eab5967 Move settings to top level of response
To better accommodate nested responses.
2016-06-08 17:18:24 +02:00
Joe Corcoran
daf534edb7 Don't overwrite settings with defaults
Also changes the way the JSON fields are set to force ActiveRecord
to recognise the changes. Is there a better way?
2016-06-08 17:13:05 +02:00
Joe Corcoran
fba9a87c39 Add settings to API V3
This adds /repo/{repository.id}/settings endpoints for reading
and updating repo settings.

Main points:

1. Sets up Settings as a first class resource instead of as an
   attribute of Repository
2. Adds new meta-programmed method to Query for accessing all
   prefixed params as a hash.
2016-06-08 15:59:52 +02:00
Ana Rosas
05f926b0ec Merge pull request #264 from travis-ci/ar-enqueue-restarting-jobs
Enqueue restarting Jobs and Builds for Hub
2016-06-07 14:23:40 +02:00
Ana Rosas
6656b5d0aa Merge branch 'master' into ar-enqueue-restarting-jobs 2016-06-07 11:23:04 +02:00
Buck Doyle
b649bb5a0f Remove duplicated sorting configuration (#274)
As noted by @rkh in the API introduction.
2016-06-06 15:08:00 -04:00
Ana Rosas
24865ee322 Merge branch 'master' into ar-enqueue-restarting-jobs 2016-06-06 18:22:06 +02:00
Piotr Sarnacki
686e3c9baf Merge pull request #273 from travis-ci/fix-sorting-by-current-build
Rename current_build sort to current_build_id
2016-06-06 16:48:05 +02:00
Piotr Sarnacki
7317d6b265 Rename current_build sort to current_build_id
This a quick workaround for sorting by current_build. When the field
that we use to sort is the same as one of the associations name API V3
will try to join the association. So in this case it will try to join
:current_build, which fails. This needs a better solution, but I want to
get this working for now.
2016-06-06 16:40:41 +02:00
Ana Rosas
3a58979e43 Merge branch 'master' into ar-enqueue-restarting-jobs 2016-06-06 15:21:53 +02:00
Piotr Sarnacki
b1de9d569c Merge pull request #272 from travis-ci/fix-sorting-by-current-build
Specify a table when sorting by current_build_id
2016-06-06 14:23:31 +02:00
Piotr Sarnacki
dbe0a75a22 Specify a table when sorting by current_build_id
Otherwise in some circumstances postgres may complain about
disambiguity.
2016-06-06 14:13:46 +02:00
Ana Rosas
8b9df97e3f Merge branch 'master' into ar-enqueue-restarting-jobs 2016-06-06 11:04:44 +02:00
carlad
9df4dc02cf Merge pull request #266 from HPI-BP2015H/cron-time
return created_at of cron
2016-06-03 15:37:10 +02:00
Christopher Weyand
7200744879 Merge branch 'master' into cron-time 2016-06-03 15:32:52 +02:00
Igor
92dd9a5ce0 Merge pull request #269 from travis-ci/igor-ruby-version
Use .ruby-version file instead of ruby statement in Gemfile
2016-06-03 12:10:49 +02:00
Igor Wiedler
bec9f35e69 Use .ruby-version file instead of ruby statement in Gemfile 2016-06-02 19:22:16 +02:00
carlad
2303db9f4f add info about developer.travis-ci.org 2016-06-02 16:46:39 +02:00
Ana Rosas
1c9212ef08 Refacto on restart endpoint for Jobs 2016-06-01 14:57:55 +02:00
Renée Hendricksen
794e2d70af Merge pull request #268 from travis-ci/fix-api-sentry-connection
Fix api sentry connection
2016-05-31 11:36:57 +02:00
Ana Rosas
0038197aab Assign variable before if statement 2016-05-30 18:10:11 +02:00
Renée Hendricksen
574dfab772 fix the error - it's reporting to Sentry - Yay 2016-05-30 18:07:54 +02:00
Renée Hendricksen
8c6477c247 try another spot to throw and error 2016-05-30 18:05:25 +02:00
Renée Hendricksen
ace3e588ea forgot this and it's not tested 2016-05-30 17:57:48 +02:00
Renée Hendricksen
a8b70f51f3 code error we want to see on staging 2016-05-30 17:51:04 +02:00
Renée Hendricksen
21c714ae97 fix the test 2016-05-30 17:31:37 +02:00
Renée Hendricksen
d7d8e3bbe3 use the method directly 2016-05-30 17:26:44 +02:00
Renée Hendricksen
2ded8ac2be some changes to get errors to report to Sentry 2016-05-30 17:16:27 +02:00
Ana Rosas
8655fd19ce Refacto endpoint 2016-05-30 17:07:17 +02:00
Ana Rosas
6de524d84c Enqueue restarting jobs for the Hub 2016-05-30 17:07:17 +02:00
Renée Hendricksen
0e43360f1d ignore my gemset 2016-05-30 15:31:19 +02:00
Christopher Weyand
799d757625 cron representation change tests 2016-05-30 11:26:06 +02:00
Christopher Weyand
504be84f27 cron return created_at 2016-05-30 10:02:21 +02:00
Ana Rosas
68daabafa0 Use only params[:id] 2016-05-27 17:52:55 +02:00
Ana Rosas
00bae7a945 Remove push_matrix method, no need of it 2016-05-27 16:41:07 +02:00
Ana Rosas
29f80ab31b Use CancelModel on Jobs endpoint 2016-05-27 16:15:41 +02:00
Ana Rosas
ef7811ead9 Small refacto 2016-05-27 16:10:16 +02:00
Ana Rosas
c3e0d6d6bb Use CancelModel in Builds endpoint 2016-05-27 15:57:19 +02:00
Ana Rosas
428422d569 Add enqueue service for canceling jobs and builds 2016-05-27 12:44:48 +02:00
Ana Rosas
fa50bd13de Abstract enqueue restart service, to use it with Jobs and Builds 2016-05-26 17:45:31 +02:00
Ana Rosas
1863f5bd0c Enqueue restarting jobs for the Hub 2016-05-26 17:45:31 +02:00
Josh Kalderimis
efb9d899b2 Signal Sciences support (#254)
* test out setting up signal sciences

* tweak the signalsciences config a little

* try out the updated signal sciences heroku integration

* use the old ngnix start script, as signalsciences is now nginx based

* make sure sigsci conf is included in our custom nginx config

* remove the custom port stuff, no longer needed
2016-05-26 17:44:12 +02:00
carlad
6e51368525 Merge pull request #263 from travis-ci/cd-cron-error
add error rescue for cron start method
2016-05-24 15:55:20 +02:00
carlad
e62ba7722e Merge branch 'master' into cd-cron-error 2016-05-24 15:46:35 +02:00
Ana Rosas
276a61759d Merge pull request #261 from travis-ci/ar-migrate-restart-builds
Enqueue restarting builds/jobs for Hub
2016-05-24 08:36:46 -05:00
carlad
1d3a2ebb67 add error rescue for cron start method 2016-05-24 15:20:40 +02:00
Ana Rosas
3c253bb88c Move stub to before block on restart test 2016-05-23 15:07:33 -05:00
Ana Rosas
2b37d90ffb Add permission methods to enqueue_build 2016-05-23 15:07:33 -05:00
Ana Rosas
9bd145856b Add feature flag to enqueue restart build to Hub 2016-05-23 15:07:33 -05:00
Ana Rosas
9bbfb7ec97 Add an equeue service 2016-05-23 15:07:33 -05:00
Ana Rosas
28884f9931 Enqueue build_restart event in Hub 2016-05-18 15:11:04 -05:00
Igor
e876a83d86 Merge pull request #260 from travis-ci/igor-cors-preflight-cache
Set Access-Control-Max-Age header for CORS preflight requests to cache them
2016-05-18 13:56:09 +02:00
Igor Wiedler
2a66505aca Set Access-Control-Max-Age header for CORS preflight requests to cache them (refs travis-pro/post-its#169) 2016-05-18 12:26:06 +02:00
Piotr Sarnacki
1615928c68 Bump travis-core 2016-05-17 16:15:27 +02:00
Piotr Sarnacki
5cade805e0 Merge pull request #259 from travis-ci/ps-current-build2
Add current_build to repositories payload
2016-05-17 14:20:22 +02:00
Piotr Sarnacki
659dc4d992 Add current_build to repositories payload
This commit adds current_build (which is based on
repositories.current_build_id) to repositories payload. It also adds
ability to sort by current_build.
2016-05-17 14:11:09 +02:00
Konstantin Haase
754101e9af Merge pull request #258 from lucascherifi/patch-1
Update README.md
2016-05-17 11:58:17 +02:00
Lucas CHERIFI
654185538f Update README.md 2016-05-16 03:56:10 +02:00
Piotr Sarnacki
13d9c97501 Revert "Merge pull request #257 from travis-ci/ps-current-build"
This reverts commit 52bebad05c, reversing
changes made to 9d386efa4c.
2016-05-11 17:13:40 +02:00
Piotr Sarnacki
52bebad05c Merge pull request #257 from travis-ci/ps-current-build
Add current_build to repositories payload
2016-05-11 17:00:35 +02:00
Piotr Sarnacki
c9b93982c9 Add current_build to repositories payload
current_build is the most recent build that is either completed or
running
2016-05-11 16:55:47 +02:00
Ana Rosas
9d386efa4c Bump travis-core 2016-05-09 11:19:22 -05:00
Konstantin Haase
168bc39d2a add command to procfile 2016-04-28 15:15:57 +02:00
Konstantin Haase
7f437f9d27 Merge pull request #255 from HPI-BP2015H/start-cron
script to start all due cron jobs
2016-04-28 15:13:06 +02:00
Steffen Kötte
ea838dd246 script to start all due cron jobs 2016-04-27 14:31:09 +02:00
Konstantin Haase
0458482fdf Merge pull request #225 from HPI-BP2015H/cronjobs
Cronjobs
2016-04-22 15:05:52 +02:00
carlad
d21fc58955 Merge pull request #253 from travis-ci/cd-after-number
bump travis-core to deal with `/builds?after_number` problem
2016-04-22 14:54:05 +02:00
carlad
4ec8e1acdc bump travis-core use master 2016-04-22 14:45:53 +02:00
carlad
c6ddffc85a bump travis core 2016-04-22 14:01:46 +02:00
carlad
732e8a956d bump travis-core for builds after number fix 2016-04-22 13:46:18 +02:00
Steffen
f186c16669 Merge branch 'master' into cronjobs 2016-04-22 10:33:40 +02:00
Konstantin Haase
0593c55ef6 Merge pull request #252 from travis-ci/cd-v3
v3 - add validation check to build and job cancel and restart
2016-04-20 14:56:45 +02:00
carlad
7b5c11fca6 add specs, update error names 2016-04-20 14:31:08 +02:00
carlad
63bef443e8 update build_cancel spec 2016-04-20 11:55:03 +02:00
carlad
30d73782c8 add error check to build restart and cancel 2016-04-20 11:33:20 +02:00
carlad
379a63bf00 fix spelling of canceled, remove debug output 2016-04-20 11:08:29 +02:00
carlad
ec217a58f1 correct typo 2016-04-19 18:29:46 +02:00
carlad
506e0f0f7a add check for state on job restart and cancel 2016-04-19 15:26:28 +02:00
carlad
ec62a5b918 merge 2016-04-19 12:39:00 +02:00
Steffen
13aa741e57 Merge branch 'master' into cronjobs 2016-04-18 09:42:36 +02:00
Konstantin Haase
78f36320a7 Merge pull request #251 from travis-ci/cd-requests-branch-name
V3 add branch_name for request
2016-04-15 17:31:04 +02:00
carlad
00aaf32b1e add branch_name for request 2016-04-15 17:22:41 +02:00
Hiro Asari
93bc69dc9d Update travis-core and thor
In particular, include https://github.com/travis-ci/travis-core/pull/538
to fetch GCS caches
2016-04-14 08:11:57 -10:00
Steffen Kötte
7e7f1b212b refactor cron start 2016-04-14 12:53:23 +02:00
carlad
27f18d77ac rename branch, add method to model 2016-04-14 11:26:51 +02:00
carlad
a67f6bb2ea Merge branch 'cd-v3' of github.com:travis-ci/travis-api into cd-v3 2016-04-14 11:15:36 +02:00
carlad
55f8378940 add branch_name method 2016-04-14 11:15:17 +02:00
carlad
866fd2a617 Auto-merged master into cd-v3 on deployment. 2016-04-14 10:43:36 +02:00
carlad
d522072705 Merge branch 'cd-v3' of github.com:travis-ci/travis-api into cd-v3 2016-04-14 10:40:49 +02:00
carlad
c22998fdcf add branch_name to request renderer 2016-04-14 10:39:59 +02:00
carlad
6b7526dd7e remove request endpoint 2016-04-14 10:19:28 +02:00
carlad
845f02d8d9 add request endpoint 2016-04-14 10:14:20 +02:00
Steffen Kötte
0b2585de45 remove cronjobs and disallow creating if branch does no longer exist on GitHub 2016-04-12 11:33:30 +02:00
Konstantin Haase
72c204883f Merge pull request #247 from HPI-BP2015H/readme_update
Readme update
2016-04-11 15:51:05 +02:00
Steffen
1b9b422753 remove text from code block 2016-04-08 09:55:32 +02:00
Christopher Weyand
c6d9e5ad7d Merge remote-tracking branch 'travis/master' into readme_update
Conflicts:
	README.md
2016-04-07 16:00:33 +02:00
Piotr Sarnacki
efe26b03a1 Bump travis-core 2016-04-07 11:43:46 +02:00
Piotr Sarnacki
dc4d6f0208 Bump travis-core 2016-04-07 11:40:44 +02:00
carlad
482f037438 Update README.md 2016-04-06 15:03:12 +02:00
Josh Kalderimis
357257b654 Merge pull request #246 from travis-ci/ha-chore-bundle-update
Update travis-core
2016-04-05 20:32:34 +02:00
Hiro Asari
1f0d26a01c Update travis-core
In particular, to include https://github.com/travis-ci/travis-core/pull/530
2016-04-05 08:27:34 -10:00
carlad
ce1ba54f77 Merge pull request #245 from travis-ci/ar-cd-rate-setting
Use Travis.config to retrieve default values for api_builds_rate_limit
2016-04-05 17:33:22 +02:00
Ana Rosas
03e992885e Bump travis-core 2016-04-05 17:28:00 +02:00
Ana Rosas
228b594237 Return LIMIT if everything else fails 2016-04-05 17:09:48 +02:00
Ana Rosas
11ceaed333 Test default limit 2016-04-05 16:47:33 +02:00
Ana Rosas
679bbd7901 Use LIMIT constant as a backup limit number 2016-04-05 16:27:45 +02:00
Ana Rosas
4556130acb Merge branch 'master' into ar-cd-rate-setting 2016-04-05 15:30:16 +02:00
Ana Rosas
407d2abea1 Use Travis.config to retrieve default values for api_builds_rate_limit 2016-04-05 15:29:49 +02:00
Steffen
7922ca8e84 Merge branch 'master' into cronjobs 2016-04-05 15:23:03 +02:00
carlad
e4b1562039 Merge pull request #244 from travis-ci/ar-cd-rate-setting
Update api builds rate limit condition to get higher rate for .com
2016-04-05 12:35:10 +02:00
Ana Rosas
a37acda0a0 Merge branch 'master' into ar-cd-rate-setting 2016-04-05 12:30:41 +02:00
Ana Rosas
5fc096f68b Update rate limit condition 2016-04-05 12:29:35 +02:00
carlad
9f9c5bf789 Update README.md 2016-04-05 11:43:40 +02:00
carlad
855997aba8 Merge pull request #243 from travis-ci/ar-cd-rate-setting
Add api builds rate limit to API
2016-04-05 10:29:35 +02:00
Ana Rosas
cab8534b4a Fix merge conflicts 2016-04-04 16:38:20 +02:00
carlad
7f4d67ea8d remove core pointing to branch 2016-04-04 16:21:16 +02:00
Ana Rosas
0e8fe08f7c Update limit method and finish test 2016-04-04 16:13:14 +02:00
Steffen
a522607673 Merge branch 'master' into cronjobs 2016-04-04 10:39:55 +02:00
Steffen Kötte
31f6b5793a refactor cron model and create service 2016-04-04 10:27:06 +02:00
Steffen
c49819ca52 add missing sudo 2016-04-01 16:22:29 +02:00
Lennard Wolf
bc42810a53 updated README to a functioning state. 2016-04-01 16:03:09 +02:00
Tyranja
6e3577401e Merge pull request #242 from travis-ci/ar-bump-core
Bump travis-core
2016-04-01 12:05:52 +02:00
carlad
24b2abdfd0 add .rspec for formatting, add new test (still broken) 2016-03-31 17:15:43 +02:00
carlad
f51cf1a1d1 update rakefile to allow heroku deployment, update create.rb with api builds rate limit 2016-03-31 16:54:12 +02:00
carlad
d6c0621d71 remove fail from rake tasks to allow heroku deployment 2016-03-31 15:55:17 +02:00
carlad
49a6bb5d26 add debug to see what request contains 2016-03-31 15:51:44 +02:00
Tyranja
2f870e6826 Bump travis-core 2016-03-30 16:35:34 +02:00
Tyranja
7ca67875b4 Merge pull request #241 from travis-ci/cd-fix-rake-problem
add better condition check for rake
2016-03-30 12:31:22 +02:00
carlad
d1848ba6f9 make settings visible in repository 2016-03-30 12:30:26 +02:00
carlad
1dd47df6bf add better condition check for rake 2016-03-30 12:18:05 +02:00
Steffen Kötte
9734e7133f fix feature flag for_branch endpoint 2016-03-29 16:51:00 +02:00
carlad
a466f0c819 Merge pull request #240 from travis-ci/sf-unsmart-helpers
Unsmart helpers, middlewares, and endpoints
2016-03-24 17:41:10 +01:00
carlad
f2d3758e09 Merge branch 'master' into sf-unsmart-helpers 2016-03-24 17:20:37 +01:00
Sven Fuchs
75937e45ee Remove load_endpoints, too 2016-03-24 17:03:55 +01:00
Sven Fuchs
e183401888 Merge pull request #238 from travis-ci/cd-rakefile
Clean up the Rakefile
2016-03-24 16:33:23 +01:00
carlad
f1b3101ac7 Merge branch 'cd-rakefile' of github.com:travis-ci/travis-api into cd-rakefile 2016-03-24 16:19:14 +01:00
carlad
bcdd15f4cf fix typo 2016-03-24 13:41:27 +01:00
carlad
aa211be12a update readme 2016-03-24 13:39:41 +01:00
Sven Fuchs
30b8f2d772 unsmart requiring helpers 2016-03-24 12:53:57 +01:00
carlad
55287b23df Merge branch 'master' into cd-rakefile 2016-03-23 17:00:23 +01:00
carlad
7a95dabe95 Merge branch 'master' into cd-rakefile 2016-03-23 14:55:00 +01:00
Piotr Sarnacki
4db60de568 Merge pull request #239 from travis-ci/sf-unsmart-extensions
Unsmart loading app extensions
2016-03-23 14:48:21 +01:00
Sven Fuchs
2db04f068c unsmart loading app extensions 2016-03-23 14:42:39 +01:00
carlad
1d6ed1e364 fix incorrect db name 2016-03-23 14:16:48 +01:00
carlad
dd82c14f5b refactor db create, move migrations into dev/test group 2016-03-23 14:09:29 +01:00
carlad
f8bee8f801 clean up rakefile, update gemspec 2016-03-23 13:13:22 +01:00
carlad
40c4c0d7ef Merge pull request #237 from travis-ci/cd-revert
This reverts master to commit 354fa83e so that /lint endpoint chances can be deployed
2016-03-22 14:10:33 +01:00
Steffen Kötte
69df412aa1 Merge branch 'master' into cronjobs
# Conflicts:
#	Gemfile
#	Gemfile.lock
2016-03-22 14:02:42 +01:00
carlad
8085710646 move travis-migrations into main group 2016-03-22 13:58:58 +01:00
Konstantin Haase
5af88d005c Revert "add buildpack url"
This reverts commit 197120a9eb.
2016-03-22 13:58:58 +01:00
carlad
1dd8b6aec5 add buildpack url 2016-03-22 13:58:58 +01:00
Sven Fuchs
1af7cd5f45 use travis-amqp 2016-03-22 13:58:58 +01:00
Sven Fuchs
1e69683c3c bump sentry-raven 2016-03-22 13:58:58 +01:00
Sven Fuchs
ba0e43c75a require raven/integrations/rack 2016-03-22 13:58:58 +01:00
Sven Fuchs
82b8512f41 do not require all of rack/contrib, it now assumes a git repository 2016-03-22 13:58:58 +01:00
Jonas Chromik
ca82725e5e move cron jobs feature flag to permissions 2016-03-22 13:48:51 +01:00
carlad
569a1d3967 Merge pull request #227 from travis-ci/sf-ar-te
Changes for the travis-enterprise release
2016-03-22 12:43:49 +01:00
Tyranja
92ec0e352a Auto-merged master into sf-ar-te on deployment. 2016-03-22 12:37:52 +01:00
carlad
9235f1057d Merge branch 'master' of github.com:travis-ci/travis-api 2016-03-22 12:36:02 +01:00
carlad
71813bf92a move travis-migrations into main group 2016-03-22 12:35:28 +01:00
carlad
b552544d19 revert 2016-03-22 12:27:34 +01:00
Konstantin Haase
48880ad184 Revert "add buildpack url"
This reverts commit 197120a9eb.
2016-03-22 12:27:10 +01:00
carlad
197120a9eb add buildpack url 2016-03-22 12:09:33 +01:00
Tyranja
11ef8d1a61 Auto-merged master into sf-ar-te on deployment. 2016-03-22 12:02:30 +01:00
Steffen Kötte
c037ec7aa3 refactor planned time calculation into separate methods 2016-03-22 10:17:23 +01:00
Jonas Chromik
462a3618e1 update Gemfile.lock to use new migrations 2016-03-21 17:21:57 +01:00
Jonas Chromik
fe76d38230 Merge branch 'master' into cronjobs 2016-03-21 17:08:33 +01:00
carlad
354fa83e42 Merge pull request #224 from travis-ci/cd-v3
Adding `/lint` endpoint
2016-03-21 17:04:36 +01:00
Tyranja
2de73fd974 Merge branch 'master' of github.com:travis-ci/travis-api 2016-03-21 15:48:33 +01:00
carlad
6b145e6f06 update lint service, update spec 2016-03-21 15:39:14 +01:00
Steffen Kötte
7215151403 adjust new test to include cron permission 2016-03-21 10:37:06 +01:00
Steffen Kötte
ac0012b0a2 Merge commit '8a050a468c77f2ad8c5faa99864c0bd7d61b08a0' into cronjobs
# Conflicts:
#	Gemfile
2016-03-21 10:32:46 +01:00
carlad
f940bffe3f more work on lint endpoint 2016-03-18 16:43:18 +01:00
carlad
69852d18b3 Merge branch 'master' into cd-v3 2016-03-18 13:49:22 +01:00
Piotr Sarnacki
8a050a468c Use shared logs model to establish connection
That way we will use only one connection to the logs database
2016-03-17 13:07:25 +01:00
Piotr Sarnacki
5294f1dab2 Bump travis-core 2016-03-17 13:00:29 +01:00
Piotr Sarnacki
f0dcf270bc Always convert pool size to integer 2016-03-17 11:59:34 +01:00
Piotr Sarnacki
6aaa25a099 Overwrite database pool size for logs database
Logs database config is set in travis keychain and is set to a
concurrency much higher than what we set in heroku config. I don't want
to change it globally, because it may need to be different for other
apps, so I'm changing it here just before we connect to the db.
2016-03-17 11:45:46 +01:00
Piotr Sarnacki
f2c96b3eb5 Set sidekiq pool size also for logs DB 2016-03-17 11:27:42 +01:00
Piotr Sarnacki
5682502cba Bump travis-core 2016-03-17 11:14:46 +01:00
Piotr Sarnacki
8ca1c4d824 Merge pull request #236 from travis-ci/allow-to-set-sidekiq-concurrency-separately
Allow to set sidekiq concurrency separately from web workers
2016-03-17 11:09:34 +01:00
Piotr Sarnacki
b68c7a33b0 Allow to set sidekiq concurrency separately from web workers
Unicorn, which we use to serve the API, uses forked workers that need
only one connection per instance. Sidekiq on the other hand runs several
instances in memory, so it needs a higher concurrency setting. This
commit introduces a way to set sidekiq db pool using
SIDEKIQ_DB_POOL_SIZE
2016-03-17 10:57:15 +01:00
carlad
55621067cc Merge pull request #235 from travis-ci/cd-fix-spam-reqs
Remove hard coded request path to allow whitelisted request paths
2016-03-16 15:38:38 +01:00
carlad
7e438be4cf remove hard coded request path 2016-03-16 15:20:41 +01:00
carlad
4462613c46 Merge branch 'master' into cd-v3 2016-03-15 12:12:36 +01:00
carlad
06cf863fec Merge pull request #234 from travis-ci/cd-statement-timeout
bump travis-core to reinstate statement_timeout config variable
2016-03-14 17:10:08 +01:00
carlad
e1fefaf456 bump travis-core statement_timeout 2016-03-14 16:29:41 +01:00
carlad
ac400906a1 bump travis-core for db statement_timeout config 2016-03-14 14:59:33 +01:00
carlad
da0576d995 Merge branch 'master' into cd-v3 2016-03-14 13:36:46 +01:00
carlad
07dd57845b Merge pull request #233 from travis-ci/cd-last-build-sort
Add ability to sort repos by default_branch.last_build
2016-03-14 13:29:06 +01:00
carlad
643ca01ee5 user repo2 again 2016-03-14 13:24:01 +01:00
carlad
156a6ebb98 set repo id 2016-03-14 13:04:34 +01:00
carlad
74b43d5e89 use repo2 2016-03-14 12:58:46 +01:00
carlad
087788757f add repo.id to spec 2016-03-14 12:56:01 +01:00
Jonas Chromik
5663410c45 minor changes 2016-03-14 12:50:39 +01:00
carlad
5cb5fdb8d6 update spec to create additional repo for sorting test 2016-03-14 12:14:10 +01:00
Christopher Weyand
dd7e74950d revert gemspec 2016-03-14 11:11:18 +01:00
Christopher Weyand
6c839aebec feature flag test 2016-03-14 11:03:41 +01:00
carlad
3a97ac8bfa add spec for sort by default_branch.last_build 2016-03-11 15:17:06 +01:00
carlad
f512975e6a change sort to builds.started_at 2016-03-11 15:05:46 +01:00
carlad
b784eaee82 add sort_by default_branch.last_build builds.id 2016-03-11 14:41:24 +01:00
carlad
3182513798 add sort_by default_branch builds.id 2016-03-11 14:39:28 +01:00
carlad
7a7e957b80 Merge branch 'master' into cd-v3 2016-03-11 11:36:19 +01:00
Hiro Asari
189bf99b18 Merge pull request #230 from travis-ci/ha-feature-debug-endpoint
Add `/job/:job_id/debug` endpoint
2016-03-08 09:09:33 -10:00
Hiro Asari
593c6edaa6 Merge branch 'master' into ha-feature-debug-endpoint 2016-03-08 08:57:57 -10:00
carlad
c0e01c46d2 Merge branch 'master' into cd-v3 2016-03-08 17:03:40 +01:00
carlad
e99fd09e2d Merge pull request #232 from travis-ci/cd-coreless-migrations
bump travis-migrations
2016-03-08 16:06:33 +01:00
carlad
41ef072a94 Merge branch 'master' into cd-coreless-migrations 2016-03-08 16:00:47 +01:00
carlad
6324bbeef8 bump travis-migrations 2016-03-08 15:58:47 +01:00
carlad
a45178c67d Merge pull request #228 from travis-ci/cd-coreless-migrations
Make api use travis-migrations for test db
2016-03-08 12:51:44 +01:00
Hiro Asari
aaed416238 Point to travis-core master branch
https://github.com/travis-ci/travis-core/pull/519 has been merged,
so there is no need for a special branch
2016-03-07 16:51:35 -10:00
Hiro Asari
73f724c58c Add more specs for /job/:job_id/debug
We now rely on https://github.com/travis-ci/travis-core/pull/519.
2016-03-07 16:36:33 -10:00
Hiro Asari
d944fe347a Add /job/:job_id/debug spec 2016-03-07 11:51:26 -10:00
Hiro Asari
ba142b84c7 Put debug options in debug_otions
This depends on https://github.com/travis-ci/travis-migrations/pull/7
2016-03-04 09:04:58 -10:00
Hiro Asari
05e860dd35 Fix #active? invocation
Second arg is repository
2016-03-03 15:21:37 -10:00
Hiro Asari
56ea1d6663 Raise if debug feature is unavailable 2016-03-03 10:12:48 -10:00
Hiro Asari
5b25683ce8 Merge remote-tracking branch 'origin/master' into ha-feature-debug-endpoint 2016-03-02 15:04:54 -10:00
Hiro Asari
ca09547452 Access job via attr_reader 2016-03-02 15:00:57 -10:00
Hiro Asari
d1e07f10f0 Accept 'quiet' param for /job/:job_id/debug endpoint 2016-03-02 15:00:57 -10:00
Piotr Sarnacki
fa8520eb25 Revert "Hardcode database pool size for sidekiq"
This reverts commit b6b1d12f48.

The pool size can be set with DATABASE_POOL_SIZE ENV var on heroku. I
set it to 5, so it's ok, to revert this change.
2016-03-02 16:14:01 +01:00
Piotr Sarnacki
b6b1d12f48 Hardcode database pool size for sidekiq
For some reason pool is set to 1 and I can't find the source of this
setting, so for now, just to fix the immediate problem I'm setting it
manually in sidekiq.rb
2016-03-02 15:17:16 +01:00
Hiro Asari
82b95440b2 Fix previous_status → previous_state, and set value correctly 2016-02-29 16:15:01 -10:00
Hiro Asari
89487c09ca Fix specs to account for new 'debug' permissions 2016-02-29 15:08:08 -10:00
Hiro Asari
80cb945557 Remove superfulous method 2016-02-29 14:27:57 -10:00
Hiro Asari
e6d39c2a52 Restart job via V3 query 2016-02-29 14:24:09 -10:00
Hiro Asari
1ee5421d3f Fix up Debug service 2016-02-29 12:44:17 -10:00
Hiro Asari
2196acb36d Use V3 services for debug route 2016-02-29 12:40:51 -10:00
Hiro Asari
8490e9f9ce Debug output 2016-02-29 12:26:19 -10:00
Hiro Asari
022089adc8 Implement bare-bones /jobs/:job_id/debug endpoint 2016-02-29 12:04:06 -10:00
Hiro Asari
f319dfbf65 Update travis-yaml 2016-02-25 16:06:32 -10:00
Konstantin Haase
fa5f65606e Merge pull request #229 from travis-ci/error-handling
create MethodNotAllowed error
2016-02-25 15:21:07 +01:00
Lisa P
0448427136 create error in v3.rb 2016-02-25 15:06:45 +01:00
Lisa P
ab1bfe0aeb create MethodNotAllowed error 2016-02-25 14:40:53 +01:00
Steffen Kötte
ca5820e2e3 send user id with cron build payload 2016-02-25 13:49:12 +01:00
carlad
54572a5ded update readme with info about db name 2016-02-24 23:42:50 +01:00
Piotr Sarnacki
2b89f7ac30 Merge pull request #219 from travis-ci/add_default_branch_info_to_jobs_and_builds
Add branch_is_default info to commits
2016-02-23 15:40:44 +01:00
Steffen Kötte
77ec852be6 send empty credentials hash 2016-02-11 14:43:33 +01:00
carlad
ec8ef98c0d Merge branch 'cd-coreless-migrations' of github.com:travis-ci/travis-api into cd-coreless-migrations 2016-02-11 10:32:00 +01:00
carlad
64f97a89d2 add db creation and migration for development, update readme 2016-02-11 10:26:24 +01:00
carlad
6ab0ec3c3a reinstate rake tasks that are still needed 2016-02-11 10:26:24 +01:00
carlad
9744f59fe2 restore original db config 2016-02-11 10:26:24 +01:00
carlad
14b7159109 remove db:migrate 2016-02-11 10:26:24 +01:00
carlad
c1d6441c7e try new rakefile 2016-02-11 10:26:24 +01:00
carlad
e283140d02 fix dump override 2016-02-11 10:26:24 +01:00
carlad
25bd6b88b7 add structure dump override 2016-02-11 10:26:24 +01:00
carlad
4d98ccafd6 new rakefile 2016-02-11 10:26:24 +01:00
carlad
14ec02da79 remove schema 2016-02-11 10:26:24 +01:00
carlad
e2e222ab7c update before script 2016-02-11 10:26:24 +01:00
carlad
179b166de4 update before script 2016-02-11 10:26:24 +01:00
carlad
1fb526de7e restore to previous 2016-02-11 10:26:24 +01:00
carlad
345921a98b move structure dump 2016-02-11 10:26:24 +01:00
carlad
15e3b84dca move require micro-migrations to top of file 2016-02-11 10:26:24 +01:00
carlad
84cfacadb6 fix struture dump syntax 2016-02-11 10:26:24 +01:00
carlad
16db162696 omit structure dump unless dev env 2016-02-11 10:26:24 +01:00
carlad
c13cabfbf3 add require travis 2016-02-11 10:26:24 +01:00
carlad
6c5c483166 use sql schema 2016-02-11 10:26:24 +01:00
carlad
5f32123891 comment out schema env definition 2016-02-11 10:26:24 +01:00
Konstantin Haase
797ca9f9fa v3: add metrics 2016-02-11 10:26:24 +01:00
Konstantin Haase
a66191c682 bump travis core 2016-02-11 10:26:24 +01:00
Konstantin Haase
416fcf2d4b Ruby 2.1.6 is no longer supported on Heroku 2016-02-11 10:26:24 +01:00
Konstantin Haase
8c3c4fe935 add ip whitelisting 2016-02-11 10:26:24 +01:00
Konstantin Haase
693e293909 make sure params is always a hash, fixes exceptions 2016-02-11 10:26:23 +01:00
carlad
277562e51c add db creation and migration for development, update readme 2016-02-11 10:13:05 +01:00
carlad
079cec3467 reinstate rake tasks that are still needed 2016-02-05 02:51:30 +01:00
carlad
8d1cd15ee2 restore original db config 2016-02-04 21:59:35 +01:00
carlad
54e2ca0300 remove db:migrate 2016-02-04 21:52:02 +01:00
carlad
b16ae846ad try new rakefile 2016-02-04 21:49:17 +01:00
carlad
979201794f fix dump override 2016-02-04 21:41:40 +01:00
carlad
cafb078c10 add structure dump override 2016-02-04 21:36:32 +01:00
carlad
c085354706 new rakefile 2016-02-04 21:27:20 +01:00
carlad
172156da59 remove schema 2016-02-04 21:17:12 +01:00
carlad
6f16091207 update before script 2016-02-04 21:13:12 +01:00
carlad
b82ca5e438 update before script 2016-02-04 21:10:21 +01:00
carlad
6e8606c01e restore to previous 2016-02-04 20:53:04 +01:00
carlad
66e63897a3 move structure dump 2016-02-03 06:45:27 +01:00
carlad
6b230828e6 move require micro-migrations to top of file 2016-02-03 06:32:40 +01:00
carlad
8d98f39e79 fix struture dump syntax 2016-02-03 06:27:35 +01:00
carlad
5e94e7436b omit structure dump unless dev env 2016-02-03 06:23:37 +01:00
carlad
5353ed027e add require travis 2016-02-03 06:12:15 +01:00
carlad
4833f41732 use sql schema 2016-02-03 06:08:31 +01:00
carlad
efab4be6de comment out schema env definition 2016-02-03 06:03:09 +01:00
carlad
a830bfe8ad Merge branch 'master' into cd-coreless-migrations 2016-02-03 05:32:53 +01:00
Steffen Kötte
8a6f4066ae refactor methods to calculate next build time 2016-02-01 17:08:11 +01:00
Steffen Kötte
3fa9c09c0c move cron creation to query 2016-02-01 16:50:10 +01:00
Steffen Kötte
0d1dbaadd7 move start all to query 2016-02-01 16:29:23 +01:00
Steffen Kötte
be01b36f05 move find cron for repository to query 2016-02-01 16:20:50 +01:00
Steffen Kötte
6fb0f7b6ce change error type 2016-02-01 16:08:33 +01:00
Steffen Kötte
98a75e5931 move find cron for branch to correct query 2016-02-01 15:23:15 +01:00
Steffen Kötte
d75daab82f move cron start to query 2016-02-01 15:13:34 +01:00
Steffen Kötte
64478d50d1 rename next_build_time to next_enqueuing 2016-01-28 13:46:35 +01:00
Steffen Kötte
24b0af35e9 move start cronjob to services 2016-01-28 13:16:53 +01:00
Steffen Kötte
05d2e4767e adjust cron API path 2016-01-28 13:01:28 +01:00
Tyranja
00db637788 Merge branch 'sf-ar-te' 2016-01-27 15:56:11 +01:00
Sven Fuchs
67d1d09569 use travis-amqp 2016-01-26 16:46:24 +01:00
Konstantin Haase
2c60a85fdb Merge pull request #226 from travis-ci/rkh-v3-metrics
v3: add metrics
2016-01-26 16:03:43 +01:00
Konstantin Haase
bf1714c437 v3: add metrics 2016-01-22 14:26:30 +01:00
Steffen
598ca6c2ca Merge branch 'master' into cronjobs 2016-01-21 13:39:43 +01:00
Steffen Kötte
2d2e7aa528 fix job enqueueing 2016-01-21 13:11:18 +01:00
Steffen Kötte
4704992a18 remove token from perform_async call 2016-01-21 10:40:43 +01:00
carlad
b572a1a50e updates 2016-01-20 11:31:05 +01:00
Steffen Kötte
da33cff0eb add more tests
add first version to start crons
adjust code to return now if cron is overdue
2016-01-18 16:59:10 +01:00
Steffen Kötte
9b24312445 Merge commit '43a2806b3ba410fc5bf3b3956e01879c96690c5b' into cronjobs 2016-01-18 13:51:48 +01:00
Steffen Kötte
2566a7761c add tests for next build time 2016-01-18 13:50:53 +01:00
Jonas Chromik
43a2806b3b Remove 'BUNDLED WITH [...]' in Gemfile.lock. 2016-01-18 12:35:10 +01:00
Jonas Chromik
3f11b08a25 Add timecop gem to Gemfile. 2016-01-18 12:27:29 +01:00
Konstantin Haase
1640c444de bump travis core 2016-01-15 15:45:26 +01:00
Steffen Kötte
e9356970f8 fix tests with output of next build date for cron jobs 2016-01-14 16:16:15 +01:00
Steffen Kötte
00e15de083 show next build time for cron 2016-01-14 16:12:27 +01:00
Sven Fuchs
3637061b76 bump sentry-raven 2016-01-12 13:58:21 +01:00
Sven Fuchs
7a5f477a0a require raven/integrations/rack 2016-01-12 13:52:01 +01:00
Steffen Kötte
ffcf8985c0 add tests for only one cron job per branch and interval value 2016-01-11 15:54:50 +01:00
Steffen Kötte
587ed37395 fix specs for new structure 2016-01-11 15:11:48 +01:00
carlad
0632c3d08f change run! to run 2016-01-11 15:03:06 +01:00
Steffen Kötte
68ba4b9fce check for correct interval
allow only one cronjob per branch
2016-01-11 14:54:02 +01:00
carlad
2d00e16962 remove query and permission 2016-01-11 14:43:23 +01:00
Steffen Kötte
0920041375 further changes for new structure with only one cron per branch 2016-01-11 14:14:00 +01:00
Sven Fuchs
9588f816b0 do not require all of rack/contrib, it now assumes a git repository 2016-01-08 14:31:49 +01:00
Steffen Kötte
b45b3fadf7 changes for new db structure 2016-01-07 15:00:08 +01:00
carlad
cf20650d39 fix syntax 2016-01-07 13:06:47 +01:00
carlad
089deeb217 add renderer for lint 2016-01-07 13:02:54 +01:00
carlad
01a86c1dd5 v3 remove put request type 2016-01-07 12:39:54 +01:00
carlad
43480752fa intial work on adding /lint endpoint 2016-01-07 12:34:10 +01:00
Steffen Kötte
e4aec173ee Merge commit 'bddd9952a74d1eddad5d5a255419e07c836b286d' into addCron
Conflicts:
	spec/v3/services/owner/find_spec.rb
	spec/v3/services/repositories/for_current_user_spec.rb
	spec/v3/services/repositories/for_owner_spec.rb
	spec/v3/services/repository/find_spec.rb
2015-12-17 10:11:20 +01:00
Konstantin Haase
24cedb57b1 Ruby 2.1.6 is no longer supported on Heroku 2015-12-16 15:10:03 +01:00
Konstantin Haase
bddd9952a7 add ip whitelisting 2015-12-16 15:06:15 +01:00
Konstantin Haase
6ddb826f1d make sure params is always a hash, fixes exceptions 2015-12-16 14:31:04 +01:00
carlad
759fdf203b change rakefile and db congig 2015-12-11 12:35:37 +01:00
Piotr Sarnacki
dff78176cc Bump travis-core 2015-12-09 09:50:21 +01:00
carlad
785ec6c784 Merge pull request #221 from travis-ci/cd-first-log-in
Add check for first log in - send data to customer.io
2015-12-07 09:27:31 +01:00
Josh Kalderimis
bbba45990d a little method splitting action good times
and high 5 @carlad
2015-12-04 17:31:06 +01:00
carlad
82f280f5d3 convert timesptamps to i for better integration w customerio 2015-12-04 17:11:18 +01:00
Josh Kalderimis
8132258b2c tiny updates to how we update the customer io info
- alway fetch the primary email and don't save it to the user model as this may not match what is on github
- move some bits into their own methods
- high 5 @carlad for her awesome work
2015-12-04 17:06:22 +01:00
carlad
ff68df9fb5 fix syntax error 2015-12-04 16:13:52 +01:00
carlad
8fc9ade6de bump travis-core 2015-12-04 16:11:45 +01:00
carlad
553700d402 add email to user 2015-12-04 16:10:44 +01:00
carlad
94c2edfbe1 remove debug messages and add rescues 2015-12-04 15:23:55 +01:00
carlad
e9533fb056 bump travis-core 2015-12-04 14:55:20 +01:00
carlad
13e6959b21 convert ahsh to string 2015-12-04 14:52:53 +01:00
carlad
d42e337996 convert timestamp to s 2015-12-04 13:14:14 +01:00
carlad
a638aee0ff bump core, add log output 2015-12-04 13:08:14 +01:00
carlad
a7fa8f6a6f update first_log_in 2015-12-04 12:53:51 +01:00
carlad
98080beeaf revert to json true 2015-12-03 16:47:26 +01:00
carlad
16817ff98e trying json false 2015-12-03 16:35:53 +01:00
carlad
28fde8333a remove json 2015-12-03 16:30:04 +01:00
carlad
a3e83659f7 tidy up customerio code 2015-12-03 15:57:14 +01:00
carlad
cc14ebac48 fix syntax error 2015-12-03 15:26:58 +01:00
carlad
d587b766f3 create payload hash 2015-12-03 15:25:21 +01:00
carlad
dcc92491f7 remove global variable syntax error 2015-12-03 15:18:14 +01:00
carlad
b5c061b239 Merge branch 'cd-first-log-in' of github.com:travis-ci/travis-api into cd-first-log-in 2015-12-03 15:14:05 +01:00
carlad
e1aee4a3b0 add require for customerio 2015-12-03 15:13:26 +01:00
carlad
7be5bf6fec Auto-merged master into cd-first-log-in on deployment. 2015-12-03 15:05:22 +01:00
carlad
0ecbd8b237 add customerio gem and event 2015-12-03 15:04:50 +01:00
carlad
a4bce14a73 move method to handshake 2015-12-03 13:02:52 +01:00
carlad
83b6bed184 fix variable name 2015-12-03 12:59:12 +01:00
carlad
f602ce0989 initial work: add check for frist log in 2015-12-03 12:52:34 +01:00
carlad
6acf267a04 try to add a check for first_log_in
but according to rkh it's possibly in the wrong place. What if there's no user??
2015-12-02 17:38:28 +01:00
carlad
7304606687 bump travis-core 2015-12-02 15:16:41 +01:00
Hiro Asari
619ff93057 Update travis-core
In particular, to have https://github.com/travis-ci/travis-core/pull/499
2015-12-02 08:53:53 -05:00
carlad
f7cd49f194 Merge pull request #220 from travis-ci/cd-v3
v3: adds star, unstar endpoints, adds starred filter, adds specs
2015-12-01 17:30:26 +01:00
Konstantin Haase
dece76ce5b v3: avoid handing repository back to the query 2015-12-01 17:25:09 +01:00
carlad
b6186890c4 v3: remove webmock gem 2015-12-01 16:53:42 +01:00
carlad
06b5e0af15 v3: fix specs 2015-12-01 16:51:04 +01:00
carlad
c0d562cb7d Merge branch 'master' into cd-v3-parity 2015-12-01 15:10:35 +01:00
carlad
50e198beee v3: tidy specs for star, unstar, enable, disable 2015-12-01 15:02:10 +01:00
carlad
54ffac9916 v3: complete enable and disable repo specs 2015-12-01 14:56:33 +01:00
carlad
221b309653 v3: add webmock for disable repo spec 2015-12-01 12:36:43 +01:00
carlad
620e38a2a0 v3: add spec for disable repo (unfinished) 2015-11-30 19:37:50 +01:00
carlad
dfdfe651af v3: complete specs for star and unstar 2015-11-30 19:36:49 +01:00
carlad
5d6b25a2b4 v3: add specs for disable repo 2015-11-30 17:51:50 +01:00
carlad
01591cefa5 v3: fix specs for services/repositories 2015-11-26 18:30:14 +01:00
Konstantin Haase
afb6fe286b v3: SQL "NOT IN ()" never matches 2015-11-26 18:17:19 +01:00
carlad
24d5efda95 v3 update spec for services/repositories 2015-11-26 17:39:03 +01:00
carlad
2b8d7e420b Update README.md 2015-11-26 16:48:10 +01:00
carlad
8d3acfe9bb v3 fix existing specs for un/star endpoints and starred filter 2015-11-26 14:00:42 +01:00
carlad
086932df11 v3 merge with master to fix default_branch spec error, fix services/repository spec 2015-11-25 19:17:33 +01:00
carlad
2974dccd3b Merge branch 'master' into cd-v3-parity 2015-11-25 18:18:56 +01:00
Piotr Sarnacki
cf5915a06b Bump travis-core 2015-11-25 18:11:43 +01:00
carlad
c2168d62f1 v3 update specs to accomodate starred, unstar and star 2015-11-25 18:08:53 +01:00
carlad
937cc0267a v3 fix filtering by unstarred and n+1 query 2015-11-25 16:30:42 +01:00
carlad
baa1881bf7 v3 change name of starred_repository to star 2015-11-24 18:59:16 +01:00
carlad
d3b13e8d7c v3 fix relation of starred_repository to repostiory model 2015-11-24 18:15:17 +01:00
carlad
af3087446c v3 adjust repo model, query and service for filtering by starred - not working 2015-11-24 18:03:15 +01:00
Piotr Sarnacki
7eb2617e48 Add branch_is_default info to commits 2015-11-24 16:07:23 +01:00
Piotr Sarnacki
dbea2f3760 Revert "v3: in access control object, avoid firing multiple permissions queries (even though they are cache hits)"
This reverts commit 4a3357a488.
2015-11-24 15:09:58 +01:00
Piotr Sarnacki
81e11da856 Fix error when default branch tries to be autosaved
For some reason when branch from V2 models is being saved, it tries to
also update relationships for V3 models, at least in tests. This fails,
because default_branch association on the V3 Repository model has a
primary key set to [:id, :default_branch]. In theory we use composite
keys plugin, but it seems that it doesn't cover that case and because of
that AR fails with an error "[:id, :default_branch] is not a Symbol"
when it tries to call Model#send with primary_key as an argument.

This commit fixes the issue by overriding the send method on the
Repository model to not fail when AR does
repository.send([:id, :default_branch_name]), when it needs to fetch
a primary key.

This is hacky, but I haven't found a nicer way to get around it.
2015-11-24 15:09:58 +01:00
carlad
02f5035100 comment out 2015-11-24 12:31:50 +01:00
carlad
4095090992 Merge branch 'master' into cd-v3-parity 2015-11-24 11:54:49 +01:00
Piotr Sarnacki
a31a6cb92b Bump travis-core 2015-11-23 15:52:18 +01:00
carlad
9793010e28 v3 add filter for d=starred repos - not working yet 2015-11-20 19:02:39 +01:00
carlad
77aabcb78f Merge branch 'master' into cd-v3-parity 2015-11-20 17:24:34 +01:00
carlad
fb483689e9 V3 start implementing filter for starred repos 2015-11-20 17:23:59 +01:00
Konstantin Haase
4a3357a488 v3: in access control object, avoid firing multiple permissions queries (even though they are cache hits) 2015-11-20 16:24:26 +01:00
Konstantin Haase
8f0b35a0f1 User-Agent-Tracker: check if comment is there 2015-11-20 14:20:02 +01:00
Konstantin Haase
efb91d0a38 move user-agent filter for /auth/github to redis 2015-11-20 13:53:35 +01:00
carlad
02d3fad23f v3 refator un/star endpoints 2015-11-20 13:20:03 +01:00
Konstantin Haase
b138fbcdeb check user agent 2015-11-19 19:59:22 +01:00
Konstantin Haase
8f5a34c7b6 disable /auth/github 2015-11-19 19:37:51 +01:00
Konstantin Haase
4f9cb29775 also add a throttle 2015-11-19 19:29:07 +01:00
Konstantin Haase
28ff2f6848 aggressive blocking on /auth/github 2015-11-19 19:24:18 +01:00
carlad
95ad9a6b56 v3 add starred to standard representation for repo 2015-11-19 19:17:46 +01:00
carlad
c20f99d210 add check_access to repo for un/star services 2015-11-19 19:07:24 +01:00
carlad
0f4a29c31c refactor un/star querys from service to query 2015-11-19 19:02:12 +01:00
carlad
2420784a87 fix syntax of db queries, add output 2015-11-19 17:26:30 +01:00
Steffen
18ea7853bf Merge branch 'master' into addCron 2015-11-19 13:39:50 +01:00
Steffen Kötte
f356beaccf add time and disable_by_push options for cron 2015-11-19 13:39:13 +01:00
carlad
16687f16d7 refining work on star/unstar endpoints 2015-11-18 18:47:59 +01:00
carlad
714e40beca more initial work on star/unstar endpoints 2015-11-18 17:43:35 +01:00
carlad
c96e8e2ff1 initial work on star and unstar endpoints 2015-11-16 18:14:31 +01:00
Steffen Kötte
75449baacd fix and add tests for crons 2015-11-16 15:52:05 +01:00
Steffen Kötte
aca632ed15 use branch for storing cron 2015-11-16 14:24:11 +01:00
Konstantin Haase
480aac2171 Merge pull request #209 from travis-ci/cd-v3-parity
v3 Add user/:id/sync endpoint
2015-11-10 12:30:27 +01:00
Steffen Kötte
0a91a69d0d remove debug code 2015-11-09 16:59:10 +01:00
Lennard Wolf
e8ab7c0be6 add test for /repo/{repo.id}/crons/create endpoint 2015-11-09 16:55:53 +01:00
Lennard Wolf
b1408583dd fix test for /repo/{repo.id}/crons endpoint 2015-11-09 16:25:03 +01:00
Lennard Wolf
0e1b266e9b add test for /repo/{repo.id}/crons endpoint 2015-11-09 16:23:01 +01:00
Lennard Wolf
b3eb2f3398 add test for /cron/{cron.id}/delete endpoint 2015-11-09 16:04:41 +01:00
Lennard Wolf
f5f4b3b0b1 add test for /cron/{cron.id} endpoint 2015-11-09 14:50:44 +01:00
Lennard Wolf
a2a4737099 Fixed tests broken by cron 2015-11-09 14:03:30 +01:00
Steffen Kötte
c6556977fa Change create and delete to POST 2015-11-09 13:42:01 +01:00
Steffen Kötte
d1dd965b32 fix permissions 2015-11-09 12:51:07 +01:00
Lennard Wolf
c08f8243fb fix .../crons/create endpoint 2015-11-05 16:08:08 +01:00
Lennard Wolf
208dfb9a93 add /repo/repository.id/crons/create endpoint, all working with our access_control 2015-11-05 16:04:08 +01:00
Lennard Wolf
ec37deb17c add /repo/repo.id/crons GET endpoint 2015-11-05 15:22:10 +01:00
Lennard Wolf
5295d0c3ee add nonworking implementation of /cron/cron.id/delete 2015-11-05 15:11:31 +01:00
Lennard Wolf
772e797aae add /cron/cron.id/ GET endpoint 2015-11-05 13:31:36 +01:00
Lennard Wolf
046a63b60a add find for cron 2015-11-05 11:43:58 +01:00
carlad
a6327ec4d2 v3 update spec for user sync 2015-10-30 16:36:38 +01:00
Konstantin Haase
9c9aa3334c allow setting sidekiq worker class 2015-10-30 16:29:09 +01:00
Konstantin Haase
4035b22bf6 allow specifying the sidekiq queue 2015-10-30 15:48:07 +01:00
carlad
426a68f567 v3 add spec for user sync 2015-10-30 12:58:24 +01:00
carlad
26b1d85d43 V3 add user/:id/sync endpoint 2015-10-29 17:57:30 +01:00
Konstantin Haase
b923b21252 v3: expose default sorting mode in service index 2015-10-28 16:13:34 +01:00
Konstantin Haase
b4fa2220a7 Merge pull request #208 from travis-ci/cd-v3-parity
Add owner/github_id/:github_id endpoint
2015-10-28 15:54:38 +01:00
carlad
59d3090da6 Auto-merged master into cd-v3-parity on deployment. 2015-10-28 15:40:26 +01:00
carlad
0339a4f3e6 update owner/find_spec to include owner by github_id 2015-10-28 13:31:35 +01:00
Konstantin Haase
57f31c6573 Merge pull request #207 from travis-ci/rkh-v3-owner-repos-under-repos
API v3: owner/repos => repos/for_owner
2015-10-28 13:25:12 +01:00
Konstantin Haase
df3ec4084a API v3: owner/repos => repos/for_owner 2015-10-28 13:22:04 +01:00
carlad
2e590585fe ;;Merge branch 'cd-v3-parity' of github.com:travis-ci/travis-api into cd-v3-parity 2015-10-28 13:20:56 +01:00
carlad
2c8db7aa61 remove debug output 2015-10-28 13:20:18 +01:00
carlad
f02c9e0a02 Auto-merged master into cd-v3-parity on deployment. 2015-10-28 13:15:57 +01:00
carlad
96f3e554ee Merge branch 'cd-v3-parity' of github.com:travis-ci/travis-api into cd-v3-parity 2015-10-28 13:14:16 +01:00
carlad
245edc5f55 add owner/github_id/:id endpoint 2015-10-28 13:13:02 +01:00
Konstantin Haase
e45d6c9dfe Merge pull request #206 from travis-ci/cd-v3-parity
add jobs endpoint
2015-10-27 12:57:42 +01:00
Konstantin Haase
64dadb7549 v3: jobs query - comment out unused lines for now 2015-10-27 12:50:55 +01:00
carlad
bce9ea5b46 update jobs service, add jobs spec 2015-10-26 19:37:32 +01:00
carlad
dc248302ab add jobs endpoint 2015-10-26 15:57:34 +01:00
Konstantin Haase
588465766f legacy: avoid off by one error in spec that suddenly surfaced 2015-10-22 09:25:53 +02:00
Konstantin Haase
3d171394a6 v3: list more resources in the service index 2015-10-22 09:13:55 +02:00
Konstantin Haase
083355227f v3: add developer program feature flag 2015-10-21 16:57:21 +02:00
carlad
4a23a1e0c5 Update README.md 2015-10-20 14:28:27 +02:00
carlad
7237ad766e Update README.md 2015-10-20 14:27:19 +02:00
carlad
a51ee4cb99 Update README.md 2015-10-20 14:26:14 +02:00
carlad
9bcf83bc09 Update README.md 2015-10-20 14:17:44 +02:00
carlad
10c05434e8 Add to nginx info 2015-10-20 14:17:31 +02:00
carlad
615499489a Update README.md 2015-10-20 14:17:03 +02:00
carlad
58b388db69 Add Nginx as a dependency 2015-10-20 14:15:47 +02:00
carlad
c37e01c911 Update README.md 2015-10-19 16:52:40 +02:00
Konstantin Haase
4a11c22a74 add another avatar spec 2015-10-15 10:40:30 +02:00
Konstantin Haase
099d10f466 Merge pull request #204 from travis-ci/rkh-more-pagination
v3: More pagination and sorting
2015-10-14 14:41:49 +02:00
Konstantin Haase
0fc7c35e0c Auto-merged master into rkh-more-pagination on deployment. 2015-10-14 14:26:42 +02:00
Konstantin Haase
03c982a45a Merge pull request #202 from travis-ci/rkh-active-broadcasts
better broadcasts, cleaner payloads
2015-10-14 14:13:13 +02:00
Konstantin Haase
df8f2537cc v3: list sortable fields in service index 2015-10-13 17:40:58 +02:00
Konstantin Haase
571af14067 v3: add pagination and sortability to repo endpoints 2015-10-13 17:34:31 +02:00
Konstantin Haase
2ebfa1d85b v3: add pagination and sorting to orgs endpoint 2015-10-13 17:09:18 +02:00
Konstantin Haase
8a7ff5c6b8 v3: add sorting to builds 2015-10-13 16:52:15 +02:00
Konstantin Haase
3904d9e362 Auto-merged master into rkh-active-broadcasts on deployment. 2015-10-13 13:42:48 +02:00
Konstantin Haase
aa222ad6b2 Merge pull request #203 from travis-ci/rkh-branches-filtering-and-sorting
better branches filtering and sorting
2015-10-13 13:18:12 +02:00
Konstantin Haase
9edb598884 v3: change branches default sort mode 2015-10-13 13:09:50 +02:00
Konstantin Haase
949a876550 v3: allow sorting branches by them being default branch or not 2015-10-13 13:08:27 +02:00
Konstantin Haase
1d783129ce v3: allow filtering branches by exists_on_github 2015-10-13 12:42:03 +02:00
Konstantin Haase
1a5788e2a1 v3: allow sorting branches by exists_on_github 2015-10-13 12:33:26 +02:00
Konstantin Haase
9461807834 50 unicorn workers on heroku is ideal, as heroku hands 50 requests to the dyno 2015-10-13 12:22:07 +02:00
Konstantin Haase
cf416e6001 relax GET request throttling 2015-10-13 12:21:08 +02:00
Konstantin Haase
202377181e add concurrency settings for Performance M dynos 2015-10-12 20:56:07 +02:00
Konstantin Haase
783e9af5b9 more unicorn workers on performance dynos 2015-10-12 18:29:30 +02:00
Konstantin Haase
ac94487d7c lol heroku (ulimit is not an executable on heroku) 2015-10-12 18:08:24 +02:00
Konstantin Haase
5dc0e62bf6 add /sysinfo endpoint 2015-10-12 17:54:00 +02:00
Konstantin Haase
4697deae26 empty commit for heroku 2015-10-09 09:37:53 +02:00
Konstantin Haase
4b76e8f658 Merge pull request #201 from travis-ci/rkh-ddos
reinstate nginx
2015-10-09 09:23:33 +02:00
Konstantin Haase
6f0a42abee set tmp_dir in script/server 2015-10-09 09:19:07 +02:00
Konstantin Haase
16c871d740 $tmp_dir is not set on heroku 2015-10-09 09:17:21 +02:00
Konstantin Haase
815d9e6e9b turn script/web_concurrency into a bash script, heroku did not like the ruby script 2015-10-09 09:13:46 +02:00
Konstantin Haase
0890d0b76a fix heroku dyno detection 2015-10-09 09:06:42 +02:00
Konstantin Haase
3e112294cb no double je 2015-10-09 09:02:10 +02:00
Konstantin Haase
aadd29574c script/server: output to $stderr, maybe that way it will show up in heroku logs 2015-10-09 09:01:55 +02:00
Konstantin Haase
4ed55a804e add nginx buildpack 2015-10-09 08:47:55 +02:00
Konstantin Haase
4cc50009aa v3: remove repository.last_build 2015-10-08 19:01:03 +02:00
Konstantin Haase
9bdc7b496e v3: repository - allow rendering minimal default branch without having to fetch the branch from the branches table 2015-10-08 18:53:26 +02:00
Konstantin Haase
860edf37bf v3: fix specs 2015-10-08 18:45:26 +02:00
Konstantin Haase
2d0bb58e35 v3: minimal represenations should not use data from other tables 2015-10-08 18:45:18 +02:00
Konstantin Haase
d7c9a367e9 v3: branches - add default_branch (boolean) property 2015-10-08 18:44:40 +02:00
Konstantin Haase
06486c57a5 v3: broadcasts - better renderer 2015-10-08 18:43:57 +02:00
Konstantin Haase
0eb564388c v3: broadcasts - filter inactive broadcasts 2015-10-08 18:43:22 +02:00
Konstantin Haase
1c4579008b v3: broadcasts - make sure expired is a boolean 2015-10-08 16:32:18 +02:00
Konstantin Haase
e03f79513a reinstate nginx, use it in development, add smare concurrency settings 2015-10-08 13:57:49 +02:00
Konstantin Haase
6cc0e6139f update travis-support 2015-10-08 11:40:43 +02:00
Konstantin Haase
509c29b33e Merge pull request #200 from travis-ci/rkh-v3-sorting
API v3: add ability to sort branches
2015-10-06 18:33:58 +02:00
Konstantin Haase
33d31131c1 v3: add ability to sort branches 2015-10-06 17:35:56 +02:00
Konstantin Haase
0249140dc8 auto banning: whitelist POST requests for in-browser handshake, on staging only ban for 10 seconds 2015-10-06 11:00:35 +02:00
Konstantin Haase
1bec0c1332 block clients sending many POST requests 2015-10-05 18:19:15 +02:00
Konstantin Haase
e218b13073 be less forgiving with /auth/github requests 2015-10-05 18:16:29 +02:00
Konstantin Haase
148e2acefe Merge branch 'rkh-v3-no-list-nesting' 2015-10-05 18:12:45 +02:00
Konstantin Haase
716bd1f8e6 v3: don't have recursive recursiveness trigger endless db queries, fixes travis-pro/team-teal#497 2015-10-05 17:49:10 +02:00
Konstantin Haase
3dc1c5b486 update travis-core 2015-10-05 17:42:35 +02:00
Konstantin Haase
154be5c38d Merge pull request #198 from travis-ci/cd-v3-parity
v3 Add Build and Job Restart and Cancellation
2015-10-05 14:36:58 +02:00
carlad
36d361b7af remove empty line 2015-09-30 17:19:08 +02:00
carlad
fd03316de7 v3 add spec for job restart 2015-09-30 17:07:59 +02:00
carlad
b6ffb8bdf8 v3 add job cancellation endpoint ans spec 2015-09-30 17:03:00 +02:00
carlad
d8e24bf52f v3 fix specs for build canceland restart 2015-09-30 16:37:34 +02:00
carlad
e3de9a4f07 v3 update payload again 2015-09-30 16:19:07 +02:00
carlad
a2deeb1d96 v3 update payload 2015-09-30 15:49:48 +02:00
carlad
38b73f53cb v3 more trying to get the payload right 2015-09-30 15:35:19 +02:00
carlad
f3b8258b53 v3 update payload for build restart 2015-09-30 15:29:12 +02:00
carlad
5c6e705012 v3 update sidekiq payload for build restart and cancel 2015-09-30 15:21:59 +02:00
carlad
b73a5604d0 v3 add build/id/cancel endpoint and tests 2015-09-29 16:28:42 +02:00
carlad
2bc72d8b9b v3 update buiild/cancel_spec 2015-09-29 13:43:22 +02:00
carlad
d99c3c8c54 v3 update build cancel, access control, specs for build cancel 2015-09-28 18:45:52 +02:00
carlad
c6cc6d1b96 update build cancel spec 2015-09-25 16:59:26 +02:00
carlad
2e110bc455 v3 add spec for build cancel - not yet passing 2015-09-25 16:34:37 +02:00
carlad
faf60a5f7f initial work to add build and job cancellation incl updating existing specs 2015-09-25 16:04:47 +02:00
carlad
faabb0f727 Merge pull request #193 from travis-ci/cd-v3-parity
v3 Add :category to broadcast renderer, update spec
2015-09-23 16:46:29 +02:00
carlad
6187c2a9c1 bump travis-core 2015-09-23 15:51:26 +02:00
carlad
4e2d33995a update broadcasts spec 2015-09-23 15:44:37 +02:00
carlad
ab979e2356 add category to broadcasts renderer 2015-09-23 15:32:15 +02:00
carlad
866ed28641 v3 revert removal of :last_build from repo renderer 2015-09-22 16:23:26 +02:00
carlad
af7fdec340 v3 remove :last_build attrubite from repository renderer 2015-09-22 16:16:01 +02:00
carlad
6821cec524 revert change to build renderer 2015-09-21 17:02:38 +02:00
carlad
986ae0ef97 add branch to build minimal rep 2015-09-21 16:26:01 +02:00
María de Antón
aef8672cba Merge pull request #191 from travis-ci/cd-throttle-limit
increase throttle limit for authenticated requests
2015-09-18 10:19:07 +02:00
carlad
9f2b880f83 increase throttle limit for authenticated requests 2015-09-18 09:58:34 +02:00
Konstantin Haase
e40e6d3fe9 Merge pull request #190 from travis-ci/rkh-better-throttling
better request throttling and auto-banning
2015-09-17 15:32:19 +02:00
Konstantin Haase
c372b07344 only enable request throttling in production 2015-09-17 15:26:30 +02:00
Konstantin Haase
e8769dddc5 add missing constant 2015-09-17 15:21:16 +02:00
Konstantin Haase
5e40f33fc1 remove left-overs from inheriting from Rack::Attack 2015-09-17 15:18:48 +02:00
Konstantin Haase
e478c621f2 no more inheritance 2015-09-17 15:13:33 +02:00
Konstantin Haase
dc0da3645a work around strange constant lookup 2015-09-17 15:10:27 +02:00
Konstantin Haase
9303a24595 base throttling on access token if the call is authenticated, rather than on IP address, improve throttling rules 2015-09-17 14:57:50 +02:00
Konstantin Haase
b59fa6cd94 add general throttling 2015-09-15 19:30:13 +02:00
Konstantin Haase
af977ca677 use in-memory store for local development 2015-09-15 19:22:04 +02:00
Konstantin Haase
3e0423aae3 add auto-throtteling to /auth/github 2015-09-15 19:17:01 +02:00
Konstantin Haase
fb4bedbb6b move ip blacklist to redis 2015-09-15 18:29:54 +02:00
Konstantin Haase
950b922e63 Merge pull request #188 from travis-ci/cd-v3-parity
v3 prefix ids with correct tables when ordering
2015-09-15 12:10:40 +02:00
carlad
4a0932df1e prefix ids with correct tables when ordering 2015-09-15 11:45:16 +02:00
Konstantin Haase
1e6d4738e3 Merge pull request #187 from travis-ci/cd-v3-parity
v3 Add /branches, /broadcasts endpoints, :exists_on_github build attribute and :default_branch to minimal repo representation
2015-09-15 10:34:48 +02:00
carlad
dc7ced1c7f v3 add :default_branch to minimal representation for repository, update specs 2015-09-14 18:43:26 +02:00
carlad
907591e001 add spec for broadcasts 2015-09-11 16:49:53 +02:00
carlad
28c6e04eb8 put jobs service back in 2015-09-11 11:10:36 +02:00
carlad
1640c33517 fix incorrect broadcast endpoints - add correct broadcasts endpoint 2015-09-10 17:36:13 +02:00
carlad
bd61d1e58e add broadcasts - initial work 2015-09-10 15:08:41 +02:00
carlad
fba1d65e76 v3 add branches/find spec, update builds spec to use v3 models 2015-09-08 17:57:43 +02:00
carlad
0705a61808 v3 update service_index_spec for requests pagination 2015-09-08 17:08:08 +02:00
carlad
8645338306 update build/find_spec to include :exists_on_github 2015-09-08 16:36:40 +02:00
carlad
2c5ad649f5 v3 add :exists_on_github to standard branch representation 2015-09-08 16:26:43 +02:00
carlad
9d7a01e60c Merge branch 'master' into cd-v3-parity
Keeping my branch up to date with the master
2015-09-08 12:21:49 +02:00
carlad
2e72233213 v3 fix services 2015-09-07 17:10:03 +02:00
carlad
f44b374d79 v3 add branches endpoint 2015-09-07 17:09:05 +02:00
carlad
beaa4b7e17 add branches endpoint 2015-09-07 17:07:09 +02:00
Konstantin Haase
3242189259 v3: eager load jobs for build history if asked for 2015-09-03 15:30:18 +02:00
Konstantin Haase
2891dd640a v3: use cached_matrix_ids for build.jobs if only job ids are being loaded 2015-09-03 15:03:12 +02:00
carlad
702b539ddf v3 put endpoints in routes.rb into alphabetical order 2015-09-02 18:22:10 +02:00
carlad
f57f62ba75 Merge pull request #186 from travis-ci/cd-v3-parity
v3 improvements incl. :job attribute on build payload and /job/:id endpoint and specs using v3 models
2015-09-02 16:50:44 +02:00
carlad
070be827df revert extensions spec expectation 2015-09-02 16:29:40 +02:00
carlad
211637e247 v3 make specs use v3 models, update representations of build and job, make some indentation pretty 2015-09-02 16:21:41 +02:00
carlad
210f368de4 v3 update all relevant specs with job_ids payload 2015-08-27 14:36:11 +02:00
carlad
288d614977 v3 update branch/find_spec to include job_ids 2015-08-27 14:22:38 +02:00
carlad
18e5c22fd7 v3 add spec for /build/:id endpoint 2015-08-27 13:42:52 +02:00
carlad
d99d80ac98 v3 add :job_ids to build payload, update builds/find_spec 2015-08-27 13:33:46 +02:00
carlad
8e8e139391 v3 fix syntax of permission in spec for /job/:id 2015-08-27 12:50:56 +02:00
carlad
e80dfadf5c add spec for /job/:id endpoint 2015-08-27 12:37:59 +02:00
carlad
8e6dbf9319 v3 add /job/:id endpoint 2015-08-27 11:00:09 +02:00
carlad
5893241ca5 v3 fix spacing on spec payloads 2015-08-26 20:39:38 +02:00
carlad
64673eb971 v3 update payloads for builds/find_spec.rb to include jobs 2015-08-26 17:41:25 +02:00
carlad
1a3d42da21 v3 add _type_disabled to ovveride activerecord setting wrong class on job 2015-08-26 16:33:16 +02:00
carlad
98bcc9e530 add :jobs to build payload 2015-08-26 12:44:15 +02:00
Konstantin Haase
6b0850813c Merge branch 'cd-v3-parity' 2015-08-25 19:42:00 +02:00
Konstantin Haase
e3d56ecadb v3: more info in the service index 2015-08-25 19:41:04 +02:00
Konstantin Haase
2610c03801 v3: in service index, sort resources alphabetically 2015-08-25 18:07:21 +02:00
Konstantin Haase
ee03ebfbe5 v3: have attributes in service index list representations 2015-08-25 17:53:08 +02:00
carlad
51bcdec77a add @representation attribute to collections and update specs 2015-08-25 17:50:45 +02:00
Konstantin Haase
d207f1c31c Merge branch 'cd-v3-parity' 2015-08-25 17:34:53 +02:00
carlad
720d8aa284 add @representation attribute to payload and update specs 2015-08-25 17:21:02 +02:00
Konstantin Haase
90812293fe add tmp back to .gitignore 2015-08-24 18:04:27 +02:00
Konstantin Haase
995ee333a8 Merge branch 'cd-v3-parity' 2015-08-24 18:04:06 +02:00
carlad
d8ad047dc8 v3 add test for branch.name 2015-08-24 17:09:40 +02:00
carlad
11f5f2cb66 v3 finish builds/find_spec tests 2015-08-24 13:27:27 +02:00
carlad
517b3b60ef Merge branch 'master' into cd-v3-parity 2015-08-24 10:01:59 +02:00
carlad
96a79be68c v3 remove blank spaces 2015-08-24 10:01:34 +02:00
carlad
a7111ba949 add database.yml to .gitignore 2015-08-24 09:48:29 +02:00
Konstantin Haase
09df061268 v3: add @warnings 2015-08-21 19:50:37 +02:00
Konstantin Haase
b4a3bdeb0e allow skipping simplecov 2015-08-21 19:22:59 +02:00
Konstantin Haase
462b2aed0d v3: allow filtering builds by branch 2015-08-21 19:11:27 +02:00
Konstantin Haase
4eb89ab141 v3: allow filtering by /repo/…/builds?state=… as a shorthand for /repo/…/builds?build.state=… 2015-08-21 18:56:51 +02:00
Konstantin Haase
73ec1d496e v3: allow filtering builds by event_type, state and previous_state 2015-08-21 18:46:42 +02:00
Konstantin Haase
cc346ce165 v3: more eager-loading 2015-08-21 18:33:27 +02:00
Konstantin Haase
cbc5329b3d v3: avoid N+1 query in builds endpoint 2015-08-21 18:26:21 +02:00
Konstantin Haase
34bff32c3d v3: pagination => @pagination 2015-08-21 17:27:42 +02:00
carlad
8057dc7ab9 Merge branch 'master' into cd-v3-parity 2015-08-21 17:07:25 +02:00
carlad
456f52405e add builds spec 2015-08-21 17:07:06 +02:00
Konstantin Haase
b3f47d3856 v3: add pagination 2015-08-21 17:04:12 +02:00
Konstantin Haase
ac522d6fdd Merge commit 'e9d1105' 2015-08-21 14:43:49 +02:00
carlad
8ef0a2d8e5 implement requests 2015-08-21 14:39:28 +02:00
Konstantin Haase
28e3e52b3e fix alignment 2015-08-21 14:39:19 +02:00
Konstantin Haase
5ef17e7da0 Merge branch 'cd-v3-parity' 2015-08-21 14:38:38 +02:00
carlad
e9d11056c0 update find for access control 2015-08-21 14:05:36 +02:00
carlad
f7634f0f39 update routes for builds 2015-08-21 13:48:47 +02:00
carlad
fe9a6536d7 add builds 2015-08-21 13:38:07 +02:00
Konstantin Haase
18a90c2561 v3: if the API is not marked as public (travis-ci.com), then do not allow read access to organizations the user is not a member of (note: private repos were never included) 2015-08-19 13:04:54 +02:00
Konstantin Haase
69a4a0a735 in console, only use pry in interactive mode 2015-07-17 14:24:28 +02:00
Konstantin Haase
120cbadf85 Merge pull request #182 from travis-ci/rkh-v2-repo-active
expose active flag in repo payload in v2
2015-07-17 11:44:53 +02:00
Konstantin Haase
d460d48684 adjust test for new payload 2015-07-17 11:30:37 +02:00
Konstantin Haase
a6c6b3c0bd add repository.active to v2 2015-07-17 11:26:00 +02:00
Josh Kalderimis
48c92659fd seems we don't have a license 2015-07-15 20:51:57 +02:00
Konstantin Haase
43219fe49e Merge pull request #181 from travis-ci/rkh-more-pusher-info
add secure and private flag to pusher config payload
2015-07-14 17:46:30 +02:00
Konstantin Haase
edac220a42 add secure and private flag to config payload 2015-07-14 17:30:50 +02:00
Sven Fuchs
bdd479298b Merge pull request #180 from travis-ci/sf-invalidated_repos
Ignore invalidated repos
2015-07-14 14:48:38 +02:00
Sven Fuchs
9ed6cb636d bump travis-core 2015-07-14 14:36:35 +02:00
Sven Fuchs
426a4f3a69 ignore invalidated repos on the Repositories query 2015-07-14 14:35:56 +02:00
Sven Fuchs
ba61986e1d use travis-core/master 2015-07-14 14:35:55 +02:00
Sven Fuchs
162a40ca80 use core/sf-repos_invalidated_at 2015-07-14 14:35:41 +02:00
Sven Fuchs
d831597cc2 ignore invalidated repos 2015-07-14 14:35:20 +02:00
Piotr Sarnacki
4c90d7c12c Bump travis-core 2015-07-14 13:59:51 +02:00
Piotr Sarnacki
2ce1220ef5 Merge pull request #179 from travis-ci/pass-token-to-request-create
Include token in requests/create payload
2015-07-08 14:30:18 +02:00
Piotr Sarnacki
a35d78afd8 Allow to configure limit for requests creation 2015-07-08 13:55:40 +02:00
Piotr Sarnacki
b898d863c0 Increase requests creation limit to 50 2015-07-08 13:40:43 +02:00
Piotr Sarnacki
3fa44b2e3f Include token in requests/create payload 2015-07-08 13:38:55 +02:00
Piotr Sarnacki
857af4fde0 Use Accept entries for getting API version 2015-07-07 12:45:30 +02:00
Piotr Sarnacki
a1b421a7fa Merge pull request #175 from travis-ci/remove-triggering-builds-in-v2
Remove triggering builds in V2
2015-06-29 14:58:15 +02:00
Josh Kalderimis
02fce160a9 try out jemalloc 2015-06-28 01:23:01 -05:00
Piotr Sarnacki
a4c228277b Fix specs 2015-06-18 15:35:22 +02:00
Piotr Sarnacki
43263b5eee Fix specs 2015-06-18 15:34:20 +02:00
Piotr Sarnacki
c001a4d830 Return channels for a user record 2015-06-18 15:28:02 +02:00
Piotr Sarnacki
f8a3c4aa19 Bump travis-core 2015-06-18 14:17:57 +02:00
Piotr Sarnacki
1a681dcc1a bump travis-core 2015-06-18 13:56:20 +02:00
Piotr Sarnacki
51b0fb0740 Bump travis-core 2015-06-18 13:25:45 +02:00
Piotr Sarnacki
66f5d71d1a Remove triggering builds in V2 2015-06-15 12:22:42 +02:00
Piotr Sarnacki
05163a558c Bump travis-core 2015-06-10 10:36:14 +02:00
Piotr Sarnacki
2fa6439af4 Bump travis-core 2015-06-03 15:31:49 +02:00
Piotr Sarnacki
e57f253632 Bump travis-core 2015-06-03 13:38:10 +02:00
Sven Fuchs
e3f23491c4 bump travis-core 2015-05-29 14:42:45 +02:00
Konstantin Haase
b65a47429f Merge pull request #174 from travis-ci/sf-bump-pg
Relax dependency for pg, remove thin
2015-05-21 18:47:22 +02:00
Sven Fuchs
10cd2d092d relax dependency for pg, remove thin 2015-05-21 18:23:33 +02:00
Konstantin Haase
0cdecaade3 API v3: add captures route dsl method 2015-05-21 14:57:16 +02:00
Konstantin Haase
0219308a08 Merge pull request #173 from travis-ci/fetch-by-slug
Allow to fetch repository by slug
2015-05-21 14:08:48 +02:00
Piotr Sarnacki
bff7f76c33 v3: Implement fetching repository by slug 2015-05-21 12:29:04 +02:00
Konstantin Haase
a8485838e3 update travis-yaml 2015-05-13 14:34:52 +02:00
Konstantin Haase
b9adb793cd Travis.config.env => Travis.env 2015-05-12 12:26:29 +02:00
Konstantin Haase
3ade697ed3 set application_name on database connection 2015-05-12 12:18:49 +02:00
Konstantin Haase
887a797ae6 add support for setting session variables for postgres connections (as you can in ActiveRecord 4.x) 2015-05-12 11:55:46 +02:00
Konstantin Haase
9ec2ef7f56 allow switching profiler mode 2015-05-11 17:51:43 +02:00
Konstantin Haase
b0f142a94b v3: drastically reduce objects allocated by access control 2015-05-11 17:38:40 +02:00
Konstantin Haase
a6c90a7237 v3: update mustermann to reduce allocated objects 2015-05-11 17:31:55 +02:00
Konstantin Haase
225e654f89 Merge branch 'master' of github.com:travis-ci/travis-api 2015-05-11 17:14:34 +02:00
Konstantin Haase
16c5106cd3 v3: reduce object allocations from polyorphic relations patch 2015-05-11 17:14:24 +02:00
Konstantin Haase
ea23fd3b7e add stackprof 2015-05-11 17:13:21 +02:00
Konstantin Haase
49750688ab Merge pull request #172 from travis-ci/sf-include-api-builds
Include event_type to build payloads
2015-05-06 17:19:00 +02:00
Sven Fuchs
40a9699a9e include event_type to build payloads, accept multiple event types 2015-05-06 17:08:49 +02:00
Konstantin Haase
2f19ba3357 API v3: don't load all builds when eagerloading repository.last_build 2015-05-05 17:01:03 +02:00
Konstantin Haase
59835c80f6 API v3: remove n+1 query from owner page endpoint 2015-05-05 16:43:52 +02:00
Konstantin Haase
cc82721565 Revert "v3: add active and private filter to owner query"
This reverts commit 2b12aadc0d.
2015-05-04 18:34:15 +02:00
Konstantin Haase
2b12aadc0d v3: add active and private filter to owner query 2015-05-04 18:23:40 +02:00
Konstantin Haase
140efa4766 Merge pull request #159 from travis-ci/sf-throttle-request-receive
Throttle request receive
2015-05-01 09:50:31 +02:00
Konstantin Haase
61ae7e669e v3: allow expanding build.commit 2015-04-30 17:08:52 +02:00
Konstantin Haase
fb8e6825db v3: expose build.previous_state 2015-04-30 16:25:14 +02:00
Konstantin Haase
ae7de12bec v3: add build.event_type 2015-04-30 16:17:55 +02:00
Konstantin Haase
ab6d236594 Merge branch 'master' of github.com:travis-ci/travis-api 2015-04-30 16:06:09 +02:00
Konstantin Haase
8215720b49 v3: don't fall back to v2 on 404 2015-04-30 16:05:58 +02:00
Sven Fuchs
7428ea4c7f restore deprecated POST /requests for restarting builds/jobs 2015-04-30 12:55:26 +02:00
Sven Fuchs
587a1a0f80 Auto-merged master into sf-throttle-request-receive on deployment. 2015-04-30 11:33:40 +02:00
Dan Buch
50d70f8429 Ignore *.env files 2015-04-29 19:09:30 -04:00
Konstantin Haase
69df85fdd6 Merge branch 'master' of github.com:travis-ci/travis-api 2015-04-29 14:49:04 +02:00
Konstantin Haase
815a217536 Merge branch 'rkh-v3-permissions' 2015-04-29 14:48:54 +02:00
Konstantin Haase
857f13b26c v3: add @permissions to user payload 2015-04-29 14:39:52 +02:00
Konstantin Haase
2094b50553 v3: add @permissions to organization payload 2015-04-29 14:28:33 +02:00
Konstantin Haase
21aa667b9c v3: add account permissions 2015-04-29 14:14:21 +02:00
Konstantin Haase
429ad3fc6b v3: don't error on including magic fields 2015-04-29 13:44:32 +02:00
Konstantin Haase
02d212c1e4 Merge pull request #171 from travis-ci/rkh-v3-permissions
[WiP] v3: expose access permissions
2015-04-29 11:40:59 +02:00
Konstantin Haase
2b0ae177fa v3: expose repo access permissions in payload 2015-04-29 11:31:05 +02:00
Konstantin Haase
77ad196a86 v3: use permissions check for enable/disable 2015-04-29 10:56:33 +02:00
Konstantin Haase
eac88e5d50 v3: introduce permission objects 2015-04-29 10:50:34 +02:00
Konstantin Haase
283092ff92 v3: avoid fetching the same repo owner over and over again when rendering a repo list 2015-04-28 22:28:45 +02:00
Konstantin Haase
075e2d1c6c v3: avoid n+1 query for last_build on the default branch when loading a list of repositories 2015-04-28 22:08:27 +02:00
Konstantin Haase
c3e96c4a55 v3: use query object for include logic to avoid n+1 queries 2015-04-28 22:02:03 +02:00
Konstantin Haase
ad7ff86aa7 v3: make sure access_control is handed on 2015-04-28 21:50:33 +02:00
Konstantin Haase
3730dc74df API v3: better eager loading and recursion detection for denormalized relations 2015-04-28 18:30:53 +02:00
Konstantin Haase
ae31a57541 v3: add @href to denormalized repository.owner 2015-04-28 18:14:36 +02:00
Konstantin Haase
49ad3bccda v3: properly hand on options to nested render calls 2015-04-28 16:46:45 +02:00
Konstantin Haase
40563b0864 Merge pull request #170 from travis-ci/rkh-v3-repos-by-owner
API v3: list repo by owner
2015-04-28 15:47:14 +02:00
Konstantin Haase
595163619d API v3: allow eager loading owner repos 2015-04-28 14:58:21 +02:00
Konstantin Haase
bac3b38153 API v3: specs for /owner/:login/repos endpoint 2015-04-28 12:44:20 +02:00
Konstantin Haase
bbba06a85f API v3: fix owner query 2015-04-28 12:43:54 +02:00
Konstantin Haase
44f2be4afb fix repo visibility filter 2015-04-28 12:41:51 +02:00
Konstantin Haase
99ca87b7c4 API v3: make polymorphic has_many work 2015-04-28 12:41:29 +02:00
Konstantin Haase
d8f1075491 start working on repos by owner endpoint 2015-04-27 17:01:41 +02:00
Hiro Asari
2485de7d44 Merge branch 'master' of github.com:travis-ci/travis-api 2015-04-23 11:25:13 -04:00
Hiro Asari
bf0d6f00da Reduce sidekiq concurrency
This may help in reducing memory usage
2015-04-23 11:25:03 -04:00
Konstantin Haase
922f221b09 v3: fix Model#=== 2015-04-22 16:24:26 +02:00
Konstantin Haase
7b5dc7b33d update travis-core 2015-04-22 16:24:14 +02:00
Konstantin Haase
3794a999a3 try to match last lib not first lib when loading directories 2015-04-22 15:22:40 +02:00
Konstantin Haase
67527afcb8 regenerate gemspec 2015-04-22 15:08:31 +02:00
Konstantin Haase
1b19b57109 v3: add accounts api 2015-04-17 13:34:29 +02:00
Konstantin Haase
344979a2a8 v3: rename account to owner (so we can use account for private accounts api) 2015-04-17 12:44:10 +02:00
Konstantin Haase
3680fcf389 v3: add subscription model 2015-04-17 12:16:11 +02:00
Konstantin Haase
aeb5046298 v3: one shared superclass for org/user renderers 2015-04-17 11:42:14 +02:00
Piotr Sarnacki
3cac519143 Ensure that both ways to get repos by ids are tested
In 222a970 I added a way to get repos by ids using format ids=1,2,3. It
turned out that getting by ids was already supported with
ids[]=1&ids[]=2 format, but it wasn't tested. I added tests for both
methods and left the comma separated ids list as we already support it
in other places.
2015-04-16 13:49:23 +02:00
Piotr Sarnacki
222a97028a Allow to get repositories by ids 2015-04-16 13:42:33 +02:00
Konstantin Haase
a12240a0eb v3: add avatar_url 2015-04-15 16:22:16 +02:00
Konstantin Haase
23c72dfa69 v3: remove include param from POST templates 2015-04-15 13:23:05 +02:00
Konstantin Haase
c3ce4738ec update travis-core 2015-04-15 13:22:46 +02:00
Hiro Asari
43aaf52e46 Update travis-core
So that we have
e87abc62c5
2015-04-14 21:16:25 -04:00
Konstantin Haase
d9f5e1e736 make user and org lookup by login case insensitive 2015-04-14 16:07:23 +02:00
Konstantin Haase
92864ed007 remove empty line 2015-04-13 17:08:29 +02:00
Konstantin Haase
3e47c93df8 v3: include query params in uri templates 2015-04-13 16:49:51 +02:00
Konstantin Haase
51c2d1f0bf v3: implement query params whitelisting to avoid argument injection attacks 2015-04-13 16:00:47 +02:00
Konstantin Haase
5efdcc24c8 implement accounts api 2015-04-13 13:12:18 +02:00
Piotr Sarnacki
0511223ca5 Fix specs 2015-03-25 16:19:03 +01:00
Piotr Sarnacki
6d74c51e0e Add avatar_url to accounts 2015-03-25 16:11:17 +01:00
Piotr Sarnacki
e8d6dfec60 Bump travis-core 2015-03-25 15:37:45 +01:00
Konstantin Haase
db623461ee update sinatra 2015-03-24 20:50:35 +01:00
Konstantin Haase
3a058339be v3: add /user and /user/:id 2015-03-24 17:25:57 +01:00
Sven Fuchs
a395ba865d throttle build request receive api 2015-02-11 17:46:55 +01:00
Sven Fuchs
4dfdefc933 remove deprecated restart action on /requests 2015-02-05 20:10:35 +01:00
609 changed files with 26816 additions and 3389 deletions

View File

@ -1,2 +1,2 @@
https://github.com/heroku/heroku-buildpack-ruby.git
https://github.com/drogus/last-commit-sha-buildpack.git
https://github.com/ryandotsmith/nginx-buildpack.git

12
.gitignore vendored
View File

@ -1,6 +1,12 @@
config/travis.yml
.yardoc
log/
vendor
config/database.yml
config/nginx.conf
config/skylight.yml
tmp/
logs/
.yardoc
.coverage
*.env
.ruby-gemset

3
.rspec Normal file
View File

@ -0,0 +1,3 @@
--require spec_helper
--colour
--tty

View File

@ -1 +1 @@
2.1.5
2.2.3

View File

@ -2,7 +2,7 @@ language: ruby
sudo: false
rvm: 2.1.5
rvm: 2.2.3
env:
global:
@ -18,4 +18,4 @@ services:
- redis
before_script:
- 'RAILS_ENV=test bundle exec rake db:create db:migrate --trace'
- 'RAILS_ENV=test bundle exec rake db:create --trace'

25
Gemfile
View File

@ -1,14 +1,14 @@
source 'https://rubygems.org'
gemspec
ruby '2.1.2' if ENV.key?('DYNO')
gem 's3', github: 'travis-ci/s3'
gem 'travis-core', github: 'travis-ci/travis-core'
gem 'travis-support', github: 'travis-ci/travis-support'
gem 'travis-amqp', github: 'travis-ci/travis-amqp'
gem 'travis-config', '~> 0.1.0'
gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil
gem 'travis-settings', github: 'travis-ci/travis-settings'
gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs'
gem 'travis-yaml', github: 'travis-ci/travis-yaml'
gem 'mustermann', github: 'rkh/mustermann'
gem 'sinatra'
@ -16,11 +16,11 @@ gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require:
gem 'active_model_serializers'
gem 'unicorn'
gem 'sentry-raven', github: 'getsentry/raven-ruby'
gem 'sentry-raven'
gem 'yard-sinatra', github: 'rkh/yard-sinatra'
gem 'rack-contrib', github: 'rack/rack-contrib'
gem 'rack-contrib'
gem 'rack-cache', github: 'rtomayko/rack-cache'
gem 'rack-attack'
gem 'rack-attack', '5.0.0.beta1'
gem 'gh'
gem 'bunny', '~> 0.8.0'
gem 'dalli'
@ -30,12 +30,23 @@ gem 'metriks-librato_metrics', github: 'eric/metriks-librato_metrics'
gem 'micro_migrations'
gem 'simplecov'
gem 'skylight', '~> 0.6.0.beta.1'
gem 'stackprof'
gem 'netaddr'
gem 'jemalloc'
gem 'customerio'
group :development, :test do
gem 'travis-migrations', github: 'travis-ci/travis-migrations'
end
group :test do
gem 'rspec', '~> 2.13'
gem 'rspec-its'
gem 'factory_girl', '~> 2.4.0'
gem 'mocha', '~> 0.12'
gem 'database_cleaner', '~> 0.8.0'
gem 'timecop', '~> 0.8.0'
end
group :development do

View File

@ -1,28 +1,13 @@
GIT
remote: git://github.com/eric/metriks-librato_metrics.git
revision: ccbeb751ec5fc4edfe446d8a67a423b96ebe86c7
revision: 2c124f024fd2e34378260cd24b0e8687ff9bd196
specs:
metriks-librato_metrics (1.0.2)
metriks-librato_metrics (1.0.5)
metriks (>= 0.9.9.6)
GIT
remote: git://github.com/getsentry/raven-ruby.git
revision: 84392e5db701f0b5c66802aab9cc82ef9a5ad830
specs:
sentry-raven (0.10.1)
faraday (>= 0.7.6)
uuidtools
GIT
remote: git://github.com/rack/rack-contrib.git
revision: 1b11346d729efd88b274cd7f704e0bca9eb3de7a
specs:
rack-contrib (1.2.0)
rack (>= 0.9.1)
GIT
remote: git://github.com/rkh/mustermann.git
revision: 01df7fe671838d6caadac278d9704b5cd3c7b999
revision: 9611951c5c789ad8227a740ae142c157a8bf7401
specs:
mustermann (0.4.0)
tool (~> 0.2)
@ -36,9 +21,9 @@ GIT
GIT
remote: git://github.com/rtomayko/rack-cache.git
revision: d00e6e491fcc7bdca9c27d735abde5c4fdb48cd9
revision: 2d6618172c39c53dceab2e2946d87496154f3e52
specs:
rack-cache (1.2)
rack-cache (1.6.1)
rack (>= 0.4)
GIT
@ -49,45 +34,42 @@ GIT
proxies (~> 0.2.0)
GIT
remote: git://github.com/travis-ci/travis-core.git
revision: 9ef018a267e94251dbaac54503a410baca71d1c6
remote: git://github.com/travis-ci/travis-amqp.git
revision: 3966b3651adfd1c544f53d49d5986ac16cd9c4bc
specs:
travis-core (0.0.1)
actionmailer (~> 3.2.19)
activerecord (~> 3.2.19)
coder (~> 0.4.0)
data_migrations (~> 0.0.1)
gh
hashr (~> 0.0.19)
metriks (~> 0.9.7)
multi_json
pusher (~> 0.14.0)
railties (~> 3.2.19)
rake
redis (~> 3.0)
rollout (~> 1.1.0)
s3 (~> 0.3)
simple_states (~> 1.0.0)
thor (~> 0.14.6)
travis-config (~> 0.1.0)
virtus (~> 1.0.0)
travis-amqp (0.0.1)
GIT
remote: git://github.com/travis-ci/travis-migrations.git
revision: dc432e45354287c617c3ae07a72e9e3c4be012cd
specs:
travis-migrations (0.0.2)
GIT
remote: git://github.com/travis-ci/travis-settings.git
revision: d510e63b6c6f059cccae141c265e7a0c7236d1fd
specs:
travis-settings (0.0.1)
activemodel
virtus
GIT
remote: git://github.com/travis-ci/travis-sidekiqs.git
revision: 21a2fee158e25252dd78f5fa31e81b4f6583be23
revision: c5d4a4abc6c3737f9c43d3333efb94daa18b9fbb
specs:
travis-sidekiqs (0.0.1)
redis-namespace
sidekiq
GIT
remote: git://github.com/travis-ci/travis-support.git
revision: 4fdd220ed7b06a12951e5d74a763c05a80eb0d20
revision: 2cd02d2a06fdd1e2fc2f129148c168b56f7c190f
specs:
travis-support (0.0.1)
GIT
remote: git://github.com/travis-ci/travis-yaml.git
revision: 1630d576d221aea2340615e87f402df7889b5176
revision: 032caed23af8ed1ed55e9204bb91316f3ada2f74
specs:
travis-yaml (0.2.0)
@ -95,29 +77,36 @@ PATH
remote: .
specs:
travis-api (0.0.1)
activerecord (~> 3.2.19)
coder (~> 0.4.0)
composite_primary_keys (~> 5.0)
google-api-client (~> 0.9.4)
hashr
memcachier
multi_json
mustermann (~> 0.4)
pg (~> 0.13.2)
pg
pusher (~> 0.14.0)
rack-contrib (~> 1.1)
rack-ssl (~> 1.3, >= 1.3.3)
railties (~> 3.2.19)
redcarpet (~> 2.1)
redis (~> 3.0)
rollout (~> 1.1.0)
simple_states (~> 1.0.0)
sinatra (~> 1.3)
sinatra-contrib (~> 1.3)
thin (~> 1.4)
travis-core
tool
travis-support
useragent
virtus (~> 1.0.0)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.19)
actionpack (= 3.2.19)
mail (~> 2.5.4)
actionpack (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
actionpack (3.2.22.2)
activemodel (= 3.2.22.2)
activesupport (= 3.2.22.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
@ -125,85 +114,103 @@ GEM
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
active_model_serializers (0.9.0)
active_model_serializers (0.9.5)
activemodel (>= 3.2)
activemodel (3.2.19)
activesupport (= 3.2.19)
activemodel (3.2.22.2)
activesupport (= 3.2.22.2)
builder (~> 3.0.0)
activerecord (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
activerecord (3.2.22.2)
activemodel (= 3.2.22.2)
activesupport (= 3.2.22.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activesupport (3.2.19)
activesupport (3.2.22.2)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
addressable (2.3.6)
addressable (2.4.0)
arel (3.0.3)
atomic (1.1.16)
atomic (1.1.99)
avl_tree (1.1.3)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
backports (3.6.4)
backports (3.6.8)
builder (3.0.4)
bunny (0.8.0)
celluloid (0.16.0)
timers (~> 4.0.0)
coder (0.4.0)
coderay (1.1.0)
coderay (1.1.1)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
composite_primary_keys (5.0.14)
activerecord (~> 3.2.0, >= 3.2.9)
connection_pool (2.1.1)
daemons (1.1.9)
dalli (2.7.2)
data_migrations (0.0.1)
activerecord
rake
concurrent-ruby (1.0.2)
connection_pool (2.2.0)
customerio (1.0.0)
multi_json (~> 1.0)
dalli (2.7.6)
database_cleaner (0.8.0)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.2.5)
docile (1.1.5)
dotenv (0.7.0)
equalizer (0.0.9)
equalizer (0.0.11)
erubis (2.7.0)
eventmachine (1.0.7)
factory_girl (2.4.2)
activesupport
faraday (0.9.1)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.6)
foreman (0.64.0)
dotenv (~> 0.7.0)
thor (>= 0.13.6)
gh (0.13.3)
ffi (1.9.10)
foreman (0.82.0)
thor (~> 0.19.1)
gh (0.14.0)
addressable
backports
faraday (~> 0.8)
multi_json (~> 1.0)
net-http-persistent (>= 2.7)
net-http-pipeline
git-version-bump (0.15.1)
google-api-client (0.9.8)
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)
hike (1.2.3)
hitimes (1.2.2)
httpclient (2.6.0.1)
i18n (0.6.11)
ice_nine (0.11.1)
hitimes (1.2.4)
httpclient (2.8.0)
hurley (0.2)
i18n (0.7.0)
ice_nine (0.11.2)
jemalloc (1.0.1)
journey (1.0.4)
json (1.8.1)
kgio (2.9.2)
listen (1.0.3)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
json (1.8.3)
jwt (1.5.4)
kgio (2.10.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
little-plugger (1.1.4)
logging (2.1.0)
little-plugger (~> 1.1)
multi_json (~> 1.10)
memcachier (0.0.2)
memoist (0.14.0)
metaclass (0.0.4)
method_source (0.8.2)
metriks (0.9.9.6)
@ -216,52 +223,58 @@ GEM
mime-types (1.25.1)
mocha (0.14.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
multi_json (1.12.1)
multipart-post (2.0.0)
net-http-persistent (2.9.4)
net-http-pipeline (1.0.1)
pg (0.13.2)
polyglot (0.3.5)
netaddr (1.5.1)
os (0.9.6)
pg (0.18.4)
proxies (0.2.1)
pry (0.10.1)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pusher (0.14.4)
pusher (0.14.6)
httpclient (~> 2.5)
multi_json (~> 1.0)
signature (~> 0.1.8)
rack (1.4.5)
rack-attack (4.2.0)
pusher-signature (~> 0.1.8)
pusher-signature (0.1.8)
rack (1.4.7)
rack-attack (5.0.0.beta1)
rack
rack-contrib (1.4.0)
git-version-bump (~> 0.15)
rack (~> 1.4)
rack-protection (1.5.3)
rack
rack-ssl (1.3.4)
rack
rack-test (0.6.2)
rack-test (0.6.3)
rack (>= 1.0)
railties (3.2.19)
actionpack (= 3.2.19)
activesupport (= 3.2.19)
railties (3.2.22.2)
actionpack (= 3.2.22.2)
activesupport (= 3.2.22.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
raindrops (0.13.0)
raindrops (0.16.0)
rake (0.9.6)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rb-kqueue (0.2.3)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (2.3.0)
redis (3.1.0)
redis-namespace (1.5.1)
redis (3.3.0)
redis-namespace (1.5.2)
redis (~> 3.0, >= 3.0.4)
rerun (0.8.2)
listen (~> 1.0.3)
representable (2.3.0)
uber (~> 0.0.7)
rerun (0.11.0)
listen (~> 3.0)
retriable (2.1.0)
rollout (1.1.0)
rspec (2.99.0)
rspec-core (~> 2.99.0)
@ -270,64 +283,64 @@ GEM
rspec-core (2.99.2)
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.99.2)
sidekiq (3.3.0)
celluloid (>= 0.16.0)
connection_pool (>= 2.0.0)
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
signature (0.1.8)
rspec-its (1.0.1)
rspec-core (>= 2.99.0.beta1)
rspec-expectations (>= 2.99.0.beta1)
rspec-mocks (2.99.4)
ruby_dep (1.3.1)
sentry-raven (1.0.0)
faraday (>= 0.7.6)
sidekiq (4.1.2)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
redis (~> 3.2, >= 3.2.1)
signet (0.7.2)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (~> 1.5)
multi_json (~> 1.10)
simple_states (1.0.1)
activesupport
hashr (~> 0.0.10)
simplecov (0.9.1)
simplecov (0.11.2)
docile (~> 1.1.0)
multi_json (~> 1.0)
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
sinatra (1.4.5)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
sinatra-contrib (1.4.2)
tilt (>= 1.3, < 3)
sinatra-contrib (1.4.7)
backports (>= 2.0)
multi_json
rack-protection
rack-test
sinatra (~> 1.4.0)
tilt (~> 1.3)
skylight (0.6.0.beta.1)
tilt (>= 1.3, < 3)
skylight (0.6.2.beta.2)
activesupport (>= 3.0.0)
slop (3.6.0)
sprockets (2.2.2)
sprockets (2.2.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thin (1.6.3)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0)
rack (~> 1.0)
thor (0.14.6)
thread_safe (0.3.4)
stackprof (0.2.9)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
timers (4.0.1)
hitimes
timecop (0.8.1)
tool (0.2.3)
travis-config (0.1.0)
travis-config (0.1.4)
hashr (~> 0.0)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.42)
unicorn (4.8.3)
tzinfo (0.3.49)
uber (0.0.15)
unicorn (5.1.0)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
useragent (0.10.0)
uuidtools (2.1.5)
virtus (1.0.4)
useragent (0.16.7)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
@ -340,35 +353,46 @@ PLATFORMS
DEPENDENCIES
active_model_serializers
bunny (~> 0.8.0)
customerio
dalli
database_cleaner (~> 0.8.0)
factory_girl (~> 2.4.0)
foreman
gh
jemalloc
metriks (= 0.9.9.6)
metriks-librato_metrics!
micro_migrations
mocha (~> 0.12)
mustermann!
netaddr
pry
rack-attack
rack-attack (= 5.0.0.beta1)
rack-cache!
rack-contrib!
rack-contrib
rake (~> 0.9.2)
rb-fsevent (~> 0.9.1)
rerun
rspec (~> 2.13)
rspec-its
s3!
sentry-raven!
sentry-raven
simplecov
sinatra
sinatra-contrib
skylight (~> 0.6.0.beta.1)
stackprof
timecop (~> 0.8.0)
travis-amqp!
travis-api!
travis-config (~> 0.1.0)
travis-core!
travis-migrations!
travis-settings!
travis-sidekiqs!
travis-support!
travis-yaml!
unicorn
yard-sinatra!
BUNDLED WITH
1.12.5

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Travis CI GmbH
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.

View File

@ -1,3 +1,4 @@
web: bundle exec ./script/server
console: bundle exec ./script/console
sidekiq: bundle exec sidekiq -c 5 -r ./lib/travis/sidekiq.rb -q build_cancellations, -q build_restarts, -q job_cancellations, -q job_restarts
web: ./script/server
console: bundle exec je ./script/console
sidekiq: bundle exec je sidekiq -c 4 -r ./lib/travis/sidekiq.rb -q build_cancellations, -q build_restarts, -q job_cancellations, -q job_restarts
start_crons: ./script/start_crons

102
README.md
View File

@ -4,47 +4,68 @@ This is the app running on https://api.travis-ci.org/
## Requirements
You will need the following packages to get travis-api to work:
1. PostgreSQL 9.3 or higher
1. Redis
1. RabbitMQ
2. Bundler
3. Redis Server
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
### Setup
$ bundle install
```sh-session
$ bundle install
```
### Database setup
1. `rake db:create db:structure:load`
1. Clone `travis-logs` and copy the `logs` database (assume the PostgreSQL user is `postgres`):
*You might need to create a role first. For this you should run the following:*
```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
$ sudo -u postgres psql -c "CREATE USER yourusername WITH SUPERUSER PASSWORD 'yourpassword'"
```
Repeat the database steps for `RAILS_ENV=test`.
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.
```sh-session
RAILS_ENV=test rake db:create db:structure:load
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
$ RAILS_ENV=development bundle exec rake db:create
$ RAILS_ENV=test bundle exec rake db:create
```
#### Optional
Clone `travis-logs` and copy the `logs` database (assume the PostgreSQL user is `postgres`):
```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
```
### Run tests
$ rake spec
```sh-session
$ bundle exec rake
```
### Run the server
$ script/server
```sh-session
$ bundle exec script/server
```
If you have problems with Nginx because the websocket is already in use, try restarting your computer.
## Contributing
@ -56,33 +77,4 @@ popd
### API documentation
We use source code comments to add documentation. If the server is running, you
can browse an HTML documenation at [`/docs`](http://localhost:5000/docs).
### Project architecture
lib
`-- travis
`-- api
`-- app
|-- endpoint # API endpoints
|-- extensions # Sinatra extensions
|-- helpers # Sinatra helpers
`-- middleware # Rack middleware
Classes inheriting from `Endpoint` or `Middleware`, they will automatically be
set up properly.
Each endpoint class gets mapped to a prefix, which defaults to the snake-case
class name (i.e. `Travis::Api::App::Profile` will map to `/profile`).
It can be overridden by setting `:prefix`:
``` ruby
require 'travis/api/app'
class Travis::Api::App
class MyRouts < Endpoint
set :prefix, '/awesome'
end
end
```
v3 documentation can be found at https://developer.travis-ci.org which is a repository that can be found at https://github.com/travis-pro/developer

149
Rakefile
View File

@ -1,127 +1,34 @@
require 'bundler/setup'
require 'travis'
require 'travis/engine'
begin
ENV['SCHEMA'] = File.expand_path('../db/schema.rb', $:.detect { |p| p.include?('travis-core') })
require 'micro_migrations'
rescue LoadError
# we can't load micro migrations on production
end
require 'travis'
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
task default: :spec
rescue LoadError
warn "could not load rspec"
end
desc "generate gemspec"
task 'travis-api.gemspec' do
content = File.read 'travis-api.gemspec'
fields = {
authors: `git shortlog -sn`.scan(/[^\d\s].*/),
email: `git shortlog -sne`.scan(/[^<]+@[^>]+/),
files: `git ls-files`.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ }
}
fields.each do |field, values|
updated = " s.#{field} = ["
updated << values.map { |v| "\n %p" % v }.join(',')
updated << "\n ]"
content.sub!(/ s\.#{field} = \[\n( .*\n)* \]/, updated)
end
File.open('travis-api.gemspec', 'w') { |f| f << content }
end
task default: 'travis-api.gemspec'
tasks_path = File.expand_path('../lib/tasks/*.rake', __FILE__)
Dir.glob(tasks_path).each { |r| import r }
module ActiveRecord
class Migration
class << self
attr_accessor :disable_ddl_transaction
end
# Disable DDL transactions for this migration.
def self.disable_ddl_transaction!
@disable_ddl_transaction = true
end
def disable_ddl_transaction # :nodoc:
self.class.disable_ddl_transaction
namespace :db do
env = ENV["RAILS_ENV"]
if env != 'production'
desc "Create and migrate the #{env} database"
task :create do
sh "createdb travis_#{env}" rescue nil
sh "psql -q travis_#{env} < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql"
end
end
end
class Migrator
def use_transaction?(migration)
!migration.disable_ddl_transaction && Base.connection.supports_ddl_transactions?
end
# begin
# require 'rspec'
# require 'rspec/core/rake_task'
# RSpec::Core::RakeTask.new(:spec)
#
# RSpec::Core::RakeTask.new(:spec_core) do |t|
# t.pattern = 'spec_core/**{,/*/**}/*_spec.rb'
# end
#
# task :default => [:spec]
# rescue LoadError => e
# puts e.inspect
# end
def ddl_transaction(migration, &block)
if use_transaction?(migration)
Base.transaction { block.call }
else
block.call
end
end
def migrate(&block)
current = migrations.detect { |m| m.version == current_version }
target = migrations.detect { |m| m.version == @target_version }
if target.nil? && @target_version && @target_version > 0
raise UnknownMigrationVersionError.new(@target_version)
end
start = up? ? 0 : (migrations.index(current) || 0)
finish = migrations.index(target) || migrations.size - 1
runnable = migrations[start..finish]
# skip the last migration if we're headed down, but not ALL the way down
runnable.pop if down? && target
ran = []
runnable.each do |migration|
if block && !block.call(migration)
next
end
Base.logger.info "Migrating to #{migration.name} (#{migration.version})" if Base.logger
seen = migrated.include?(migration.version.to_i)
# On our way up, we skip migrating the ones we've already migrated
next if up? && seen
# On our way down, we skip reverting the ones we've never migrated
if down? && !seen
migration.announce 'never migrated, skipping'; migration.write
next
end
begin
ddl_transaction(migration) do
migration.migrate(@direction)
record_version_state_after_migrating(migration.version)
end
ran << migration
rescue => e
canceled_msg = Base.connection.supports_ddl_transactions? ? "this and " : ""
raise StandardError, "An error has occurred, #{canceled_msg}all later migrations canceled:\n\n#{e}", e.backtrace
end
end
ran
end
end
class MigrationProxy
delegate :disable_ddl_transaction, to: :migration
# not sure how else to include the spec_helper
namespace :spec do
desc 'Run all specs'
task :all do
sh 'bundle exec rspec -r spec_helper spec'
end
end
task :default => :'spec:all'

View File

@ -1,3 +1,82 @@
#!/bin/sh
#!/usr/bin/env bash
"$@"
# make sure we kill all child processes once done
trap '{ pkill -P $$; rm -f config/nginx.conf; exit 255; }' EXIT
if [ -f bin/nginx ]; then
nginx=bin/nginx
else
which nginx &>/dev/null || { echo "nginx not found" && exit 1; }
nginx=nginx
fi
psmgr=$tmp_dir/nginx-buildpack-wait
rm -f $psmgr
mkfifo $psmgr
#Evaluate config to get $PORT
erb config/nginx.conf.erb > config/nginx.conf
n=1
while getopts :f option ${@:1:2}
do
case "${option}"
in
f) FORCE=$OPTIND; n=$((n+1));;
esac
done
#Initialize log directory.
mkdir -p logs/nginx
touch logs/nginx/access.log logs/nginx/error.log
echo 'buildpack=nginx at=logs-initialized'
#Start log redirection.
(
#Redirect NGINX logs to stdout.
tail -qF -n 0 logs/nginx/*.log
echo 'logs' >$psmgr
) &
#Start App Server
(
#Take the command passed to this bin and start it.
#E.g. bin/start-nginx bundle exec unicorn -c config/unicorn.rb
COMMAND=${@:$n}
echo "buildpack=nginx at=start-app cmd=$COMMAND"
$COMMAND
echo 'app' >$psmgr
) &
if [[ -z "$FORCE" ]]
then
FILE="$tmp_dir/app-initialized"
#We block on app-initialized so that when NGINX binds to $PORT
#are app is ready for traffic.
while [[ ! -f "$FILE" ]]
do
echo 'buildpack=nginx at=app-initialization'
sleep 1
done
echo 'buildpack=nginx at=app-initialized'
fi
#Start NGINX
(
#We expect nginx to run in foreground.
#We also expect a socket to be at $tmp_dir/nginx.socket.
echo 'buildpack=nginx at=nginx-start'
$nginx -p . -c config/nginx.conf
echo 'nginx' >$psmgr
) &
#This read will block the process waiting on a msg to be put into the fifo.
#If any of the processes defined above should exit,
#a msg will be put into the fifo causing the read operation
#to un-block. The process putting the msg into the fifo
#will use it's process name as a msg so that we can print the offending
#process to stdout.
read exit_process <$psmgr
echo "buildpack=nginx at=exit process=$exit_process"
exit 1

View File

@ -20,4 +20,3 @@ development:
test:
<<: *defaults
database: travis_test

76
config/mime.types Normal file
View File

@ -0,0 +1,76 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml;
text/cache-manifest manifest appcache;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mpeg mpeg mpg;
video/quicktime mov;
video/x-flv flv;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}

45
config/nginx.conf.erb Normal file
View File

@ -0,0 +1,45 @@
daemon off;
#Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || ENV['WEB_CONCURRENCY'] || 4 %>;
events {
<% if `uname` != "Darwin\n" %>use epoll;<% end %>
accept_mutex on;
worker_connections 1024;
}
http {
gzip on;
gzip_comp_level 2;
gzip_min_length 512;
server_tokens off;
log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
access_log logs/nginx/access.log l2met;
error_log logs/nginx/error.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
#Must read the body in 5 seconds.
client_body_timeout 5;
upstream app_server {
server unix:<%= ENV["tmp_dir"] %>/nginx.socket fail_timeout=0;
}
server {
listen <%= ENV["PORT"] %>;
server_name _;
keepalive_timeout 5;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
}

View File

@ -2,8 +2,8 @@ root = File.expand_path('../..', __FILE__)
rackup "#{root}/config.ru"
bind 'unix:///tmp/nginx.socket'
tmp_dir = ENV.fetch("tmp_dir", "/tmp")
bind "unix://#{tmp_dir}/nginx.socket"
environment ENV['RACK_ENV'] || 'development'
threads 0, 16

7
config/ruby_config.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
export RUBY_HEAP_MIN_SLOTS=800000
export RUBY_GC_HEAP_INIT_SLOTS=$RUBY_HEAP_MIN_SLOTS
export RUBY_GC_MALLOC_LIMIT=59000000
export RUBY_HEAP_SLOTS_INCREMENT=10000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_HEAP_FREE_MIN=100000

View File

@ -1,19 +1,16 @@
# http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-single-heroku-dyno-with-the-new-celadon-cedar-stack/
worker_processes 4 # amount of unicorn workers to spin up
timeout 30 # restarts workers that hang for 15 seconds
worker_processes Integer(ENV.fetch('WEB_CONCURRENCY')) # amount of unicorn workers to spin up
timeout 30 # restarts workers that hang for 30 seconds
listen '/tmp/nginx.socket', backlog: 1024
tmp_dir = ENV.fetch("tmp_dir", "/tmp")
listen File.expand_path("nginx.socket", tmp_dir), backlog: 1024
require 'fileutils'
before_fork do |server,worker|
FileUtils.touch('/tmp/app-initialized')
end
before_fork do |server, worker|
# preload travis so we can have copy on write
require 'travis/api/app'
before_exec do |server|
ENV['RUBY_HEAP_MIN_SLOTS']=800000
ENV['RUBY_GC_MALLOC_LIMIT']=59000000
ENV['RUBY_HEAP_SLOTS_INCREMENT']=10000
ENV['RUBY_HEAP_SLOTS_GROWTH_FACTOR']=1
ENV['RUBY_HEAP_FREE_MIN']=100000
# signal to nginx we're ready
FileUtils.touch("#{tmp_dir}/app-initialized")
end

BIN
heroku-buildpack-sigsci.tgz Normal file

Binary file not shown.

View File

@ -0,0 +1,30 @@
# This backports support for the :variables option on postgres database details from ActiveRecord 4 to ActiveRecord 3.
require 'active_record'
if ActiveRecord::VERSION::MAJOR < 4
require 'active_record/connection_adapters/postgresql_adapter'
module ActiveRecordPostgresVariables
def configure_connection
result = super
set_variables
result
end
def set_variables
return unless variables = @config[:variables]
# copied from AR 4.2.1
variables.map do |k, v|
if v == ':default' || v == :default
# Sets the value to the global or compile default
execute("SET SESSION #{k} TO DEFAULT", 'SCHEMA')
elsif !v.nil?
execute("SET SESSION #{k} TO #{quote(v)}", 'SCHEMA')
end
end
end
end
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(ActiveRecordPostgresVariables)
end

67
lib/travis.rb Normal file
View File

@ -0,0 +1,67 @@
require 'pusher'
require 'travis/support'
require 'travis/support/database'
require 'travis/redis_pool'
require 'travis/errors'
module Travis
class << self
def services=(services)
@services = services
end
def services
@services ||= Travis::Services
end
end
require 'travis/model'
require 'travis/task'
require 'travis/event'
require 'travis/api/serialize'
require 'travis/config/defaults'
require 'travis/features'
require 'travis/github'
require 'travis/notification'
require 'travis/services'
class UnknownRepository < StandardError; end
class GithubApiError < StandardError; end
class AdminMissing < StandardError; end
class RepositoryMissing < StandardError; end
class LogAlreadyRemoved < StandardError; end
class AuthorizationDenied < StandardError; end
class JobUnfinished < StandardError; end
class << self
def setup(options = {})
@config = Config.load(*options[:configs])
@redis = Travis::RedisPool.new(config.redis.to_h)
Travis.logger.info('Setting up Travis::Core')
Github.setup
Services.register
Github::Services.register
end
attr_accessor :redis, :config
def pusher
@pusher ||= ::Pusher.tap do |pusher|
pusher.app_id = config.pusher.app_id
pusher.key = config.pusher.key
pusher.secret = config.pusher.secret
pusher.scheme = config.pusher.scheme if config.pusher.scheme
pusher.host = config.pusher.host if config.pusher.host
pusher.port = config.pusher.port if config.pusher.port
end
end
def states_cache
@states_cache ||= Travis::StatesCache.new
end
end
setup
end

View File

@ -1,26 +1,40 @@
# these things need to go first
require 'conditional_skylight'
require 'active_record_postgres_variables'
# now actually load travis
require 'travis'
require 'travis/amqp'
require 'travis/model'
require 'travis/support/amqp'
require 'travis/states_cache'
require 'rack'
require 'rack/protection'
require 'rack/contrib'
require 'rack/contrib/config'
require 'rack/contrib/jsonp'
require 'rack/contrib/post_body_content_type_parser'
require 'dalli'
require 'memcachier'
require 'rack/cache'
require 'rack/attack'
require 'travis/api/attack'
require 'active_record'
require 'redis'
require 'gh'
require 'raven'
require 'raven/integrations/rack'
require 'sidekiq'
require 'metriks/reporter/logger'
require 'metriks/librato_metrics_reporter'
require 'travis/support/log_subscriber/active_record_metrics'
require 'fileutils'
require 'securerandom'
module Travis::Api
end
require 'travis/api/app/endpoint'
require 'travis/api/app/middleware'
require 'travis/api/instruments'
require 'travis/api/v2/http'
require 'travis/api/serialize/v2'
require 'travis/api/v3'
require 'travis/api/app/stack_instrumentation'
require 'travis/api/app/error_handling'
@ -68,34 +82,27 @@ module Travis::Api
end
def self.deploy_sha
@deploy_sha ||= File.exist?(deploy_sha_path) ? File.read(deploy_sha_path)[0..7] : 'deploy-sha'
end
def self.deploy_sha_path
File.expand_path('../../../../.deploy-sha', __FILE__)
@deploy_sha ||= ENV['HEROKU_SLUG_COMMIT'] || SecureRandom.hex(5)
end
attr_accessor :app
def initialize
@app = Rack::Builder.app do
# if stackprof = ENV['STACKPROF']
# require 'stackprof'
# modes = ['wall', 'cpu', 'object', 'custom']
# mode = modes.include?(stackprof) ? stackprof.to_sym : :cpu
# Travis.logger.info "Setting up profiler: #{mode}"
# use StackProf::Middleware, enabled: true, save_every: 1, mode: mode
# end
extend StackInstrumentation
use Travis::Api::App::Middleware::Skylight
use(Rack::Config) { |env| env['metriks.request.start'] ||= Time.now.utc }
Rack::Utils::HTTP_STATUS_CODES[420] = "Enhance Your Calm"
use Rack::Attack
Rack::Attack.blacklist('block client requesting ruby builds') do |req|
req.ip == "130.15.4.210"
end
Rack::Attack.blacklisted_response = lambda do |env|
[ 420, {}, ['Enhance Your Calm']]
end
use Travis::Api::App::Cors # if Travis.env == 'development' ???
use Raven::Rack if Travis.env == 'production' || Travis.env == 'staging'
use Rack::Protection::PathTraversal
use Raven::Rack if Travis::Api::App.use_monitoring?
use Rack::SSL if Endpoint.production?
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
@ -120,7 +127,9 @@ module Travis::Api
use Travis::Api::App::Middleware::Logging
use Travis::Api::App::Middleware::ScopeCheck
use Travis::Api::App::Middleware::UserAgentTracker
use Travis::Api::App::Middleware::Metriks
# make sure this is below ScopeCheck so we have the token
use Rack::Attack if Endpoint.production? and not Travis.config.enterprise
# if this is a v3 API request, ignore everything after
use Travis::API::V3::OptIn
@ -128,6 +137,9 @@ module Travis::Api
# rewrite should come after V3 hook
use Travis::Api::App::Middleware::Rewrite
# v3 has its own metriks
use Travis::Api::App::Middleware::Metriks
SettingsEndpoint.subclass :env_vars
if Travis.config.endpoints.ssh_key
SingletonSettingsEndpoint.subclass :ssh_key
@ -164,14 +176,13 @@ module Travis::Api
def self.setup!
setup_travis
load_endpoints
setup_endpoints
@setup = true
end
def self.setup_travis
Travis::Async.enabled = true
Travis::Amqp.config = Travis.config.amqp
Travis::Amqp.setup(Travis.config.amqp)
setup_database_connections
@ -181,17 +192,21 @@ module Travis::Api
end
end
if use_monitoring? and not console?
if use_monitoring? && !console?
setup_monitoring
end
end
def self.setup_database_connections
Travis.config.database.variables ||= {}
Travis.config.database.variables.application_name ||= ["api", Travis.env, ENV['DYNO']].compact.join(?-)
Travis::Database.connect
if Travis.config.logs_database
Log.establish_connection 'logs_database'
Log::Part.establish_connection 'logs_database'
pool_size = ENV['DATABASE_POOL_SIZE']
Travis.config.logs_database[:pool] = pool_size.to_i if pool_size
Travis::LogsModel.establish_connection 'logs_database'
end
end
@ -203,11 +218,6 @@ module Travis::Api
Travis::Metrics.setup
end
def self.load_endpoints
Dir.glob("#{__dir__}/app/middleware/*.rb").each { |f| require f[%r[(?<=lib/).+(?=\.rb$)]] }
Dir.glob("#{__dir__}/app/endpoint/*.rb").each { |f| require f[%r[(?<=lib/).+(?=\.rb$)]] }
end
def self.setup_endpoints
Base.subclasses.each(&:setup)
end

View File

@ -1,6 +1,8 @@
require 'travis/api/app'
require 'sinatra/base'
require 'mustermann'
require 'travis/api/app'
require 'travis/api/app/extensions'
require 'travis/api/app/helpers'
class Travis::Api::App
# Superclass for any endpoint and middleware.

View File

@ -15,6 +15,11 @@ class Travis::Api::App
options // do
headers['Access-Control-Allow-Methods'] = "HEAD, GET, POST, PATCH, PUT, DELETE"
headers['Access-Control-Allow-Headers'] = "Content-Type, Authorization, Accept, If-None-Match, If-Modified-Since, X-User-Agent, Travis-API-Version"
# cache OPTIONS for 24 hours to avoid excessive preflight requests and speed up access
# browsers might still limit this value to 10 minutes, see caveats
# http://stackoverflow.com/a/12021982
headers['Access-Control-Max-Age'] = "86400"
end
end
end

View File

@ -1,6 +1,7 @@
require 'travis/api/app'
require 'addressable/uri'
require 'active_record/base'
require 'travis/api/app'
require 'travis/api/app/base'
class Travis::Api::App
# Superclass for HTTP endpoints. Takes care of prefixing.
@ -48,3 +49,23 @@ class Travis::Api::App
end
end
end
require 'travis/api/app/endpoint/accounts'
require 'travis/api/app/endpoint/authorization'
require 'travis/api/app/endpoint/branches'
require 'travis/api/app/endpoint/broadcasts'
require 'travis/api/app/endpoint/builds'
require 'travis/api/app/endpoint/documentation'
require 'travis/api/app/endpoint/endpoints'
require 'travis/api/app/endpoint/env_vars'
require 'travis/api/app/endpoint/home'
require 'travis/api/app/endpoint/hooks'
require 'travis/api/app/endpoint/jobs'
require 'travis/api/app/endpoint/lint'
require 'travis/api/app/endpoint/logs'
require 'travis/api/app/endpoint/repos'
require 'travis/api/app/endpoint/requests'
require 'travis/api/app/endpoint/setting_endpoint'
require 'travis/api/app/endpoint/singleton_settings_endpoint'
require 'travis/api/app/endpoint/uptime'
require 'travis/api/app/endpoint/users'

View File

@ -1,7 +1,10 @@
require 'travis/api/app'
require 'addressable/uri'
require 'faraday'
require 'securerandom'
require 'customerio'
require 'travis/api/app'
require 'travis/github/education'
require 'travis/github/oauth'
class Travis::Api::App
class Endpoint
@ -78,6 +81,7 @@ class Travis::Api::App
#
# * **github_token**: GitHub token for checking authorization (required)
post '/github' do
check_agent
unless params[:github_token]
halt 422, { "error" => "Must pass 'github_token' parameter" }
end
@ -94,6 +98,7 @@ class Travis::Api::App
# * **redirect_uri**: URI to redirect to after handshake.
get '/handshake' do
handshake do |user, token, redirect_uri|
if target_ok? redirect_uri
content_type :html
data = { user: user, token: token, uri: redirect_uri }
@ -109,7 +114,7 @@ class Travis::Api::App
# access token and user payload to the parent window via postMessage.
#
# However, the endpoint to send the payload to has to be explicitely
# whitelisted in production, as this is endpoint is only meant to be used
# safelisted in production, as this is endpoint is only meant to be used
# with the official Travis CI client at the moment.
#
# Example usage:
@ -145,8 +150,46 @@ class Travis::Api::App
private
def allowed_agents
@allowed_agents ||= redis.smembers('auth_agents')
end
def check_agent
return if settings.test? or allowed_agents.empty?
return if allowed_agents.any? { |a| request.user_agent.to_s.start_with? a }
halt 403, "you are currently not allowed to perform this request. please contact support@travis-ci.com."
end
# update first login date if not set
def update_first_login(user)
unless user.first_logged_in_at
user.update_attributes(first_logged_in_at: Time.now)
end
end
def update_customerio(user)
return unless Travis.config.customerio.site_id
# send event to customer.io
payload = {
:id => user.id,
:name => user.name,
:login => user.login,
:email => primary_email_for_user(user.github_oauth_token),
:created_at => user.created_at.to_i,
:github_id => user.github_id,
:education => user.education,
:first_logged_in_at => user.first_logged_in_at.to_i,
:travis_domain => Travis.config.client_domain
}
customerio.identify(payload)
rescue StandardError => e
Travis.logger.error "Could not update Customer.io for User: #{user.id}:#{user.login} with message:#{e.message}"
end
def serialize_user(user)
rendered = Travis::Api.data(user, version: :v2)
rendered = Travis::Api::Serialize.data(user, version: :v2)
rendered['user'].merge('token' => user.tokens.first.try(:token).to_s)
end
@ -174,6 +217,8 @@ class Travis::Api::App
user = user_for_github_token(github_token)
token = generate_token(user: user, app_id: 0)
payload = params[:state].split(":::", 2)[1]
update_first_login(user)
update_customerio(user)
yield serialize_user(user), token, payload
else
values[:state] = create_state
@ -183,6 +228,7 @@ class Travis::Api::App
end
end
def create_state
state = SecureRandom.urlsafe_base64(16)
redis.sadd('github:states', state)
@ -212,6 +258,7 @@ class Travis::Api::App
super
@user = ::User.find_by_github_id(data['id'])
end
def info(attributes = {})
@ -243,8 +290,11 @@ class Travis::Api::App
user.update_attributes info
else
self.user = ::User.create! info
Travis.run_service(:sync_user, user)
end
Travis::Github::Oauth.update_scopes(user) # unless Travis.env == 'test'
nullify_logins(user.github_id, user.login)
end
@ -296,7 +346,7 @@ class Travis::Api::App
end
def acceptable?(scopes, lossy = false)
User::Oauth.wanted_scopes.all? do |scope|
Travis::Github::Oauth.wanted_scopes.all? do |scope|
acceptable_scopes_for(scope, lossy).any? { |s| scopes.include? s }
end
end
@ -342,6 +392,15 @@ class Travis::Api::App
def allowed_https_targets
@allowed_https_targets ||= Travis.config.auth.target_origin.to_s.split(',')
end
def primary_email_for_user(oauth_token)
# check for the users primary email address (we don't store this info)
GH.with(token: oauth_token, client_id: nil) { GH['user/emails'] }.select { |e| e['primary'] }.first['email']
end
def customerio
Customerio::Client.new(Travis.config.customerio.site_id, Travis.config.customerio.api_key, :json => true)
end
end
end
end
@ -350,7 +409,7 @@ __END__
@@ invalid_target
<script>
console.log('refusing to send a token to <%= target_origin.inspect %>, not whitelisted!');
console.log('refusing to send a token to <%= target_origin.inspect %>, not safelisted!');
</script>
@@ common

View File

@ -1,6 +1,8 @@
require 'travis/api/app'
require 'travis/api/workers/build_cancellation'
require 'travis/api/workers/build_restart'
require 'travis/api/enqueue/services/restart_model'
require 'travis/api/enqueue/services/cancel_model'
class Travis::Api::App
class Endpoint
@ -20,7 +22,8 @@ class Travis::Api::App
post '/:id/cancel' do
Metriks.meter("api.request.cancel_build").mark
service = self.service(:cancel_build, params.merge(source: 'api'))
service = Travis::Enqueue::Services::CancelModel.new(current_user, { build_id: params[:id] })
if !service.authorized?
json = { error: {
message: "You don't have access to cancel build(#{params[:id]})"
@ -39,7 +42,9 @@ class Travis::Api::App
status 422
respond_with json
else
Travis::Sidekiq::BuildCancellation.perform_async(id: params[:id], user_id: current_user.id, source: 'api')
payload = { id: params[:id], user_id: current_user.id, source: 'api' }
service.push("build:cancel", payload)
Metriks.meter("api.request.cancel_build.success").mark
status 204
@ -48,16 +53,18 @@ class Travis::Api::App
post '/:id/restart' do
Metriks.meter("api.request.restart_build").mark
service = Travis::Enqueue::Services::RestartModel.new(current_user, build_id: params[:id])
service = self.service(:reset_model, build_id: params[:id])
if !service.accept?
result = if !service.accept?
status 400
result = false
false
else
Travis::Sidekiq::BuildRestart.perform_async(id: params[:id], user_id: current_user.id)
payload = { id: params[:id], user_id: current_user.id }
service.push("build:restart", payload)
status 202
result = true
true
end
respond_with(result: result, flash: service.messages)
end
end

View File

@ -11,7 +11,7 @@ class Travis::Api::App
host: host,
shorten_host: Travis.config.shorten_host,
assets: Travis.config.assets,
pusher: (Travis.config.pusher_ws || Travis.config.pusher || {}).to_hash.slice(:scheme, :host, :port, :path, :key),
pusher: (Travis.config.pusher_ws || Travis.config.pusher || {}).to_hash.slice(:scheme, :host, :port, :path, :key, :secure, :private),
github: { api_url: GH.current.api_host.to_s, scopes: Travis.config.oauth2.try(:scope).to_s.split(?,) }
# Landing point. Redirects web browsers to [API documentation](#/docs/).
@ -49,6 +49,18 @@ class Travis::Api::App
get '/config' do
{ config: settings.client_config }
end
deploy_sha = File.read(".deploy-sha") if File.exist?(".deploy-sha")
sys_info = {
web_concurrency: ENV['WEB_CONCURRENCY'],
ulimit: `echo "ulimit -u" | bash`.to_i,
dyno: ENV['DYNO'],
deploy_sha: deploy_sha
}
get '/sysinfo' do
sys_info
end
end
end
end

View File

@ -1,6 +1,8 @@
require 'travis/api/app'
require 'travis/api/workers/job_cancellation'
require 'travis/api/workers/job_restart'
require 'travis/api/enqueue/services/restart_model'
require 'travis/api/enqueue/services/cancel_model'
class Travis::Api::App
class Endpoint
@ -27,7 +29,8 @@ class Travis::Api::App
post '/:id/cancel' do
Metriks.meter("api.request.cancel_job").mark
service = self.service(:cancel_job, params.merge(source: 'api'))
service = Travis::Enqueue::Services::CancelModel.new(current_user, { job_id: params[:id] })
if !service.authorized?
json = { error: {
message: "You don't have access to cancel job(#{params[:id]})"
@ -46,7 +49,8 @@ class Travis::Api::App
status 422
respond_with json
else
Travis::Sidekiq::JobCancellation.perform_async(id: params[:id], user_id: current_user.id, source: 'api')
payload = { id: params[:id], user_id: current_user.id, source: 'api' }
service.push("job:cancel", payload)
Metriks.meter("api.request.cancel_job.success").mark
status 204
@ -56,15 +60,18 @@ class Travis::Api::App
post '/:id/restart' do
Metriks.meter("api.request.restart_job").mark
service = self.service(:reset_model, job_id: params[:id])
if !service.accept?
service = Travis::Enqueue::Services::RestartModel.new(current_user, { job_id: params[:id] })
result = if !service.accept?
status 400
result = false
false
else
Travis::Sidekiq::JobRestart.perform_async(id: params[:id], user_id: current_user.id)
payload = {id: params[:id], user_id: current_user.id}
service.push("job:restart", payload)
status 202
result = true
true
end
respond_with(result: result, flash: service.messages)
end

View File

@ -16,6 +16,7 @@ class Travis::Api::App
# json(:repositories)
get '/' do
prefer_follower do
params['ids'] = params['ids'].split(',') if params['ids'].respond_to?(:split)
respond_with service(:find_repos, params)
end
end

View File

@ -1,19 +1,10 @@
require 'travis/api/app'
require 'travis/api/app/services/schedule_request'
require 'travis/api/enqueue/services/restart_model'
class Travis::Api::App
class Endpoint
class Requests < Endpoint
post '/', scope: :private do
if params[:request] && params[:request][:repository]
respond_with service(:schedule_request, params[:request])
else
# DEPRECATED: this will be removed by 1st of December
Metriks.meter("api.request.restart").mark
respond_with service(:reset_model, params)
end
end
get '/' do
begin
respond_with(service(:find_requests, params).run)
@ -26,7 +17,28 @@ class Travis::Api::App
get '/:id' do
respond_with service(:find_request, params)
end
post '/', scope: :private do
if params[:request] && params[:request][:repository]
status 404
else
# DEPRECATED: this will be removed by 1st of December
#
# TODO It seems this endpoint is still in use, quite a bit:
# https://metrics.librato.com/s/metrics/api.request.restart?duration=2419200&q=api.request.restart
#
# I think we need to properly deprecate this by publishing a blog post.
Metriks.meter("api.request.restart").mark
service = Travis::Enqueue::Services::RestartModel.new(current_user, params)
params[:user_id] = service.target.repository.owner.id
type = params[:build_id] ? 'build' : 'job'
params[:id] = params[:build_id] || params[:job_id]
service.push("#{type}:restart", params)
respond_with(result: true, flash: service.messages)
end
end
end
end
end

View File

@ -9,7 +9,7 @@ class Travis::Api::App
Thread.new do
loop do
begin
Raven.send queue.pop
Raven.send_event queue.pop
rescue Exception => e
puts e.message, e.backtrace
end

View File

@ -1,8 +1,4 @@
require 'travis/api/app'
class Travis::Api::App
# Namespace for Sinatra extensions.
module Extensions
Dir.glob("#{__dir__}/extensions/*.rb").each { |f| require f[%r[(?<=lib/).+(?=\.rb$)]] }
end
end
require 'travis/api/app/extensions/expose_pattern'
require 'travis/api/app/extensions/scoping'
require 'travis/api/app/extensions/smart_constants'
require 'travis/api/app/extensions/subclass_tracker'

View File

@ -1,8 +1,7 @@
require 'travis/api/app'
class Travis::Api::App
# Namespace for helpers.
module Helpers
Dir.glob("#{__dir__}/helpers/*.rb").each { |f| require f[%r[(?<=lib/).+(?=\.rb$)]] }
end
end
require 'travis/api/app/helpers/accept'
require 'travis/api/app/helpers/current_user'
require 'travis/api/app/helpers/db_follower'
require 'travis/api/app/helpers/flash'
require 'travis/api/app/helpers/mime_types'
require 'travis/api/app/helpers/respond_with'

View File

@ -53,6 +53,8 @@ class Travis::Api::App
if params
params = Hash[*params.split(';').map { |p| p.scan /(#{TOKEN})=(#{TOKEN})/ }.flatten]
quality = params.delete('q').to_f if params['q']
else
params = {}
end
if subtype =~ HEADER_FORMAT
@ -82,7 +84,7 @@ class Travis::Api::App
end
def accept_version
@accept_version ||= request.accept.join =~ HEADER_FORMAT && "v#{$1}" || DEFAULT_VERSION
@accept_version ||= accept_entries.map(&:version).compact.first || DEFAULT_VERSION
end
def accept_format

View File

@ -3,5 +3,11 @@ require 'travis/api/app'
class Travis::Api::App
# Superclass for all middleware.
class Middleware < Base
require 'travis/api/app/middleware/logging'
require 'travis/api/app/middleware/metriks'
require 'travis/api/app/middleware/rewrite'
require 'travis/api/app/middleware/scope_check'
require 'travis/api/app/middleware/skylight'
require 'travis/api/app/middleware/user_agent_tracker'
end
end

View File

@ -37,7 +37,7 @@ class Travis::Api::App
end
def mark_travis(agent)
command = agent.application.comment.detect { |c| c.start_with? "command " }
command = agent.application.comment.detect { |c| c.start_with? "command " } if agent.application.comment
if command
mark(:cli, :version, agent.version)

View File

@ -4,15 +4,15 @@ module Travis::Api::App::Responders
class Atom < Base
ATOM_FEED_ERB = ERB.new <<-EOF
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><%= resource.first.repository.slug %> Builds</title>
<link href="<%= endpoint.url %>" type="application/atom+xml" rel = "self" />
<id>repo:<%= resource.first.repository.id %></id>
<rights>Copyright (c) <%= DateTime.now.strftime("%Y") %> Travis CI GmbH</rights>
<updated><%= DateTime.now.rfc3339 %></updated>
<% resource.each do |build| %>
<entry>
<title><%= build.repository.slug %> Build #<%= build.number %></title>
@ -21,7 +21,7 @@ module Travis::Api::App::Responders
<updated><%= ::DateTime.parse(build.updated_at.to_s).rfc3339 %></updated>
<summary type="html">
&lt;p&gt;
<%= build.commit.message.encode(:xml => :text) %> (<%= build.commit.committer_name %>)
<%= build.commit.message.encode(:xml => :text) if build.commit.message %> (<%= build.commit.committer_name %>)
&lt;br/&gt;&lt;br/&gt;
State: <%= build.state %>
&lt;br/&gt;
@ -36,7 +36,7 @@ module Travis::Api::App::Responders
</author>
</entry>
<% end %>
</feed>
EOF

View File

@ -1,3 +1,5 @@
require 'travis/api/serialize'
class Travis::Api::App
module Responders
class Json < Base
@ -46,7 +48,7 @@ class Travis::Api::App
if defined?(@builder)
@builder
else
@builder = Travis::Api.builder(resource, { :version => version }.merge(options))
@builder = Travis::Api::Serialize.builder(resource, { :version => version }.merge(options))
end
end

View File

@ -8,7 +8,15 @@ class Travis::Api::App
register :schedule_request
def run
repo && active? ? schedule_request : not_found
if repo.nil?
not_found
elsif !active?
not_active
elsif throttle.throttled?
throttled
else
schedule_request
end
end
def messages
@ -29,6 +37,16 @@ class Travis::Api::App
:not_found
end
def not_active
messages << { error: "Repository #{slug} not active." }
:not_active
end
def throttled
messages << { error: "Repository #{slug} throttled." }
:throttled
end
def active?
Travis::Features.owner_active?(:request_create, repo.owner)
end
@ -40,13 +58,44 @@ class Travis::Api::App
end
def repo
@repo ||= Repository.by_slug(slug).first
instance_variable_defined?(:@repo) ? @repo : @repo = Repository.by_slug(slug).first
end
def slug
repo = params[:repository] || {}
repo.values_at(:owner_name, :name).join('/')
end
def throttle
@throttle ||= Throttle.new(slug)
end
class Throttle < Struct.new(:slug)
def throttled?
current_requests >= max_requests
end
def message
'API throttled'
end
private
def current_requests
@current_requests ||= begin
sql = "repository_id = ? AND event_type = ? AND result = ? AND created_at > ?"
Request.where(sql, repository.id, 'api', 'accepted', 1.hour.ago).count
end
end
def max_requests
Travis.config.max_api_requests || 10
end
def repository
@repository ||= Repository.by_slug(slug).first || raise(Travis::RepositoryNotFoundError.new(slug: slug))
end
end
end
end
end

115
lib/travis/api/attack.rb Normal file
View File

@ -0,0 +1,115 @@
require 'rack/attack'
require 'netaddr'
class Rack::Attack
class Request
TOKEN = 'travis.access_token'.freeze
def travis_token
env.fetch(TOKEN)
end
def authenticated?
env.include? TOKEN
end
def identifier
authenticated? ? travis_token.to_s : ip
end
end
def self.bantime(value)
case Travis.env
when "production" then value
when "staging" then 10 # ban for 10 seconds on staging
else 1
end
end
POST_SAFELIST = [
"/auth/handshake",
"/auth/post_message",
"/auth/post_message/iframe"
]
GITHUB_CIDR = NetAddr::CIDR.create('192.30.252.0/22')
safelist('safelist build status images') do |request|
/\.(png|svg)$/.match(request.path)
end
# https://help.github.com/articles/what-ip-addresses-does-github-use-that-i-should-safelist/
safelist('safelist anything coming from github') do |request|
request.ip && GITHUB_CIDR.contains?(request.ip)
end
####
# Whitelisted IP addresses
safelist('safelist client requesting from redis') do |request|
# TODO: deprecate :api_whitelisted_ips in favour of api_safelisted_ips
Travis.redis.sismember(:api_whitelisted_ips, request.ip) || Travis.redis.sismember(:api_safelisted_ips, request.ip)
end
####
# Ban based on: IP address
# Ban time: indefinite
# Ban after: manually banned
blocklist('block client requesting from redis') do |request|
# TODO: deprecate :api_blacklisted_ips in favour of api_blocklisted_ips
Travis.redis.sismember(:api_blacklisted_ips, request.ip) || Travis.redis.sismember(:api_blocklisted_ips, request.ip)
end
####
# Ban based on: IP address or access token
# Ban time: 5 hours
# Ban after: 10 POST requests within five minutes to /auth/github
blocklist('hammering /auth/github') do |request|
Rack::Attack::Allow2Ban.filter(request.identifier, maxretry: 2, findtime: 5.minutes, bantime: bantime(5.hours)) do
request.post? and request.path == '/auth/github'
end
end
####
# Ban based on: IP address or access token
# Ban time: 1 hour
# Ban after: 10 POST requests within 30 seconds
blocklist('spamming with POST requests') do |request|
Rack::Attack::Allow2Ban.filter(request.identifier, maxretry: 10, findtime: 30.seconds, bantime: bantime(1.hour)) do
request.post? and not POST_SAFELIST.include? request.path
end
end
###
# Throttle: unauthenticated requests to /auth/github - 1 per minute
# Scoped by: IP address
throttle('req/ip/1min', limit: 1, period: 1.minute) do |request|
request.ip unless request.authenticated? and request.path == '/auth/github'
end
###
# Throttle: unauthenticated requests - 500 per minute
# Scoped by: IP address
throttle('req/ip/1min', limit: 500, period: 1.minute) do |request|
request.ip unless request.authenticated?
end
###
# Throttle: authenticated requests - 2000 per minute
# Scoped by: access token
throttle('req/token/1min', limit: 2000, period: 1.minute) do |request|
request.identifier
end
if ENV["MEMCACHIER_SERVERS"]
cache.store = Dalli::Client.new(
ENV["MEMCACHIER_SERVERS"].split(","),
username: ENV["MEMCACHIER_USERNAME"],
password: ENV["MEMCACHIER_PASSWORD"],
failover: true,
socket_timeout: 1.5,
socket_failure_delay: 0.2)
else
cache.store = ActiveSupport::Cache::MemoryStore.new
end
end

View File

@ -0,0 +1,59 @@
module Travis
module Enqueue
module Services
class CancelModel
attr_reader :current_user, :target
def initialize(current_user, params)
@current_user = current_user
@params = params
target
end
def messages
messages = []
messages << { :notice => "The #{type} was successfully cancelled." } if can_cancel?
messages << { :error => "You are not authorized to cancel this #{type}." } unless authorized?
messages << { :error => "The #{type} could not be cancelled." } unless build.cancelable?
messages
end
def push(event, payload)
# target may have been retrieved with a :join query, so we need to reset the readonly status
if can_cancel?
::Sidekiq::Client.push(
'queue' => 'hub',
'class' => 'Travis::Hub::Sidekiq::Worker',
#'args' => ["#{type}:cancel", @params]
'args' => [event, payload]
)
end
end
def type
@type ||= @params[:build_id] ? :build : :job
end
def target
if type == :build
@target = Build.find(@params[:build_id])
else
@target = Job.find(@params[:job_id])
end
end
def can_cancel?
authorized? && target.cancelable?
end
# check on web
def authorized?
current_user.permission?(:pull, :repository_id => target.repository_id)
end
end
end
end
end

View File

@ -0,0 +1,64 @@
module Travis
module Enqueue
module Services
class RestartModel
attr_reader :current_user, :target
def initialize(current_user, params)
@current_user = current_user
@params = params
target
end
def push(event, payload)
if current_user && target && accept?
::Sidekiq::Client.push(
'queue' => 'hub',
'class' => 'Travis::Hub::Sidekiq::Worker',
'args' => [event, payload]
)
end
end
def accept?
current_user && permission? && resetable?
end
def messages
messages = []
messages << { notice: "The #{type} was successfully restarted." } if accept?
messages << { error: 'You do not seem to have sufficient permissions.' } unless permission?
messages << { error: "This #{type} currently can not be restarted." } unless resetable?
messages
end
def type
@type ||= @params[:build_id] ? :build : :job
end
def target
if type == :build
@target = Build.find(@params[:build_id])
else
@target = Job.find(@params[:job_id])
end
end
private
def permission?
current_user.permission?(required_role, repository_id: target.repository_id)
end
def resetable?
target.resetable?
end
def required_role
Travis.config.roles.reset_model
end
end
end
end
end

View File

@ -0,0 +1,68 @@
require 'travis/api/serialize/formats'
require 'travis/api/serialize/v0'
require 'travis/api/serialize/v1'
module Travis
module Api
module Serialize
DEFAULT_VERSION = 'v2'
class << self
def data(resource, options = {})
new(resource, options).data
end
def builder(resource, options = {})
target = (options[:for] || 'http').to_s.camelize
version = (options[:version] || default_version(options)).to_s.camelize
type = (options[:type] || type_for(resource)).to_s.camelize.split('::')
([version, target] + type).inject(self) do |const, name|
begin
if const && const.const_defined?(name.to_s.camelize, false)
const.const_get(name, false)
else
nil
end
rescue NameError
nil
end
end
end
def new(resource, options = {})
builder = builder(resource, options) || raise(ArgumentError, "cannot serialize #{resource.inspect}, options: #{options.inspect}")
builder.new(resource, options[:params] || {})
end
private
def type_for(resource)
if arel_relation?(resource)
type = resource.klass.name.pluralize
else
type = resource.class
type = type.base_class if active_record?(type)
type = type.name
end
type.split('::').last
end
def arel_relation?(object)
object.respond_to?(:klass)
end
def active_record?(object)
object.respond_to?(:base_class)
end
def default_version(options)
if options[:for].to_s.downcase == "pusher"
"v0"
else
DEFAULT_VERSION
end
end
end
end
end
end

View File

@ -0,0 +1,11 @@
module Travis
module Api
module Serialize
module Formats
def format_date(date)
date && date.strftime('%Y-%m-%dT%H:%M:%SZ')
end
end
end
end
end

View File

@ -0,0 +1,25 @@
require 'active_model_serializers'
module Travis
module Api
module Serialize
class ObjectSerializer < ActiveModel::Serializer
def data
as_json
end
end
class ArraySerializer < ActiveModel::ArraySerializer
def data
as_json
end
def initialize(resource, options)
options[:each_serializer] ||= V2::Http.const_get(options[:root].to_s.singularize.camelize)
super(resource, options)
end
end
end
end
end

View File

@ -0,0 +1,6 @@
# V0 is an internal api that we can change at any time
require 'travis/api/serialize/v0/event'
require 'travis/api/serialize/v0/notification'
require 'travis/api/serialize/v0/pusher'
require 'travis/api/serialize/v0/worker'

View File

@ -0,0 +1,2 @@
require 'travis/api/serialize/v0/event/build'
require 'travis/api/serialize/v0/event/job'

View File

@ -0,0 +1,96 @@
module Travis
module Api
module Serialize
module V0
module Event
class Build
include Formats
attr_reader :build, :repository, :request, :commit, :options
def initialize(build, options = {})
@build = build
@repository = build.repository
@request = build.request
@commit = build.commit
# @options = options
end
def data(extra = {})
{
'repository' => repository_data,
'request' => request_data,
'commit' => commit_data,
'build' => build_data,
'jobs' => build.matrix.map { |job| job_data(job) }
}
end
private
def build_data
{
'id' => build.id,
'repository_id' => build.repository_id,
'commit_id' => build.commit_id,
'number' => build.number,
'pull_request' => build.pull_request?,
'pull_request_number' => build.pull_request_number,
'config' => build.config.try(:except, :source_key),
'state' => build.state.to_s,
'previous_state' => build.previous_state.to_s,
'started_at' => format_date(build.started_at),
'finished_at' => format_date(build.finished_at),
'duration' => build.duration,
'job_ids' => build.matrix_ids
}
end
def repository_data
{
'id' => repository.id,
'key' => repository.key.try(:public_key),
'slug' => repository.slug,
'name' => repository.name,
'owner_email' => repository.owner_email,
'owner_avatar_url' => repository.owner.try(:avatar_url)
}
end
def request_data
{
'token' => request.token,
'head_commit' => (request.head_commit || '')
}
end
def commit_data
{
'id' => commit.id,
'sha' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'compare_url' => commit.compare_url,
}
end
def job_data(job)
{
'id' => job.id,
'number' => job.number,
'state' => job.state.to_s,
'tags' => job.tags
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,37 @@
module Travis
module Api
module Serialize
module V0
module Event
class Job
include Formats
attr_reader :job
def initialize(job, options = {})
@job = job
# @options = options
end
def data(extra = {})
{
'job' => job_data,
}
end
private
def job_data
{
'queue' => job.queue,
'created_at' => job.created_at,
'started_at' => job.started_at,
'finished_at' => job.finished_at,
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,3 @@
require 'travis/api/serialize/v0/notification/build'
require 'travis/api/serialize/v0/notification/repository'
require 'travis/api/serialize/v0/notification/user'

View File

@ -0,0 +1,29 @@
module Travis
module Api
module Serialize
module V0
module Notification
class Build
attr_reader :build
def initialize(build, options = {})
@build = build
end
def data
{
'build' => build_data
}
end
def build_data
{
'id' => build.id
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,30 @@
module Travis
module Api
module Serialize
module V0
module Notification
class Repository
attr_reader :repository
def initialize(repository, options = {})
@repository = repository
end
def data
{
'repository' => repository_data
}
end
def repository_data
{
'id' => repository.id,
'slug' => repository.slug
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,30 @@
module Travis
module Api
module Serialize
module V0
module Notification
class User
attr_reader :user
def initialize(user, options = {})
@user = user
end
def data
{
'user' => user_data
}
end
def user_data
{
'id' => user.id,
'login' => user.login
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,3 @@
require 'travis/api/serialize/v0/pusher/annotation'
require 'travis/api/serialize/v0/pusher/build'
require 'travis/api/serialize/v0/pusher/job'

View File

@ -0,0 +1,35 @@
require 'travis/api/serialize/v0/pusher/annotation/created'
require 'travis/api/serialize/v0/pusher/annotation/updated'
module Travis
module Api
module Serialize
module V0
module Pusher
class Annotation
include Formats
attr_reader :annotation
def initialize(annotation, options = {})
@annotation = annotation
end
def data
{
"annotation" => {
"id" => annotation.id,
"job_id" => annotation.job_id,
"description" => annotation.description,
"url" => annotation.url,
"status" => annotation.status,
"provider_name" => annotation.annotation_provider.name,
}
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Annotation
class Created < Annotation
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Annotation
class Updated < Annotation
end
end
end
end
end
end
end

View File

@ -0,0 +1,112 @@
require 'travis/api/serialize/v0/pusher/build/canceled'
require 'travis/api/serialize/v0/pusher/build/created'
require 'travis/api/serialize/v0/pusher/build/received'
require 'travis/api/serialize/v0/pusher/build/started'
require 'travis/api/serialize/v0/pusher/build/finished'
module Travis
module Api
module Serialize
module V0
module Pusher
class Build
include Formats
attr_reader :build, :options
def initialize(build, options = {})
@build = build
@options = options
end
def data
{
'build' => build_data(build),
'commit' => commit_data(build.commit),
'repository' => repository_data(build.repository)
}
end
private
def build_data(build)
commit = build.commit
{
'id' => build.id,
'repository_id' => build.repository_id,
'commit_id' => build.commit_id,
'number' => build.number,
'pull_request' => build.pull_request?,
'pull_request_title' => build.pull_request_title,
'pull_request_number' => build.pull_request_number,
'state' => build.state.to_s,
'started_at' => format_date(build.started_at),
'finished_at' => format_date(build.finished_at),
'duration' => build.duration,
'job_ids' => build.matrix_ids,
'event_type' => build.event_type,
# this is a legacy thing, we should think about removing it
'commit' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'compare_url' => commit.compare_url,
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email
}
end
def commit_data(commit)
{
'id' => commit.id,
'sha' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'compare_url' => commit.compare_url,
}
end
def repository_data(repository)
{
'id' => repository.id,
'slug' => repository.slug,
'description' => repository.description,
'private' => repository.private,
'last_build_id' => repository.last_build_id,
'last_build_number' => repository.last_build_number,
'last_build_state' => repository.last_build_state.to_s,
'last_build_duration' => repository.last_build_duration,
'last_build_language' => nil,
'last_build_started_at' => format_date(repository.last_build_started_at),
'last_build_finished_at' => format_date(repository.last_build_finished_at),
'github_language' => repository.github_language,
'default_branch' => {
'name' => repository.default_branch,
'last_build_id' => last_build_on_default_branch_id(repository)
},
'active' => repository.active,
'current_build_id' => repository.current_build_id
}
end
def last_build_on_default_branch_id(repository)
default_branch = Branch.where(repository_id: repository.id, name: repository.default_branch).first
if default_branch
default_branch.last_build_id
end
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Build
class Canceled < Build
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Build
class Created < Build
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Build
class Finished < Build
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Build
class Received < Build
end
end
end
end
end
end
end

View File

@ -0,0 +1,49 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Build
class Received < Build
class Job
include Formats, V1::Helpers::Legacy
attr_reader :job, :commit
def initialize(job)
@job = job
@commit = job.commit
end
def data
{
'id' => job.id,
'repository_id' => job.repository_id,
'repository_private' => repository.private,
'parent_id' => job.source_id,
'number' => job.number,
'state' => job.state.to_s,
'result' => legacy_job_result(job),
'config' => job.obfuscated_config,
'commit' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'compare_url' => commit.compare_url,
'started_at' => format_date(job.started_at),
'finished_at' => format_date(job.finished_at),
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'allow_failure' => job.allow_failure
}
end
end
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Build
class Started < Build
end
end
end
end
end
end
end

View File

@ -0,0 +1,49 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Build
class Started < Build
class Job
include Formats, V1::Helpers::Legacy
attr_reader :job, :commit
def initialize(job)
@job = job
@commit = job.commit
end
def data
{
'id' => job.id,
'repository_id' => job.repository_id,
'repository_private' => repository.private,
'parent_id' => job.source_id,
'number' => job.number,
'state' => job.state.to_s,
'result' => legacy_job_result(job),
'config' => job.obfuscated_config,
'commit' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'compare_url' => commit.compare_url,
'started_at' => format_date(job.started_at),
'finished_at' => format_date(job.finished_at),
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'allow_failure' => job.allow_failure
}
end
end
end
end
end
end
end
end
end

View File

@ -0,0 +1,69 @@
require 'travis/api/serialize/v0/pusher/job/canceled'
require 'travis/api/serialize/v0/pusher/job/created'
require 'travis/api/serialize/v0/pusher/job/log'
require 'travis/api/serialize/v0/pusher/job/received'
require 'travis/api/serialize/v0/pusher/job/started'
require 'travis/api/serialize/v0/pusher/job/finished'
module Travis
module Api
module Serialize
module V0
module Pusher
class Job
include Formats
attr_reader :job, :options
def initialize(job, options = {})
@job = job
@options = options
end
def data
job_data(job).merge(
'commit' => commit_data(job.commit)
)
end
private
def job_data(job)
{
'id' => job.id,
'repository_id' => job.repository_id,
'repository_slug' => job.repository.slug,
'repository_private' => job.repository.private,
'build_id' => job.source_id,
'commit_id' => job.commit_id,
'log_id' => job.log_id,
'number' => job.number,
'state' => job.state.to_s,
'started_at' => format_date(job.started_at),
'finished_at' => format_date(job.finished_at),
'queue' => job.queue,
'allow_failure' => job.allow_failure,
'annotation_ids' => job.annotation_ids
}
end
def commit_data(commit)
{
'id' => commit.id,
'sha' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'compare_url' => commit.compare_url,
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Job
class Canceled < Job
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Job
class Created < Job
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Job
class Finished < Job
end
end
end
end
end
end
end

View File

@ -0,0 +1,32 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Job
class Log
attr_reader :job, :options
def initialize(job, options = {})
@job = job
@options = options
end
def data
{
'id' => job.id,
'build_id' => job.source_id,
'repository_id' => job.repository_id,
'repository_private' => repository.private,
'_log' => options[:_log],
'number' => options[:number],
'final' => options[:final]
}
end
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Job
class Received < Job
end
end
end
end
end
end
end

View File

@ -0,0 +1,14 @@
module Travis
module Api
module Serialize
module V0
module Pusher
class Job
class Started < Job
end
end
end
end
end
end
end

View File

@ -0,0 +1 @@
require 'travis/api/serialize/v0/worker/job'

View File

@ -0,0 +1,35 @@
require 'travis/api/serialize/v0/worker/job/test'
module Travis
module Api
module Serialize
module V0
module Worker
class Job
attr_reader :job
def initialize(job, options = {})
@job = job
end
def commit
job.commit
end
def repository
job.repository
end
def request
build.request
end
def build
job.source
end
end
end
end
end
end
end

View File

@ -0,0 +1,120 @@
module Travis
module Api
module Serialize
module V0
module Worker
class Job
class Test < Job
include Formats
def data
{
'type' => 'test',
# TODO legacy. remove this once workers respond to a 'job' key
'build' => job_data,
'job' => job_data,
'source' => build_data,
'repository' => repository_data,
'pull_request' => commit.pull_request? ? pull_request_data : false,
'config' => job.decrypted_config,
'queue' => job.queue,
'uuid' => Travis.uuid,
'ssh_key' => ssh_key,
'env_vars' => env_vars,
'timeouts' => timeouts
}
end
def build_data
{
'id' => build.id,
'number' => build.number
}
end
def job_data
data = {
'id' => job.id,
'number' => job.number,
'commit' => commit.commit,
'commit_range' => commit.range,
'commit_message' => commit.message,
'branch' => commit.branch,
'ref' => commit.pull_request? ? commit.ref : nil,
'state' => job.state.to_s,
'secure_env_enabled' => job.secure_env_enabled?
}
data['tag'] = request.tag_name if include_tag_name?
data['pull_request'] = commit.pull_request? ? commit.pull_request_number : false
data
end
def repository_data
{
'id' => repository.id,
'slug' => repository.slug,
'github_id' => repository.github_id,
'source_url' => repository.source_url,
'api_url' => repository.api_url,
'last_build_id' => repository.last_build_id,
'last_build_number' => repository.last_build_number,
'last_build_started_at' => format_date(repository.last_build_started_at),
'last_build_finished_at' => format_date(repository.last_build_finished_at),
'last_build_duration' => repository.last_build_duration,
'last_build_state' => repository.last_build_state.to_s,
'description' => repository.description,
'default_branch' => repository.default_branch
}
end
def pull_request_data
{
'number' => commit.pull_request_number,
'head_repo' => request.head_repo,
'base_repo' => request.base_repo,
'head_branch' => request.head_branch,
'base_branch' => request.base_branch
}
end
def ssh_key
nil
end
def env_vars
vars = settings.env_vars
vars = vars.public unless job.secure_env_enabled?
vars.map do |var|
{
'name' => var.name,
'value' => var.value.decrypt,
'public' => var.public
}
end
end
def timeouts
{ 'hard_limit' => timeout(:hard_limit), 'log_silence' => timeout(:log_silence) }
end
def timeout(type)
timeout = settings.send(:"timeout_#{type}")
timeout = timeout * 60 if timeout # worker handles timeouts in seconds
timeout
end
def include_tag_name?
Travis.config.include_tag_name_in_worker_payload && request.tag_name.present?
end
def settings
repository.settings
end
end
end
end
end
end
end
end

View File

@ -0,0 +1,4 @@
require 'travis/api/serialize/v1/archive'
require 'travis/api/serialize/v1/http'
require 'travis/api/serialize/v1/helpers'
require 'travis/api/serialize/v1/webhook'

View File

@ -0,0 +1 @@
require 'travis/api/serialize/v1/archive/build'

View File

@ -0,0 +1,52 @@
require 'travis/api/serialize/v1/archive/build/job'
module Travis
module Api
module Serialize
module V1
module Archive
class Build
include Formats
attr_reader :build, :commit, :repository
def initialize(build, options = {})
@build = build
@commit = build.commit
@repository = build.repository
end
def data
{
'id' => build.id,
'number' => build.number,
'config' => build.obfuscated_config.stringify_keys,
'result' => 0,
'started_at' => format_date(build.started_at),
'finished_at' => format_date(build.finished_at),
'duration' => build.duration,
'commit' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'matrix' => build.matrix.map { |job| Job.new(job).data },
'repository' => repository_data
}
end
def repository_data
{
'id' => repository.id,
'slug' => repository.slug
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,33 @@
module Travis
module Api
module Serialize
module V1
module Archive
class Build
class Job
include Formats
attr_reader :job, :commit
def initialize(job)
@job = job
@commit = job.commit
end
def data
{
'id' => job.id,
'number' => job.number,
'config' => job.obfuscated_config,
'started_at' => format_date(job.started_at),
'finished_at' => format_date(job.finished_at),
'log' => job.log_content
}
end
end
end
end
end
end
end
end

View File

@ -0,0 +1 @@
require 'travis/api/serialize/v1/helpers/legacy'

View File

@ -0,0 +1,36 @@
module Travis
module Api
module Serialize
module V1
module Helpers
module Legacy
RESULTS = {
passed: 0,
failed: 1
}
def legacy_repository_last_build_result(repository)
RESULTS[repository.last_build_state.try(:to_sym)]
end
def legacy_build_state(build)
build.finished? ? 'finished' : build.state.to_s
end
def legacy_build_result(build)
RESULTS[build.state.try(:to_sym)]
end
def legacy_job_state(job)
job.finished? ? 'finished' : job.state.to_s
end
def legacy_job_result(job)
RESULTS[job.state.try(:to_sym)]
end
end
end
end
end
end
end

View File

@ -0,0 +1,9 @@
require 'travis/api/serialize/v1/http/branches'
require 'travis/api/serialize/v1/http/build'
require 'travis/api/serialize/v1/http/builds'
require 'travis/api/serialize/v1/http/hooks'
require 'travis/api/serialize/v1/http/job'
require 'travis/api/serialize/v1/http/jobs'
require 'travis/api/serialize/v1/http/repositories'
require 'travis/api/serialize/v1/http/repository'
require 'travis/api/serialize/v1/http/user'

View File

@ -0,0 +1,45 @@
require 'travis/api/serialize/v1/helpers/legacy'
module Travis
module Api
module Serialize
module V1
module Http
class Branches
include Formats, Helpers::Legacy
attr_reader :builds, :options
def initialize(builds, options = {})
builds = builds.last_finished_builds_by_branches if builds.is_a?(Repository) # TODO remove, bc
@builds = builds
end
def cache_key
"branches-#{builds.map(&:id).join('-')}"
end
def updated_at
builds.compact.map(&:finished_at).compact.sort.first
end
def data
builds.compact.map do |build|
{
'repository_id' => build.repository_id,
'build_id' => build.id,
'commit' => build.commit.commit,
'branch' => build.commit.branch,
'message' => build.commit.message,
'result' => legacy_build_result(build),
'finished_at' => format_date(build.finished_at),
'started_at' => format_date(build.started_at)
}
end
end
end
end
end
end
end
end

View File

@ -0,0 +1,49 @@
require 'travis/api/serialize/v1/http/build/job'
module Travis
module Api
module Serialize
module V1
module Http
class Build
include Formats, Helpers::Legacy
attr_reader :build, :commit, :request
def initialize(build, options = {})
@build = build
@commit = build.commit
@request = build.request
end
def data
{
'id' => build.id,
'repository_id' => build.repository_id,
'number' => build.number,
'config' => build.obfuscated_config.stringify_keys,
'state' => legacy_build_state(build),
'result' => legacy_build_result(build),
'status' => legacy_build_result(build),
'started_at' => format_date(build.started_at),
'finished_at' => format_date(build.finished_at),
'duration' => build.duration,
'commit' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'compare_url' => commit.compare_url,
'event_type' => build.event_type,
'matrix' => build.matrix.map { |job| Job.new(job).data },
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,34 @@
module Travis
module Api
module Serialize
module V1
module Http
class Build
class Job
include Formats, Helpers::Legacy
attr_reader :job
def initialize(job)
@job = job
end
def data
{
'id' => job.id,
'repository_id' => job.repository_id,
'number' => job.number,
'config' => job.obfuscated_config.stringify_keys,
'result' => legacy_job_result(job),
'started_at' => format_date(job.started_at),
'finished_at' => format_date(job.finished_at),
'allow_failure' => job.allow_failure
}
end
end
end
end
end
end
end
end

View File

@ -0,0 +1,40 @@
module Travis
module Api
module Serialize
module V1
module Http
class Builds
include Formats, Helpers::Legacy
attr_reader :builds
def initialize(builds, options = {})
@builds = builds
end
def data
builds.map { |build| build_data(build) }
end
def build_data(build)
{
'id' => build.id,
'repository_id' => build.repository_id,
'number' => build.number,
'state' => legacy_build_state(build),
'result' => legacy_build_result(build),
'started_at' => format_date(build.started_at),
'finished_at' => format_date(build.finished_at),
'duration' => build.duration,
'commit' => build.commit.commit,
'branch' => build.commit.branch,
'message' => build.commit.message,
'event_type' => build.event_type,
}
end
end
end
end
end
end
end

View File

@ -0,0 +1,36 @@
module Travis
module Api
module Serialize
module V1
module Http
class Hooks
attr_reader :repos, :options
def initialize(repos, options = {})
@repos = repos
@options = options
end
def data
repos.map { |repo| repo_data(repo) }
end
private
def repo_data(repo)
{
'uid' => [repo.owner_name, repo.name].join(':'),
'url' => "https://github.com/#{repo.owner_name}/#{repo.name}",
'name' => repo.name,
'owner_name' => repo.owner_name,
'description' => repo.description,
'active' => repo.active,
'private' => repo.private
}
end
end
end
end
end
end
end

View File

@ -1,49 +1,32 @@
module Travis
module Api
module V2
module Http
class Jobs
include Formats
module Serialize
module V1
module Http
class Job
include Formats, Helpers::Legacy
attr_reader :jobs, :options
attr_reader :job, :commit
def initialize(jobs, options = {})
@jobs = jobs
@options = options
end
def data
{
'jobs' => jobs.map { |job| job_data(job) },
'commits' => jobs.map { |job| commit_data(job.commit) }
}
end
private
def job_data(job)
{
'id' => job.id,
'repository_id' => job.repository_id,
'repository_slug' => job.repository.slug,
'build_id' => job.source_id,
'commit_id' => job.commit_id,
'log_id' => job.log_id,
'number' => job.number,
'config' => job.obfuscated_config.stringify_keys,
'state' => job.state.to_s,
'started_at' => format_date(job.started_at),
'finished_at' => format_date(job.finished_at),
'queue' => job.queue,
'allow_failure' => job.allow_failure,
'tags' => job.tags
}
def initialize(job, options = {})
@job = job
@commit = job.commit
end
def commit_data(commit)
def data
{
'id' => commit.id,
'sha' => commit.commit,
'id' => job.id,
'number' => job.number,
'config' => job.obfuscated_config.stringify_keys,
'repository_id' => job.repository_id,
'build_id' => job.source_id,
'state' => job.finished? ? 'finished' : job.state.to_s,
'result' => legacy_job_result(job),
'status' => legacy_job_result(job),
'started_at' => format_date(job.started_at),
'finished_at' => format_date(job.finished_at),
'log' => job.log_content,
'commit' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'committed_at' => format_date(commit.committed_at),
@ -52,8 +35,10 @@ module Travis
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'compare_url' => commit.compare_url,
'worker' => job.worker
}
end
end
end
end
end

View File

@ -0,0 +1,36 @@
module Travis
module Api
module Serialize
module V1
module Http
class Jobs
include Formats, Helpers::Legacy
attr_reader :jobs
def initialize(jobs, options = {})
@jobs = jobs
end
def data
jobs.map { |job| job_data(job) }
end
def job_data(job)
commit = job.commit
{
'id' => job.id,
'repository_id' => job.repository_id,
'number' => job.number,
'state' => legacy_job_state(job),
'queue' => job.queue,
'allow_failure' => job.allow_failure
}
end
end
end
end
end
end
end

View File

@ -1,25 +1,21 @@
module Travis
module Api
module V2
module Http
class Repository
include Formats
module Serialize
module V1
module Http
class Repositories
include Formats, Helpers::Legacy
attr_reader :repository, :options
attr_reader :repositories
def initialize(repository, options = {})
@repository = repository
end
def initialize(repositories, options = {})
@repositories = repositories
end
def data
{
'repo' => repository_data(repository)
}
end
def data
repositories.map { |repository| repository_data(repository) }
end
private
# TODO why does this not include the last build? (i.e. 'builds' => { last build here })
def repository_data(repository)
{
'id' => repository.id,
@ -27,17 +23,17 @@ module Travis
'description' => repository.description,
'last_build_id' => repository.last_build_id,
'last_build_number' => repository.last_build_number,
'last_build_state' => repository.last_build_state.to_s,
'last_build_status' => legacy_repository_last_build_result(repository),
'last_build_result' => legacy_repository_last_build_result(repository),
'last_build_duration' => repository.last_build_duration,
'last_build_language' => nil,
'last_build_started_at' => format_date(repository.last_build_started_at),
'last_build_finished_at' => format_date(repository.last_build_finished_at),
'github_language' => repository.github_language
}
end
end
end
end
end
end
end

View File

@ -1,41 +1,34 @@
module Travis
module Api
module V2
module Http
class Repositories
include Formats
module Serialize
module V1
module Http
class Repository
include Formats, Helpers::Legacy
attr_reader :repositories, :options
attr_reader :repository, :options
def initialize(repositories, options = {})
@repositories = repositories
@options = options
end
def initialize(repository, options = {})
@repository = repository
end
def data
{
'repos' => repositories.map { |repository| repository_data(repository) }
}
end
private
def repository_data(repository)
def data
{
'id' => repository.id,
'slug' => repository.slug,
'description' => repository.description,
'public_key' => repository.key.public_key,
'last_build_id' => repository.last_build_id,
'last_build_number' => repository.last_build_number,
'last_build_state' => repository.last_build_state.to_s,
'last_build_status' => legacy_repository_last_build_result(repository),
'last_build_result' => legacy_repository_last_build_result(repository),
'last_build_duration' => repository.last_build_duration,
'last_build_language' => nil,
'last_build_started_at' => format_date(repository.last_build_started_at),
'last_build_finished_at' => format_date(repository.last_build_finished_at),
'active' => repository.active,
'github_language' => repository.github_language
}
end
end
end
end
end

View File

@ -0,0 +1,33 @@
module Travis
module Api
module Serialize
module V1
module Http
class User
include Formats
attr_reader :user, :options
def initialize(user, options = {})
@user = user
@options = options
end
def data
{
'login' => user.login,
'name' => user.name,
'email' => user.email,
'gravatar_id' => user.gravatar_id,
'locale' => user.locale,
'is_syncing' => user.is_syncing,
'synced_at' => format_date(user.synced_at)
}
end
end
end
end
end
end
end

View File

@ -0,0 +1 @@
require 'travis/api/serialize/v1/webhook/build'

View File

@ -0,0 +1,29 @@
require 'travis/api/serialize/v1/webhook/build/finished'
module Travis
module Api
module Serialize
module V1
module Webhook
class Build
attr_reader :build, :commit, :request, :repository, :options
def initialize(build, options = {})
@build = build
@commit = build.commit
@request = build.request
@repository = build.repository
@options = options
end
private
def build_url
["https://#{Travis.config.host}", repository.slug, 'builds', build.id].join('/')
end
end
end
end
end
end
end

View File

@ -0,0 +1,72 @@
require 'travis/api/serialize/v1/webhook/build/finished/job'
module Travis
module Api
module Serialize
module V1
module Webhook
class Build
class Finished < Build
include Formats
def data
data = {
'id' => build.id,
'repository' => repository_data,
'number' => build.number,
'config' => build.obfuscated_config.stringify_keys,
'status' => build.result,
'result' => build.result,
'status_message' => result_message,
'result_message' => result_message,
'started_at' => format_date(build.started_at),
'finished_at' => format_date(build.finished_at),
'duration' => build.duration,
'build_url' => build_url,
'commit_id' => commit.id,
'commit' => commit.commit,
'base_commit' => request.base_commit,
'head_commit' => request.head_commit,
'branch' => commit.branch,
'message' => commit.message,
'compare_url' => commit.compare_url,
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'matrix' => build.matrix.map { |job| Job.new(job, options).data },
'type' => build.event_type,
'state' => build.state.to_s,
'pull_request' => build.pull_request?,
'pull_request_number' => build.pull_request_number,
'pull_request_title' => build.pull_request_title,
'tag' => request.tag_name
}
if commit.pull_request?
data['pull_request_number'] = commit.pull_request_number
end
data
end
def repository_data
{
'id' => repository.id,
'name' => repository.name,
'owner_name' => repository.owner_name,
'url' => repository.url
}
end
def result_message
@result_message ||= ::Build::ResultMessage.new(build).short
end
end
end
end
end
end
end
end

View File

@ -0,0 +1,52 @@
module Travis
module Api
module Serialize
module V1
module Webhook
class Build
class Finished < Build
class Job
include Formats
attr_reader :job, :commit, :options
def initialize(job, options = {})
@job = job
@commit = job.commit
@options = options
end
def data
data = {
'id' => job.id,
'repository_id' => job.repository_id,
'parent_id' => job.source_id,
'number' => job.number,
'state' => job.finished? ? 'finished' : job.state.to_s,
'config' => job.obfuscated_config,
'status' => job.result,
'result' => job.result,
'commit' => commit.commit,
'branch' => commit.branch,
'message' => commit.message,
'compare_url' => commit.compare_url,
'committed_at' => format_date(commit.committed_at),
'author_name' => commit.author_name,
'author_email' => commit.author_email,
'committer_name' => commit.committer_name,
'committer_email' => commit.committer_email,
'allow_failure' => job.allow_failure
}
data['log'] = job.log_content || '' if options[:include_logs]
data['started_at'] = format_date(job.started_at) if job.started?
data['finished_at'] = format_date(job.finished_at) if job.finished?
data
end
end
end
end
end
end
end
end
end

View File

@ -0,0 +1 @@
require 'travis/api/serialize/v2/http'

View File

@ -0,0 +1,24 @@
require 'travis/api/serialize/serializer'
require 'travis/api/serialize/v2/http/accounts'
require 'travis/api/serialize/v2/http/annotations'
require 'travis/api/serialize/v2/http/broadcasts'
require 'travis/api/serialize/v2/http/branch'
require 'travis/api/serialize/v2/http/branches'
require 'travis/api/serialize/v2/http/build'
require 'travis/api/serialize/v2/http/builds'
require 'travis/api/serialize/v2/http/caches'
require 'travis/api/serialize/v2/http/hooks'
require 'travis/api/serialize/v2/http/job'
require 'travis/api/serialize/v2/http/jobs'
require 'travis/api/serialize/v2/http/log'
require 'travis/api/serialize/v2/http/permissions'
require 'travis/api/serialize/v2/http/repositories'
require 'travis/api/serialize/v2/http/repository'
require 'travis/api/serialize/v2/http/requests'
require 'travis/api/serialize/v2/http/request'
require 'travis/api/serialize/v2/http/ssl_key'
require 'travis/api/serialize/v2/http/env_var'
require 'travis/api/serialize/v2/http/env_vars'
require 'travis/api/serialize/v2/http/user'
require 'travis/api/serialize/v2/http/validation_error'
require 'travis/api/serialize/v2/http/ssh_key'

View File

@ -0,0 +1,44 @@
require 'travis/api/serialize/formats'
module Travis
module Api
module Serialize
module V2
module Http
class Accounts
include Formats
attr_reader :accounts, :options
def initialize(accounts, options = {})
@accounts = accounts
@options = options
end
def data
{
:accounts => accounts.map { |account| account_data(account) }
}
end
private
def account_data(account)
data = {
'id' => account.id,
'name' => account.name,
'login' => account.login,
'type' => account.type.underscore,
'repos_count' => account.repos_count
}
data['avatar_url'] = account.avatar_url if account.respond_to?(:avatar_url)
data
end
end
end
end
end
end
end

Some files were not shown because too many files have changed in this diff Show More