diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb new file mode 100644 index 000000000..ba1bafc4e --- /dev/null +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -0,0 +1,542 @@ +class Api::V1::Projects::PipelinesController < Api::V1::BaseController + before_action :require_manager_above + + def index + @pipelines = Action::Pipeline.where(project_id: @project.id).order(updated_at: :desc) + @pipelines = paginate @pipelines + end + + def create + size = Action::Pipeline.where(pipeline_name: params[:pipeline_name], project_id: @project.id).size + tip_exception("已经存在#{params[:pipeline_name]}流水线!") if size > 0 + @pipeline = Action::Pipeline.new(pipeline_name: params[:pipeline_name], project_id: @project.id) + @pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yaml" + @pipeline.json = demo.to_json + # @pipeline.json = params[:json] if params[:json] + @pipeline.yaml = build_pipeline_yaml(@pipeline) + @pipeline.save! + sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) + tip_exception("#{@pipeline.file_name}已存在") if sha + interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params) + tip_exception(interactor.error) unless interactor.success? + render_ok({ id: @pipeline.id }) + end + + def update + @pipeline = Action::Pipeline.find(params[:id]) + @pipeline.update!(pipeline_name: params[:pipeline_name]) + interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params) + tip_exception(interactor.error) unless interactor.success? + render_ok + end + + def destroy + @pipeline = Action::Pipeline.find(params[:id]) + if pipeline + interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, content_params) + tip_exception(interactor.error) unless interactor.success? + @pipeline.destroy! + end + render_ok + end + + def show + @pipeline = Action::Pipeline.find_by(id: params[:id]) + @pipeline = Action::Pipeline.new(id: 0, pipeline_name: "test-ss", yaml: build_yaml) if @pipeline.blank? + end + + def build_pipeline_yaml(pipeline) + if pipeline.json.present? + @name = pipeline.pipeline_name + params_nodes = JSON.parse(pipeline.json)["nodes"].select { |node| !["on-push", "on-schedule"].include?(node["component_name"]) } + on_nodes = JSON.parse(pipeline.json)["nodes"].select { |node| ["on-push", "on-schedule"].include?(node["component_name"]) } + @on_nodes = build_nodes(on_nodes) + @steps_nodes = build_nodes(params_nodes) + yaml = ERB.new(File.read(File.join(Rails.root, "app/views/api/v1/projects/pipelines", "build_pipeline.yaml.erb"))).result(binding) + # 删除空行内容 + @pipeline_yaml = yaml.gsub(/^\s*\n/, "") + else + @pipeline_yaml = params[:yaml] + end + @pipeline_yaml + end + + def build_yaml + @name = "love me" + params_nodes = JSON.parse(demo.to_json)["nodes"].select { |node| !["on-push", "on-schedule"].include?(node["component_name"]) } + on_nodes = JSON.parse(demo.to_json)["nodes"].select { |node| ["on-push", "on-schedule"].include?(node["component_name"]) } + @on_nodes = build_nodes(on_nodes) + @steps_nodes = [] + params_nodes.each do |input_node| + # Rails.logger.info "input_node=====0===#{input_node["component_name"]}======#{input_node["in_parameters"]}" + node = Action::Node.find_by(name: input_node["component_name"]) + node.cust_name = input_node["component_label"] if input_node["component_label"].present? + input_values = {} + if input_node["in_parameters"].present? + # Rails.logger.info "@in_parameters=====11===#{input_node["component_name"]}======#{input_node["in_parameters"]}" + input_node["in_parameters"].each_key do |input_key| + # Rails.logger.info "@in_parameters.input_key===#{input_key}" + # Rails.logger.info "@in_parameters.input_value===#{input_node["in_parameters"][input_key]["value"]}" + input_values = input_values.merge({ "#{input_key.gsub("--", "")}": "#{input_node["in_parameters"][input_key]["value"]}" }) + end + node.input_values = input_values + # Rails.logger.info "@input_values node===#{node.input_values.to_json}" + end + @steps_nodes.push(node) + end + Rails.logger.info "@@on_nodes===#{@on_nodes.to_json}" + Rails.logger.info "@steps_nodes===#{@steps_nodes.to_json}" + yaml = ERB.new(File.read(File.join(Rails.root, "app/views/api/v1/projects/pipelines", "build_pipeline.yaml.erb"))).result(binding) + @pipeline_yaml = yaml.gsub(/^\s*\n/, "") + Rails.logger.info "=========================" + Rails.logger.info @pipeline_yaml + @pipeline_yaml + end + + private + + def get_pipeline_file_sha(file_name, branch) + file_path_uri = URI.parse(file_name) + interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: branch || 'master') + if interactor.success? + file = interactor.result + file['sha'] + end + end + + def content_params + { + filepath: ".gitea/workflows/#{@pipeline.pipeline_name}.yaml", + branch: @pipeline.branch, + new_branch: @pipeline.branch, + content: build_pipeline_yaml(@pipeline), + message: 'create pipeline', + committer: { + email: current_user.mail, + name: current_user.login + }, + identifier: @project.identifier + } + end + + def build_nodes(params_nodes) + steps_nodes = [] + params_nodes.each do |input_node| + node = Action::Node.find_by(name: input_node["component_name"]) + node.cust_name = input_node["component_label"] if input_node["component_label"].present? + input_values = {} + if input_node["in_parameters"].present? + # Rails.logger.info "@in_parameters=====11===#{input_node["component_name"]}======#{input_node["in_parameters"]}" + input_node["in_parameters"].each_key do |input_key| + # Rails.logger.info "@in_parameters.input_key===#{input_key}" + # Rails.logger.info "@in_parameters.input_value===#{input_node["in_parameters"][input_key]["value"]}" + input_values = input_values.merge({ "#{input_key.gsub("--", "")}": "#{input_node["in_parameters"][input_key]["value"]}" }) + end + # Rails.logger.info "@input_values node1===#{input_values}" + node.input_values = input_values + # Rails.logger.info "@input_values node===#{node.input_values.to_json}" + end + steps_nodes.push(node) + end + steps_nodes + end + + def demo + { + "nodes": [ + { + "id": "git-clone-245734ab", + "category_id": 1, + "component_name": "on-schedule", + "component_label": "触发器", + "working_directory": "", + "command": "", + "in_parameters": { + "--cro": { + "type": "str", + "item_type": "", + "label": "push代码", + "require": 1, + "choice": [], + "default": "", + "placeholder": "私有仓库填写ssh地址,公有仓库填写https git地址", + "describe": "代码仓库地址", + "editable": 1, + "condition": "", + "value": "15 4,5 * * *" + }, + "--paths-ignore": { + "type": "str", + "item_type": "", + "label": "push代码", + "require": 1, + "choice": [], + "default": "", + "placeholder": "私有仓库填写ssh地址,公有仓库填写https git地址", + "describe": "代码仓库地址", + "editable": 1, + "condition": "", + "value": "**.md" + } + }, + "out_parameters": { + "--code_output": { + "type": "str", + "label": "代码输出路径", + "path": "/code", + "require": 1, + "value": "/code" + } + }, + "description": "代码拉取组件", + "icon_path": "component-icon-1", + "create_by": "admin", + "create_time": "2024-03-02T05:41:25.000+00:00", + "update_by": "admin", + "update_time": "2024-03-02T05:41:25.000+00:00", + "state": 1, + "image": "172.20.32.187/pipeline-component/built-in/git:202312071000", + "env_variables": "", + "x": 532, + "y": 202, + "label": "代码拉取", + "img": "/assets/images/component-icon-1.png", + "isCluster": false, + "type": "rect-node", + "size": [110, 36], + "--code_path": "https://openi.pcl.ac.cn/somunslotus/somun202304241505581.git", + "--branch": "train_ci_test", + "--depth": "1", + "--code_output": "/code" + }, + { + "id": "git-clone-245734ab", + "category_id": 1, + "component_name": "git-clone", + "component_label": "代码拉取", + "working_directory": "", + "command": "", + "in_parameters": { + + }, + "out_parameters": { + "--code_output": { + "type": "str", + "label": "代码输出路径", + "path": "/code", + "require": 1, + "value": "/code" + } + }, + "description": "代码拉取组件", + "icon_path": "component-icon-1", + "create_by": "admin", + "create_time": "2024-03-02T05:41:25.000+00:00", + "update_by": "admin", + "update_time": "2024-03-02T05:41:25.000+00:00", + "state": 1, + "image": "172.20.32.187/pipeline-component/built-in/git:202312071000", + "env_variables": "", + "x": 532, + "y": 202, + "label": "代码拉取", + "img": "/assets/images/component-icon-1.png", + "isCluster": false, + "type": "rect-node", + "size": [110, 36], + "--code_path": "https://openi.pcl.ac.cn/somunslotus/somun202304241505581.git", + "--branch": "train_ci_test", + "--depth": "1", + "--code_output": "/code" + }, + { + "id": "git-clone-245734ab", + "category_id": 1, + "component_name": "setup-java", + "component_label": "安装java环境", + "working_directory": "", + "command": "", + "in_parameters": { + "--distribution": { + "type": "str", + "item_type": "", + "label": "代码仓库地址", + "require": 1, + "choice": [], + "default": "", + "placeholder": "私有仓库填写ssh地址,公有仓库填写https git地址", + "describe": "代码仓库地址", + "editable": 1, + "condition": "", + "value": "jdkfile" + }, + "--java-version": { + "type": "str", + "item_type": "", + "label": "代码分支/tag", + "require": 1, + "choice": [], + "default": "master", + "placeholder": "", + "describe": "代码分支或者tag", + "editable": 1, + "condition": "", + "value": "11.0.0" + }, + "--architecture": { + "type": "str", + "item_type": "", + "label": "克隆深度", + "require": 0, + "choice": [], + "default": "1", + "placeholder": "", + "describe": "代码克隆深度", + "editable": 1, + "condition": "", + "value": "x64" + }, + "--mvn-toolchain-vendor": { + "type": "str", + "item_type": "", + "label": "ssh私钥", + "require": 0, + "choice": [], + "default": "1", + "placeholder": "", + "describe": "ssh私钥,确保ssh公钥已经托管到代码平台,否则可能拉取失败", + "editable": 1, + "value": "Oracle" + } + }, + "out_parameters": { + "--code_output": { + "type": "str", + "label": "代码输出路径", + "path": "/code", + "require": 1, + "value": "/code" + } + }, + "description": "代码拉取组件", + "icon_path": "component-icon-1", + "create_by": "admin", + "create_time": "2024-03-02T05:41:25.000+00:00", + "update_by": "admin", + "update_time": "2024-03-02T05:41:25.000+00:00", + "state": 1, + "image": "172.20.32.187/pipeline-component/built-in/git:202312071000", + "env_variables": "", + "x": 532, + "y": 202, + "label": "代码拉取", + "img": "/assets/images/component-icon-1.png", + "isCluster": false, + "type": "rect-node", + "size": [110, 36], + "--code_path": "https://openi.pcl.ac.cn/somunslotus/somun202304241505581.git", + "--branch": "train_ci_test", + "--depth": "1", + "--code_output": "/code" + }, + { + "id": "git-clone-245734ab", + "category_id": 1, + "component_name": "shell", + "component_label": "执行shell命令", + "working_directory": "", + "command": "", + "in_parameters": { + "--run": { + "type": "str", + "item_type": "", + "label": "代码仓库地址", + "require": 1, + "choice": [], + "default": "", + "placeholder": "私有仓库填写ssh地址,公有仓库填写https git地址", + "describe": "代码仓库地址", + "editable": 1, + "condition": "", + "value": "service nginx restart" + } + } + }, + { + "id": "git-clone-245734ab", + "category_id": 1, + "component_name": "scp", + "component_label": "scp", + "working_directory": "", + "command": "", + "in_parameters": { + "--run": { + "type": "str", + "item_type": "", + "label": "代码仓库地址", + "require": 1, + "choice": [], + "default": "", + "placeholder": "私有仓库填写ssh地址,公有仓库填写https git地址", + "describe": "代码仓库地址", + "editable": 1, + "condition": "", + "value": "service nginx restart" + } + } + } + + ], + # "edges": [ + # { + # "source": "git-clone-245734ab", + # "target": "model-train-09b1491", + # "style": { + # "active": { + # "stroke": "rgb(95, 149, 255)", + # "lineWidth": 1 + # }, + # "selected": { + # "stroke": "rgb(95, 149, 255)", + # "lineWidth": 2, + # "shadowColor": "rgb(95, 149, 255)", + # "shadowBlur": 10, + # "text-shape": { + # "fontWeight": 500 + # } + # }, + # "highlight": { + # "stroke": "rgb(95, 149, 255)", + # "lineWidth": 2, + # "text-shape": { + # "fontWeight": 500 + # } + # }, + # "inactive": { + # "stroke": "rgb(234, 234, 234)", + # "lineWidth": 1 + # }, + # "disable": { + # "stroke": "rgb(245, 245, 245)", + # "lineWidth": 1 + # }, + # "endArrow": { + # "path": "M 6,0 L 9,-1.5 L 9,1.5 Z", + # "d": 4.5, + # "fill": "#CDD0DC" + # }, + # "cursor": "pointer", + # "lineWidth": 1, + # "opacity": 1, + # "stroke": "#CDD0DC", + # "radius": 1 + # }, + # "nodeStateStyle": { + # "hover": { + # "opacity": 1, + # "stroke": "#8fe8ff" + # } + # }, + # "labelCfg": { + # "autoRotate": true, + # "style": { + # "fontSize": 10, + # "fill": "#FFF" + # } + # }, + # "id": "edge-0.11773197923997381714446043619", + # "startPoint": { + # "x": 532, + # "y": 220.25, + # "anchorIndex": 1 + # }, + # "endPoint": { + # "x": 530, + # "y": 304.75, + # "anchorIndex": 0 + # }, + # "targetAnchor": 0, + # "type": "cubic-vertical", + # "curveOffset": [0, 0], + # "curvePosition": [0.5, 0.5], + # "minCurveOffset": [0, 0], + # "depth": 0 + # }, + # { + # "source": "model-train-09b1491", + # "target": "model-evaluate-b401ff0", + # "style": { + # "active": { + # "stroke": "rgb(95, 149, 255)", + # "lineWidth": 1 + # }, + # "selected": { + # "stroke": "rgb(95, 149, 255)", + # "lineWidth": 2, + # "shadowColor": "rgb(95, 149, 255)", + # "shadowBlur": 10, + # "text-shape": { + # "fontWeight": 500 + # } + # }, + # "highlight": { + # "stroke": "rgb(95, 149, 255)", + # "lineWidth": 2, + # "text-shape": { + # "fontWeight": 500 + # } + # }, + # "inactive": { + # "stroke": "rgb(234, 234, 234)", + # "lineWidth": 1 + # }, + # "disable": { + # "stroke": "rgb(245, 245, 245)", + # "lineWidth": 1 + # }, + # "endArrow": { + # "path": "M 6,0 L 9,-1.5 L 9,1.5 Z", + # "d": 4.5, + # "fill": "#CDD0DC" + # }, + # "cursor": "pointer", + # "lineWidth": 1, + # "opacity": 1, + # "stroke": "#CDD0DC", + # "radius": 1 + # }, + # "nodeStateStyle": { + # "hover": { + # "opacity": 1, + # "stroke": "#8fe8ff" + # } + # }, + # "labelCfg": { + # "autoRotate": true, + # "style": { + # "fontSize": 10, + # "fill": "#FFF" + # } + # }, + # "id": "edge-0.28238605806531771714446047075", + # "startPoint": { + # "x": 530, + # "y": 341.25, + # "anchorIndex": 1 + # }, + # "endPoint": { + # "x": 520, + # "y": 431.75, + # "anchorIndex": 0 + # }, + # "targetAnchor": 0, + # "type": "cubic-vertical", + # "curveOffset": [0, 0], + # "curvePosition": [0.5, 0.5], + # "minCurveOffset": [0, 0], + # "depth": 0 + # } + # ] + } + end +end diff --git a/app/models/action/node.rb b/app/models/action/node.rb index 69e45b3a8..601749047 100644 --- a/app/models/action/node.rb +++ b/app/models/action/node.rb @@ -19,6 +19,7 @@ # # Indexes # +# by_name (name) # index_action_nodes_on_action_types_id (action_node_types_id) # index_action_nodes_on_user_id (user_id) # @@ -33,39 +34,31 @@ class Action::Node < ApplicationRecord belongs_to :user, optional: true + attr_accessor :cust_name, :input_values - # def content_yaml - # "foo".to_yaml - # <<~YAML - # - name: Set up JDK ${{ matrix.java }} - # uses: actions/setup-java@v3 - # with: - # distribution: 'temurin' - # java-version: ${{ matrix.java }} - # YAML - # end - def yaml_hash + def content_yaml + "foo".to_yaml <<~YAML - name: Check dist - - on: - push: - branches: - - main - paths-ignore: - - '**.md' - pull_request: - paths-ignore: - - '**.md' - workflow_dispatch: - - jobs: - call-check-dist: - name: Check dist/ - uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main - with: - node-version: '20.x' + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: ${{ matrix.java }} YAML end + + def node + self + end + + def build_yaml + yaml = ERB.new(File.read(File.join(Rails.root, "app/views/api/v1/projects/pipelines", "build_node.yaml.erb"))).result(binding) + # 删除空行内容 + yaml = yaml.gsub(/^\s*\n/, "") + # Rails.logger.info "=========================" + # Rails.logger.info yaml + yaml + end + end diff --git a/app/models/action/pipeline.rb b/app/models/action/pipeline.rb new file mode 100644 index 000000000..1dfbd0f24 --- /dev/null +++ b/app/models/action/pipeline.rb @@ -0,0 +1,37 @@ +# == Schema Information +# +# Table name: action_pipelines +# +# id :integer not null, primary key +# project_id :integer +# user_id :integer +# pipeline_name :string(255) +# pipeline_status :string(255) +# description :string(255) +# file_name :string(255) +# is_graphic_design :boolean default("0") +# repo_name :string(255) +# repo_identifier :string(255) +# repo_owner :string(255) +# branch :string(255) +# event :string(255) +# sha :string(255) +# json :text(65535) +# yaml :text(65535) +# disable :boolean default("0") +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_action_pipelines_on_project_id (project_id) +# index_action_pipelines_on_user_id (user_id) +# + +class Action::Pipeline < ApplicationRecord + self.table_name = 'action_pipelines' + belongs_to :user, optional: true + belongs_to :project + + +end diff --git a/app/views/api/v1/projects/pipelines/build_node.yaml.erb b/app/views/api/v1/projects/pipelines/build_node.yaml.erb new file mode 100644 index 000000000..ded111099 --- /dev/null +++ b/app/views/api/v1/projects/pipelines/build_node.yaml.erb @@ -0,0 +1,9 @@ +steps: + - name: <%=self.node.name %> + uses: <%=self.full_name %> + <%if self.action_node_inputs.present? %> + with: + <% self.action_node_inputs.each do |input| %> + <%=input.name %>: '' + <%end %> + <%end %> \ No newline at end of file diff --git a/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb new file mode 100644 index 000000000..be8a7106e --- /dev/null +++ b/app/views/api/v1/projects/pipelines/build_pipeline.yaml.erb @@ -0,0 +1,55 @@ +# action name +name: <%=@name %> + +# 什么时候触发这个workflow +on: + <%@on_nodes.each do |node| %> + <%if node.name.to_s.include?("on-push") %> + push: + <% 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 %> + <% end %> + <%if node.name.to_s.include?("on-pull_request") %> + pull_request: + <% 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 %> + <% end %> + <%if node.name.to_s.include?("on-schedule") %> + schedule: + <% node.input_values.each_key do |key| %> + - <%=key %>: "<%=node.input_values[key] %>" + <% end %> + <% end %> + <% end %> + +jobs: + job1: + # 运行环境 + runs-on: 'ubuntu-latest' + steps: + <%@steps_nodes.each do |node| %> + - name: <%=node.cust_name || node.name %> + uses: <%=node.full_name %> + <%if node.input_values.present? %> + with: + <% node.input_values.each_key do |key| %> + <%=key %>: <%=node.input_values[key] %> + <%end %> + <%end %> + <% end %> diff --git a/app/views/api/v1/projects/pipelines/index.json.jbuilder b/app/views/api/v1/projects/pipelines/index.json.jbuilder new file mode 100644 index 000000000..7c3f2a405 --- /dev/null +++ b/app/views/api/v1/projects/pipelines/index.json.jbuilder @@ -0,0 +1,8 @@ +json.status 0 +json.message "success" + +json.pipelines @pipelines.each do |pip| + json.extract! pip, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, + :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at + # json.project +end diff --git a/app/views/api/v1/projects/pipelines/show.json.jbuilder b/app/views/api/v1/projects/pipelines/show.json.jbuilder new file mode 100644 index 000000000..d82015ade --- /dev/null +++ b/app/views/api/v1/projects/pipelines/show.json.jbuilder @@ -0,0 +1,5 @@ +json.status 0 +json.message "success" +json.extract! @pipeline, :id, :pipeline_name, :pipeline_status, :description, :file_name, :is_graphic_design, + :repo_name, :repo_identifier, :branch, :event, :sha, :disable, :json, :yaml, :created_at, :updated_at +# json.project \ No newline at end of file diff --git a/app/views/api/v1/projects/pipelines/test.yaml.erb b/app/views/api/v1/projects/pipelines/test.yaml.erb new file mode 100644 index 000000000..3ec890230 --- /dev/null +++ b/app/views/api/v1/projects/pipelines/test.yaml.erb @@ -0,0 +1,89 @@ +name: Check dist<%= @name %> + +# action name +name: Test with Junit + +# 什么时候触发这个workflow +on: + # push 到master分之的时候 这里可以指定多个 + #push: + # branches: + # - master +# paths-ignore: +# - '**.md' + # pull request 到master分之的时候, 这里可以指定多个 + #pull_request: + # branches: + # - master +# paths-ignore: +# - '**.md' + # 定时调度执行 + schedule: + - cron: '26 10,11 * * *' +env: + https_proxy: http://172.20.32.253:3128 + http_proxy: http://172.20.32.253:3128 + +# 一个workflow可以由多个job组成,多个job可以并行运行 +jobs: + junit: + strategy: + matrix: + # 指定jdk 版本。可以指定多个版本 比如[8,11,17] + java: [11] + # 指定运行 os 版本 也是多个 + os: [ 'ubuntu-latest' ] + # 运行环境,这里就是上面定义的多个 os + runs-on: 'ubuntu-latest' + + steps: + # 将job的工作目录指向$GITHUB_WORSPACES checkout@v2比较旧不推荐使用 + - name: Checkout codes + uses: actions/checkout@v3 + #- name: Install Java and Maven + # uses: actions/setup-java@v3 + # with: + # java-version: '11' + # distribution: 'temurin' + # 设置jdk环境 + - name: download latest temurin JDK + id: download_latest_jdk + env: + HTTPS_PROXY: http://172.20.32.253:3128 + HTTP_PROXY: http://172.20.32.253:3128 + #run: curl -o https://testgitea2.trustie.net/xxq250/licensee-identify-api-sss/raw/branch/master/openlogic-openjdk-11.0.22+7-linux-x64.tar.gz + run: wget -O $RUNNER_TEMP/java_package.tar.gz "http://172.20.32.202:10082/xxq250/licensee-identify-api-sss/raw/branch/master/OpenJDK11U-jdk_x64_linux_hotspot_11.0.22_7.tar.gz" + - uses: actions/setup-java@v4 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/java_package.tar.gz + java-version: '11.0.0' + architecture: x64 + mvn-toolchain-vendor: 'Oracle' + # 设置maven 仓库缓存 避免每次构建时都重新下载依赖 + - name: Cache local Maven repository + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Test java version + run: java -version + - name: Set up Maven + uses: stCarolas/setup-maven@v5 + with: + maven-version: 3.8.2 + - name: Setup Maven mirrors + uses: s4u/maven-settings-action@v3.0.0 + with: + mirrors: '[{"id": "alimaven", "name": "aliyun maven", "mirrorOf": "central", "url": "http://172.20.32.181:30005/repository/aliyun-maven/"}]' + - name: env show + run: env + - name: cat maven-settings.xml + run: cat /root/.m2/settings.xml + - name: Test with Maven + run: mvn clean test -B -U + env: + https_proxy: http://172.20.32.253:3128 + http_proxy: http://172.20.32.253:3128 diff --git a/config/routes/api.rb b/config/routes/api.rb index a111bcdb2..4db29cf06 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -129,7 +129,8 @@ defaults format: :json do end end end - resources :pulls, module: 'pulls' do + resources :pipelines + resources :pulls, module: 'pulls' do resources :versions, only: [:index] do member do get :diff diff --git a/db/migrate/20240408010227_create_action_node_inputs.rb b/db/migrate/20240408010227_create_action_node_inputs.rb index 501844e28..a710271cd 100644 --- a/db/migrate/20240408010227_create_action_node_inputs.rb +++ b/db/migrate/20240408010227_create_action_node_inputs.rb @@ -6,7 +6,7 @@ class CreateActionNodeInputs < ActiveRecord::Migration[5.2] t.string :input_type t.string :description t.boolean :is_required, default: false - t.string :sort_no, default: 0 + t.integer :sort_no, default: 0 t.references :user t.timestamps end diff --git a/db/migrate/20240408010233_create_action_templates.rb b/db/migrate/20240408010233_create_action_templates.rb index 47d335094..1b4c985d2 100644 --- a/db/migrate/20240408010233_create_action_templates.rb +++ b/db/migrate/20240408010233_create_action_templates.rb @@ -4,7 +4,7 @@ class CreateActionTemplates < ActiveRecord::Migration[5.2] t.string :name t.string :description t.string :img - t.string :sort_no, default: 0 + t.integer :sort_no, default: 0 t.text :json t.text :yaml t.timestamps diff --git a/db/migrate/20240514121788_create_action_pipelines.rb b/db/migrate/20240514121788_create_action_pipelines.rb new file mode 100644 index 000000000..b453c3943 --- /dev/null +++ b/db/migrate/20240514121788_create_action_pipelines.rb @@ -0,0 +1,23 @@ +class CreateActionPipelines < ActiveRecord::Migration[5.2] + def change + create_table :action_pipelines do |t| + t.references :project + t.references :user + t.string :pipeline_name + t.string :pipeline_status + t.string :description + t.string :file_name + t.boolean :is_graphic_design, default: false + t.string :repo_name + t.string :repo_identifier + t.string :repo_owner + t.string :branch + t.string :event + t.string :sha + t.text :json + t.text :yaml + t.boolean :disable, default: false + t.timestamps + end + end +end