From 4dd920313cda73fef09ae7f5129c687e42513d20 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 23 Jan 2025 11:50:54 +0800 Subject: [PATCH 01/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E8=BF=90=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/pm/action_runs_controller.rb | 48 +++++++++++++++++++ .../v1/projects/actions/actions_controller.rb | 4 +- config/routes/api.rb | 1 + 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 app/controllers/api/pm/action_runs_controller.rb diff --git a/app/controllers/api/pm/action_runs_controller.rb b/app/controllers/api/pm/action_runs_controller.rb new file mode 100644 index 000000000..0e69d56a9 --- /dev/null +++ b/app/controllers/api/pm/action_runs_controller.rb @@ -0,0 +1,48 @@ +class Api::Pm::ActionRunsController < Api::Pm::BaseController + before_action :require_login + + def index + render_error('请输入workflows') if params[:workflows].blank? + @owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s) + render_error('组织未找到') if @owner.blank? + action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid) + group_data = action_runs.where(workflow_id: params[:workflows].to_s.split(",")).group(:workflow_id, :status).count + @result = [] + params[:workflows].to_s.split(",").each do |file| + last_action_run = action_runs.where(workflow_id: file).order(updated: :desc).first + last_action_run_json = last_action_run.present? ? { + id: last_action_run.id, + schedule: last_action_run.schedule_id > 0, + title: last_action_run.title, + index: last_action_run.index, + status: last_action_run.status, + started: last_action_run.started, + stopped: last_action_run.stopped, + length: last_action_run.stopped - last_action_run.started, + created: last_action_run.created, + updated: last_action_run.updated, + } : {} + + total = 0 + success = 0 + failure = 0 + group_data.each do |k,v| + total += v if k[0] == file + success += v if k[0] == file && k[1] == 1 + failure += v if k[0] == file && k[1] == 2 + end + + @result << { + name: file, + last_action_run: last_action_run_json, + history: { + total: total, + success: success, + failure: failure + } + } + end + render :json => @result + end + +end \ No newline at end of file diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 5a34847e2..1e9177144 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -3,8 +3,8 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions def new_index @files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") puts @files - @action_runs = Gitea::ActionRun.where(repo_id: @project.gpid, status: [1,2]) - group_data = @action_runs.group(:workflow_id, :status).count + @action_runs = Gitea::ActionRun.where(repo_id: @project.gpid) + group_data = @action_runs.where(status: [1,2]).group(:workflow_id, :status).count @result = [] @files.map{|i|i['name']}.each do |file| last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first diff --git a/config/routes/api.rb b/config/routes/api.rb index ec8031fd8..629ea93f7 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -50,6 +50,7 @@ defaults format: :json do get :polyline end end + resources :action_runs, only: [:index] end namespace :v1 do From 47627fbcaf0f1644583d92eba0234815f6a74985 Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 23 Jan 2025 15:56:14 +0800 Subject: [PATCH 02/24] =?UTF-8?q?=E6=96=B0=E5=A2=9E:=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=B5=81=E6=B0=B4=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/actions_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 5a34847e2..bfcb2875d 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -2,8 +2,9 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions def new_index @files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") - puts @files @action_runs = Gitea::ActionRun.where(repo_id: @project.gpid, status: [1,2]) + @action_runs = @action_runs.where(id: params[:ids].split(",")) if params[:ids].present? + @action_runs = @action_runs.where(workflow_id: params[:workflow_ids].split(",")) if params[:workflow_ids].present? group_data = @action_runs.group(:workflow_id, :status).count @result = [] @files.map{|i|i['name']}.each do |file| From dee3d1c43818d2a0cbd05d12fae750296260a65e Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 23 Jan 2025 16:18:53 +0800 Subject: [PATCH 03/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/actions_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 1885273b1..7186067c2 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -28,7 +28,7 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions group_data.each do |k,v| total += v if k[0] == file success += v if k[0] == file && k[1] == 1 - failure += v if k[0] == file && k[1] == 1 + failure += v if k[0] == file && k[1] == 2 end @result << { From a73292ad98aa2c0cfa93797c4eb996648a8790bc Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 23 Jan 2025 16:19:52 +0800 Subject: [PATCH 04/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E8=BF=90=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E6=94=B9=E6=88=90=E4=B8=80=E7=BB=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=B9=E4=BE=BF=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/action_runs_controller.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/pm/action_runs_controller.rb b/app/controllers/api/pm/action_runs_controller.rb index 0e69d56a9..76cf64629 100644 --- a/app/controllers/api/pm/action_runs_controller.rb +++ b/app/controllers/api/pm/action_runs_controller.rb @@ -34,13 +34,10 @@ class Api::Pm::ActionRunsController < Api::Pm::BaseController @result << { name: file, - last_action_run: last_action_run_json, - history: { - total: total, - success: success, - failure: failure - } - } + total: total, + success: success, + failure: failure + }.merge(last_action_run) end render :json => @result end From 5d01e8ae4036533a4e51e5f951591c6d133f315f Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 23 Jan 2025 16:24:08 +0800 Subject: [PATCH 05/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E8=BF=90=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E6=94=B9=E6=88=90=E4=B8=80=E7=BB=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=B9=E4=BE=BF=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/action_runs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/action_runs_controller.rb b/app/controllers/api/pm/action_runs_controller.rb index 76cf64629..c450b8908 100644 --- a/app/controllers/api/pm/action_runs_controller.rb +++ b/app/controllers/api/pm/action_runs_controller.rb @@ -37,7 +37,7 @@ class Api::Pm::ActionRunsController < Api::Pm::BaseController total: total, success: success, failure: failure - }.merge(last_action_run) + }.merge(last_action_run_json) end render :json => @result end From 2e7e25e2d1434d7a328c240b82e7bd5a5fd4c3fb Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 24 Jan 2025 08:32:53 +0800 Subject: [PATCH 06/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E8=BF=90=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E6=94=B9=E6=88=90=E4=B8=80=E7=BB=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=B9=E4=BE=BF=E4=BD=BF=E7=94=A8,status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/action_runs_controller.rb | 6 +++--- .../api/v1/projects/actions/actions_controller.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/pm/action_runs_controller.rb b/app/controllers/api/pm/action_runs_controller.rb index c450b8908..88bb6b129 100644 --- a/app/controllers/api/pm/action_runs_controller.rb +++ b/app/controllers/api/pm/action_runs_controller.rb @@ -2,11 +2,11 @@ class Api::Pm::ActionRunsController < Api::Pm::BaseController before_action :require_login def index - render_error('请输入workflows') if params[:workflows].blank? + tip_exception('请输入workflows') if params[:workflows].blank? @owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s) - render_error('组织未找到') if @owner.blank? + tip_exception('组织未找到') if @owner.blank? action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid) - group_data = action_runs.where(workflow_id: params[:workflows].to_s.split(",")).group(:workflow_id, :status).count + group_data = action_runs.where(workflow_id: params[:workflows].to_s.split(",")).where(status: [1,2]).group(:workflow_id, :status).count @result = [] params[:workflows].to_s.split(",").each do |file| last_action_run = action_runs.where(workflow_id: file).order(updated: :desc).first diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 7186067c2..0d7d51336 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -5,7 +5,7 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions @action_runs = Gitea::ActionRun.where(repo_id: @project.gpid) @action_runs = @action_runs.where(id: params[:ids].split(",")) if params[:ids].present? @action_runs = @action_runs.where(workflow_id: params[:workflow_ids].split(",")) if params[:workflow_ids].present? - group_data = @action_runs.group(:workflow_id, :status).count + group_data = @action_runs.where(status: [1,2]).group(:workflow_id, :status).count @result = [] @files.map{|i|i['name']}.each do |file| last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first From 4da3ac255827c42cb1e069959908de2e5f53d5ec Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 24 Jan 2025 08:48:58 +0800 Subject: [PATCH 07/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E8=BF=90=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E6=94=B9=E6=88=90=E4=B8=80=E7=BB=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=B9=E4=BE=BF=E4=BD=BF=E7=94=A8,=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=8F=96=E5=80=BCkey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/action_runs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/pm/action_runs_controller.rb b/app/controllers/api/pm/action_runs_controller.rb index 88bb6b129..85af3a447 100644 --- a/app/controllers/api/pm/action_runs_controller.rb +++ b/app/controllers/api/pm/action_runs_controller.rb @@ -39,7 +39,7 @@ class Api::Pm::ActionRunsController < Api::Pm::BaseController failure: failure }.merge(last_action_run_json) end - render :json => @result + render :json => {data: @result} end end \ No newline at end of file From a26bbf35c5b742c63044d1a4b3cf0d5f5cdca846 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 24 Jan 2025 09:42:45 +0800 Subject: [PATCH 08/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E8=BF=90=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E6=94=B9=E6=88=90=E4=B8=80=E7=BB=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=B9=E4=BE=BF=E4=BD=BF=E7=94=A8,=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=B1=BB=E5=9E=8B=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v1/projects/actions/actions_controller.rb | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 0d7d51336..5d494d288 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -31,18 +31,26 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions failure += v if k[0] == file && k[1] == 2 end + pipeline_type = 1 + begin + content = Gitea::Repository::Entries::GetService.call(@project&.owner, @project&.identifier, URI.escape(file), ref: last_action_run.present? ? last_action_run.gsub("refs/heads/","") : @project.default_branch)['content'] + yaml_string = Base64.decode64(content).force_encoding("GBK").encode("UTF-8") unless Base64.decode64(content).force_encoding('UTF-8').valid_encoding? + yaml_string = Base64.decode64(content).force_encoding('UTF-8') + yml = YAML.safe_load(yaml_string) + pipeline_type = yml.name == file.to_s.gsub(".yml","").gsub(".yaml","") ? 2 : 1 + rescue + Rails.logger.info("#{file}不能识别流水线类型") + end @result << { - name: file, - last_action_run: last_action_run_json, - history: { - total: total, - success: success, - failure: failure, - } - } + name: file.to_s.gsub(".yml","").gsub(".yaml","") , + branch: last_action_run.present? ? last_action_run.gsub("refs/heads/","") : @project.default_branch, + pipeline_type: pipeline_type, + total: total, + success: success, + failure: failure + }.merge(last_action_run_json) end - - render :json => @result + render :json => {data: @result} end def index From 5540d8732c1cf17e59d921be332e0073a8751e31 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 24 Jan 2025 09:45:47 +0800 Subject: [PATCH 09/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E8=BF=90=E8=A1=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E6=94=B9=E6=88=90=E4=B8=80=E7=BB=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=B9=E4=BE=BF=E4=BD=BF=E7=94=A8,=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=B1=BB=E5=9E=8B=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/actions_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 5d494d288..824d966ea 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -33,7 +33,7 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions pipeline_type = 1 begin - content = Gitea::Repository::Entries::GetService.call(@project&.owner, @project&.identifier, URI.escape(file), ref: last_action_run.present? ? last_action_run.gsub("refs/heads/","") : @project.default_branch)['content'] + content = Gitea::Repository::Entries::GetService.call(@project&.owner, @project&.identifier, URI.escape(file), ref: last_action_run.present? ? last_action_run.ref.gsub("refs/heads/","") : @project.default_branch)['content'] yaml_string = Base64.decode64(content).force_encoding("GBK").encode("UTF-8") unless Base64.decode64(content).force_encoding('UTF-8').valid_encoding? yaml_string = Base64.decode64(content).force_encoding('UTF-8') yml = YAML.safe_load(yaml_string) @@ -43,7 +43,7 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions end @result << { name: file.to_s.gsub(".yml","").gsub(".yaml","") , - branch: last_action_run.present? ? last_action_run.gsub("refs/heads/","") : @project.default_branch, + branch: last_action_run.present? ? last_action_run.ref.gsub("refs/heads/","") : @project.default_branch, pipeline_type: pipeline_type, total: total, success: success, From 5c2639773ed086de0ebef1e875b4262c351c7ae9 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 24 Jan 2025 11:18:50 +0800 Subject: [PATCH 10/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BA=8B=E4=BB=B6=E8=AE=BE=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A2=9E=E5=8A=A0=E5=BF=BD=E7=95=A5=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF=E6=96=87=E4=BB=B6=E6=94=B9=E5=8A=A8=E6=89=A7?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb index 4d3bf7738..3887278b4 100644 --- a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb +++ b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb @@ -13,6 +13,9 @@ on: <% end %> <% end %> <% end %> + paths-ignore: + - '.gitea/workflows/**' + - '.github/workflows/**' <% end %> <%if node.name.to_s.include?("on-pull_request") && node.input_values.present? %> pull_request: @@ -26,6 +29,9 @@ on: <% end %> <% end %> <% end %> + paths-ignore: + - '.gitea/workflows/**' + - '.github/workflows/**' <% end %> <%if node.name.to_s.include?("on-schedule") && node.input_values.present? %> schedule: From 8a052e30d8773f8be2151b31e021174456f78af4 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 11 Feb 2025 09:12:27 +0800 Subject: [PATCH 11/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E4=B8=8D=E5=AD=98=E5=9C=A8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/actions_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 824d966ea..0769a2e78 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -1,7 +1,7 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions::BaseController def new_index - @files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") + @files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") rescue [] @action_runs = Gitea::ActionRun.where(repo_id: @project.gpid) @action_runs = @action_runs.where(id: params[:ids].split(",")) if params[:ids].present? @action_runs = @action_runs.where(workflow_id: params[:workflow_ids].split(",")) if params[:workflow_ids].present? From 98a2bc5b4a7fe151b462b5abfed0d0cfb7bd64a7 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 11 Feb 2025 11:20:02 +0800 Subject: [PATCH 12/24] =?UTF-8?q?=E6=96=B0=E5=A2=9E:=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BF=E5=88=97=E8=A1=A8=E6=90=9C=E7=B4=A2=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/projects/actions/actions_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 0769a2e78..1adf75c35 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -2,12 +2,16 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions def new_index @files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") rescue [] + @workflows = params[:workflows].split(",") if params[:workflows].present? @action_runs = Gitea::ActionRun.where(repo_id: @project.gpid) @action_runs = @action_runs.where(id: params[:ids].split(",")) if params[:ids].present? - @action_runs = @action_runs.where(workflow_id: params[:workflow_ids].split(",")) if params[:workflow_ids].present? + @action_runs = @action_runs.where(workflows: @workflows) if params[:workflows].present? group_data = @action_runs.where(status: [1,2]).group(:workflow_id, :status).count @result = [] @files.map{|i|i['name']}.each do |file| + if @workflows.present? + next !@workflows.include?(file) + end last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first last_action_run_json = last_action_run.present? ? { id: last_action_run.id, From 6096234742c3d14fb2159e8db11f15128707f9f8 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 11 Feb 2025 11:26:02 +0800 Subject: [PATCH 13/24] fix --- app/controllers/api/v1/projects/actions/actions_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 1adf75c35..ea4023941 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -5,7 +5,7 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions @workflows = params[:workflows].split(",") if params[:workflows].present? @action_runs = Gitea::ActionRun.where(repo_id: @project.gpid) @action_runs = @action_runs.where(id: params[:ids].split(",")) if params[:ids].present? - @action_runs = @action_runs.where(workflows: @workflows) if params[:workflows].present? + @action_runs = @action_runs.where(workflow_id: @workflows) if params[:workflows].present? group_data = @action_runs.where(status: [1,2]).group(:workflow_id, :status).count @result = [] @files.map{|i|i['name']}.each do |file| From 62eeda7007fe2f496f47beeeb4417245861600ec Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 11 Feb 2025 11:31:14 +0800 Subject: [PATCH 14/24] fix --- app/controllers/api/v1/projects/actions/actions_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index ea4023941..b70e2fdf6 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -10,7 +10,7 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions @result = [] @files.map{|i|i['name']}.each do |file| if @workflows.present? - next !@workflows.include?(file) + next if !@workflows.include?(file) end last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first last_action_run_json = last_action_run.present? ? { From 465d5db87e73f035ca36cfb01a15e717bf32146d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 11 Feb 2025 11:40:34 +0800 Subject: [PATCH 15/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BA=8B=E4=BB=B6fork?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/pipelines/build_pipeline.yaml.erb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb index 3887278b4..503f695ce 100644 --- a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb +++ b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb @@ -33,6 +33,22 @@ on: - '.gitea/workflows/**' - '.github/workflows/**' <% end %> + <%if node.name.to_s.include?("on-fork") && node.input_values.present? %> + fork: + <% node.input_values.each_key do |key| %> + <%=key %>: + <% if node.input_values[key].blank? %> + - '*' + <% else %> + <% node.input_values[key].to_s.split(",").each do |val| %> + - <%=val %> + <% end %> + <% end %> + <% end %> + paths-ignore: + - '.gitea/workflows/**' + - '.github/workflows/**' + <% end %> <%if node.name.to_s.include?("on-schedule") && node.input_values.present? %> schedule: <% node.input_values.each_key do |key| %> From 19ccaa5599ef4a53b824d82b19933b5d8abe855c Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 11 Feb 2025 12:24:46 +0800 Subject: [PATCH 16/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BA=8B=E4=BB=B6fork?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb index 503f695ce..cc9e67643 100644 --- a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb +++ b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb @@ -33,7 +33,7 @@ on: - '.gitea/workflows/**' - '.github/workflows/**' <% end %> - <%if node.name.to_s.include?("on-fork") && node.input_values.present? %> + <%if node.name.to_s.include?("on-fork") %> fork: <% node.input_values.each_key do |key| %> <%=key %>: From 2e93b5ea34347f48ad7db3c4f5f5b462d1fb2eab Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 11 Feb 2025 12:26:08 +0800 Subject: [PATCH 17/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BA=8B=E4=BB=B6fork?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v1/projects/pipelines/build_pipeline.yaml.erb | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb index cc9e67643..782485674 100644 --- a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb +++ b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb @@ -35,19 +35,6 @@ on: <% end %> <%if node.name.to_s.include?("on-fork") %> fork: - <% node.input_values.each_key do |key| %> - <%=key %>: - <% if node.input_values[key].blank? %> - - '*' - <% else %> - <% node.input_values[key].to_s.split(",").each do |val| %> - - <%=val %> - <% end %> - <% end %> - <% end %> - paths-ignore: - - '.gitea/workflows/**' - - '.github/workflows/**' <% end %> <%if node.name.to_s.include?("on-schedule") && node.input_values.present? %> schedule: From 2dbc7ee9f12993269fb530237eaceaab0cb08086 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 11 Feb 2025 12:27:46 +0800 Subject: [PATCH 18/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BA=8B=E4=BB=B6fork?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb index 782485674..9690d1cb7 100644 --- a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb +++ b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb @@ -34,8 +34,8 @@ on: - '.github/workflows/**' <% end %> <%if node.name.to_s.include?("on-fork") %> - fork: - <% end %> + fork: + <% end %> <%if node.name.to_s.include?("on-schedule") && node.input_values.present? %> schedule: <% node.input_values.each_key do |key| %> From bbbf4283d4ab9d230cfdafdb52c59e9659c05d84 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 11 Feb 2025 15:33:15 +0800 Subject: [PATCH 19/24] =?UTF-8?q?=E6=96=B0=E5=A2=9E:=20filenmae?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/actions_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index b70e2fdf6..cc80b68de 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -46,6 +46,7 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions Rails.logger.info("#{file}不能识别流水线类型") end @result << { + filename: file, name: file.to_s.gsub(".yml","").gsub(".yaml","") , branch: last_action_run.present? ? last_action_run.ref.gsub("refs/heads/","") : @project.default_branch, pipeline_type: pipeline_type, From ce980714af082de5861cb3cb946b57eaede56ade Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 12 Feb 2025 09:07:47 +0800 Subject: [PATCH 20/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BA=8B=E4=BB=B6pull=5Frequest:opened?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb index 9690d1cb7..c08455162 100644 --- a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb +++ b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb @@ -19,6 +19,8 @@ on: <% end %> <%if node.name.to_s.include?("on-pull_request") && node.input_values.present? %> pull_request: + types: + - opened <% node.input_values.each_key do |key| %> <%=key %>: <% if node.input_values[key].blank? %> From ef18ea8cdcda5842b7db35ad6f02418fda1adc7e Mon Sep 17 00:00:00 2001 From: yystopf Date: Thu, 13 Feb 2025 14:00:00 +0800 Subject: [PATCH 21/24] =?UTF-8?q?=E6=9B=B4=E6=94=B9:=20=E8=BD=AC=E7=A7=BB?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=B2=BE=E9=80=89=E9=A1=B9=E7=9B=AE=E6=B8=85?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/projects/transfer_service.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb index 43ae135dc..973d4ede3 100644 --- a/app/services/projects/transfer_service.rb +++ b/app/services/projects/transfer_service.rb @@ -31,6 +31,7 @@ class Projects::TransferService < ApplicationService project.members.map{|m| m.destroy! if m.user_id == owner.id || project.member(new_owner.id) || (new_owner.is_a?(Organization) && new_owner.is_member?(m.user_id)) } project.update!(user_id: new_owner.id) project.set_owner_permission(new_owner) + project.pinned_projects.destroy_all # 移除原来精选的项目 end def update_actions From 053afec58722fb1b0e719d44900ff0d7eefec49d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 13 Feb 2025 15:58:12 +0800 Subject: [PATCH 22/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E8=AE=A1=E6=95=B0=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/runs_controller.rb | 5 +++-- app/views/api/v1/projects/actions/runs/index.json.jbuilder | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/projects/actions/runs_controller.rb b/app/controllers/api/v1/projects/actions/runs_controller.rb index 9d0cdb8b0..808a86549 100644 --- a/app/controllers/api/v1/projects/actions/runs_controller.rb +++ b/app/controllers/api/v1/projects/actions/runs_controller.rb @@ -1,8 +1,9 @@ class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::BaseController - def index + def index @result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit}, current_user&.gitea_token) - puts @result_object + @begin_num = (page.to_i -1) * limit.to_i + # puts @result_object end def create diff --git a/app/views/api/v1/projects/actions/runs/index.json.jbuilder b/app/views/api/v1/projects/actions/runs/index.json.jbuilder index 9122ef9cf..e0a8aa189 100644 --- a/app/views/api/v1/projects/actions/runs/index.json.jbuilder +++ b/app/views/api/v1/projects/actions/runs/index.json.jbuilder @@ -1,6 +1,7 @@ json.total_data @result_object[:total_data].to_i if @result_object[:data]["Runs"].present? - json.runs @result_object[:data]["Runs"].each do |run| + json.runs @result_object[:data]["Runs"].each_with_index.to_a do |run, index| + json.num @result_object[:total_data].to_i - @begin_num - index json.workflow run["WorkflowID"] json.index run["Index"] json.title run["Title"] From 4fe26099dda7a1da58884cb8dc33859b31515e2e Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 13 Feb 2025 16:01:54 +0800 Subject: [PATCH 23/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E8=AE=A1=E6=95=B0=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/projects/actions/runs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/projects/actions/runs_controller.rb b/app/controllers/api/v1/projects/actions/runs_controller.rb index 808a86549..cdde508a1 100644 --- a/app/controllers/api/v1/projects/actions/runs_controller.rb +++ b/app/controllers/api/v1/projects/actions/runs_controller.rb @@ -2,7 +2,7 @@ class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::B def index @result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit}, current_user&.gitea_token) - @begin_num = (page.to_i -1) * limit.to_i + @begin_num = (page.to_i - 1) * limit.to_i # puts @result_object end From 3fcbf74890364f146cfee6f8dd9260f1040cc42d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Thu, 13 Feb 2025 16:06:57 +0800 Subject: [PATCH 24/24] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BA=8B=E4=BB=B6pull=5Frequest=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/pipelines/build_pipeline.yaml.erb | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb index c08455162..41908c8f5 100644 --- a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb +++ b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb @@ -17,23 +17,8 @@ on: - '.gitea/workflows/**' - '.github/workflows/**' <% end %> - <%if node.name.to_s.include?("on-pull_request") && node.input_values.present? %> + <%if node.name.to_s.include?("on-pull_request") %> pull_request: - types: - - opened - <% node.input_values.each_key do |key| %> - <%=key %>: - <% if node.input_values[key].blank? %> - - '*' - <% else %> - <% node.input_values[key].to_s.split(",").each do |val| %> - - <%=val %> - <% end %> - <% end %> - <% end %> - paths-ignore: - - '.gitea/workflows/**' - - '.github/workflows/**' <% end %> <%if node.name.to_s.include?("on-fork") %> fork: