-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support proper trunk flow #675
base: main
Are you sure you want to change the base?
Changes from 3 commits
222b06a
1911da9
5547d12
be7c299
a45cfbd
a319717
550d90d
bced35a
dd02ab7
feda268
149e51e
cf3530d
5640974
e57058e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateVersionTagJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(commit_hash, version, working_branch, vcs_provider) | ||
Triggers::Trunk.call(commit_hash, version, working_branch, vcs_provider) | ||
rescue Installations::Github::Error => e | ||
Rails.logger.error("Failed to create version tag: #{e.message}") | ||
raise | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module ReleasePlatformRuns | ||
class TriggerWorkflowJob < ApplicationJob | ||
queue_as :high | ||
|
||
def perform(platform_run_id, commit_id) | ||
platform_run = ReleasePlatformRun.find(platform_run_id) | ||
commit = Commit.find(commit_id) | ||
Coordinators::CreateBetaRelease.trigger_workflows(platform_run, commit) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Webhooks::CommitJob < ApplicationJob | ||
queue_as :high | ||
|
||
def perform(train_run_id, head_commit, rest_commits) | ||
release = Release.find(train_run_id) | ||
return unless release.committable? | ||
Signal.commit_has_landed!(release, head_commit) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
class Coordinators::CreateBetaRelease | ||
def self.call(release_platform_run, commit) | ||
new(release_platform_run, commit).call | ||
|
||
if release_platform_run.release.release_platform_runs.all? { |run| run.beta_releases.exists?(commit: commit) } && | ||
release_platform_run.train.trunk? | ||
|
||
tag_name = "v#{release_platform_run.release_version}" | ||
release_platform_run.train.create_tag!(tag_name, commit.commit_hash) | ||
|
||
release_platform_run.release.release_platform_runs.each do |run| | ||
run.update!(tag_name: tag_name) | ||
ReleasePlatformRuns::TriggerWorkflowJob.perform_later(run.id, commit.id) | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: the same issue applies here, as internal releases, but I'm also not certain what the need of triggering workflow job is here? The workflow run is normally triggered here anyway. Could you help me understand the reasoning behind this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The wrong approach was used when this was implemented. This has now been changed and it no longer handles the logic for creating and updating tags |
||
end | ||
|
||
def initialize(release_platform_run, commit) | ||
|
@@ -18,12 +30,30 @@ def call | |
release_platform_run.update_last_commit!(commit) | ||
release_platform_run.bump_version! | ||
release_platform_run.correct_version! | ||
|
||
beta_release = release_platform_run.beta_releases.create!(config:, previous:, commit:) | ||
WorkflowRun.create_and_trigger!(rc_workflow_config, beta_release, commit, release_platform_run) | ||
|
||
unless release_platform_run.train.trunk? | ||
WorkflowRun.create_and_trigger!(rc_workflow_config, beta_release, commit, release_platform_run) | ||
end | ||
|
||
beta_release.previous&.workflow_run&.cancel_workflow! | ||
end | ||
end | ||
|
||
def self.trigger_workflows(release_platform_run, commit) | ||
return if release_platform_run.tag_name.blank? | ||
return unless release_platform_run.train.trunk? | ||
|
||
beta_release = release_platform_run.beta_releases.find_by(commit: commit) | ||
WorkflowRun.create_and_trigger!( | ||
release_platform_run.conf.release_candidate_workflow, | ||
beta_release, | ||
commit, | ||
release_platform_run | ||
) | ||
end | ||
|
||
private | ||
|
||
def previous | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
class Coordinators::CreateInternalRelease | ||
def self.call(release_platform_run, commit) | ||
new(release_platform_run, commit).call | ||
|
||
if release_platform_run.release.release_platform_runs.all? { |run| run.internal_releases.exists?(commit: commit) } && | ||
release_platform_run.train.trunk? | ||
|
||
tag_name = "v#{release_platform_run.release_version}" | ||
release_platform_run.train.create_tag!(tag_name, commit.commit_hash) | ||
|
||
release_platform_run.release.release_platform_runs.each do |run| | ||
run.update!(tag_name: tag_name) | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: I think this creation & updating of tag should happen during the application of the commit, not here. This is about creating internal releases and its details. The tagging is about the commit, not about the builds. |
||
end | ||
|
||
def initialize(release_platform_run, commit) | ||
|
@@ -21,6 +32,19 @@ def call | |
end | ||
end | ||
|
||
def self.trigger_workflows(release_platform_run, commit) | ||
return if release_platform_run.tag_name.blank? | ||
return unless release_platform_run.train.trunk? | ||
|
||
internal_release = release_platform_run.internal_releases.find_by(commit: commit) | ||
WorkflowRun.create_and_trigger!( | ||
release_platform_run.conf.pick_internal_workflow, | ||
internal_release, | ||
commit, | ||
release_platform_run | ||
) | ||
end | ||
|
||
private | ||
|
||
def previous | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: this is entirely dead code.