Removes the unused travis-core v0 code
This commit is contained in:
parent
feb4bcd90f
commit
341adbae21
1
vendor/travis-core/lib/travis/api.rb
vendored
1
vendor/travis-core/lib/travis/api.rb
vendored
|
@ -1,7 +1,6 @@
|
||||||
module Travis
|
module Travis
|
||||||
module Api
|
module Api
|
||||||
require 'travis/api/formats'
|
require 'travis/api/formats'
|
||||||
require 'travis/api/v0'
|
|
||||||
require 'travis/api/v1'
|
require 'travis/api/v1'
|
||||||
require 'travis/api/v2'
|
require 'travis/api/v2'
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
This directory contains serializers for events and models.
|
This directory contains serializers for events and models.
|
||||||
|
|
||||||
- `v0/event`: Payloads used by [`Travis::Event::Handler`](../event/handler.rb). These are the payloads that the [addons](../addons) will get.
|
|
||||||
- `v0/pusher`: Payloads used to send events to the web UI using Pusher.
|
|
||||||
- `v0/worker`: Payloads sent to [travis-worker](https://github.com/travis-ci/travis-worker).
|
|
||||||
|
|
||||||
- `v1/http`: Payloads for the v1 [API](https://github.com/travis-ci/travis-api).
|
- `v1/http`: Payloads for the v1 [API](https://github.com/travis-ci/travis-api).
|
||||||
- `v1/webhook`: Payloads for the webhook notifications.
|
- `v1/webhook`: Payloads for the webhook notifications.
|
||||||
|
|
||||||
|
|
11
vendor/travis-core/lib/travis/api/v0.rb
vendored
11
vendor/travis-core/lib/travis/api/v0.rb
vendored
|
@ -1,11 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
# V0 is an internal api that we can change at any time
|
|
||||||
module V0
|
|
||||||
require 'travis/api/v0/event'
|
|
||||||
require 'travis/api/v0/notification'
|
|
||||||
require 'travis/api/v0/pusher'
|
|
||||||
require 'travis/api/v0/worker'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
12
vendor/travis-core/lib/travis/api/v0/event.rb
vendored
12
vendor/travis-core/lib/travis/api/v0/event.rb
vendored
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Event
|
|
||||||
require 'travis/api/v0/event/build'
|
|
||||||
require 'travis/api/v0/event/job'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Notification
|
|
||||||
require 'travis/api/v0/notification/build'
|
|
||||||
require 'travis/api/v0/notification/repository'
|
|
||||||
require 'travis/api/v0/notification/user'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
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
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
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
|
|
|
@ -1,28 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
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
|
|
11
vendor/travis-core/lib/travis/api/v0/pusher.rb
vendored
11
vendor/travis-core/lib/travis/api/v0/pusher.rb
vendored
|
@ -1,11 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
require 'travis/api/v0/pusher/annotation'
|
|
||||||
require 'travis/api/v0/pusher/build'
|
|
||||||
require 'travis/api/v0/pusher/job'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,33 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Annotation
|
|
||||||
require 'travis/api/v0/pusher/annotation/created'
|
|
||||||
require 'travis/api/v0/pusher/annotation/updated'
|
|
||||||
|
|
||||||
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
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Annotation
|
|
||||||
class Created < Annotation
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Annotation
|
|
||||||
class Updated < Annotation
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
111
vendor/travis-core/lib/travis/api/v0/pusher/build.rb
vendored
111
vendor/travis-core/lib/travis/api/v0/pusher/build.rb
vendored
|
@ -1,111 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Build
|
|
||||||
require 'travis/api/v0/pusher/build/canceled'
|
|
||||||
require 'travis/api/v0/pusher/build/created'
|
|
||||||
require 'travis/api/v0/pusher/build/received'
|
|
||||||
require 'travis/api/v0/pusher/build/started'
|
|
||||||
require 'travis/api/v0/pusher/build/finished'
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Build
|
|
||||||
class Canceled < Build
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
require 'travis/api/v1'
|
|
||||||
|
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Build
|
|
||||||
class Created < Build
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Build
|
|
||||||
class Finished < Build
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Build
|
|
||||||
class Received < Build
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,47 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
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
|
|
|
@ -1,13 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Build
|
|
||||||
class Started < Build
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
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
|
|
|
@ -1,67 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Job
|
|
||||||
require 'travis/api/v0/pusher/job/canceled'
|
|
||||||
require 'travis/api/v0/pusher/job/created'
|
|
||||||
require 'travis/api/v0/pusher/job/log'
|
|
||||||
require 'travis/api/v0/pusher/job/received'
|
|
||||||
require 'travis/api/v0/pusher/job/started'
|
|
||||||
require 'travis/api/v0/pusher/job/finished'
|
|
||||||
|
|
||||||
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
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Job
|
|
||||||
class Canceled < Job
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Job
|
|
||||||
class Created < Job
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Job
|
|
||||||
class Finished < Job
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,31 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
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
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Job
|
|
||||||
class Received < Job
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Pusher
|
|
||||||
class Job
|
|
||||||
class Started < Job
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,9 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Worker
|
|
||||||
require 'travis/api/v0/worker/job'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,33 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
module V0
|
|
||||||
module Worker
|
|
||||||
class Job
|
|
||||||
require 'travis/api/v0/worker/job/test'
|
|
||||||
|
|
||||||
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
|
|
|
@ -1,118 +0,0 @@
|
||||||
module Travis
|
|
||||||
module Api
|
|
||||||
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
|
|
Loading…
Reference in New Issue
Block a user