diff --git a/.workflow/check_run-pipeline.yml b/.workflow/check_run-pipeline.yml index 8e15c24c67f586e878960c3cd4eed204b485722c..5302b06757398f3922d96e8b641c06b6a4538a42 100644 --- a/.workflow/check_run-pipeline.yml +++ b/.workflow/check_run-pipeline.yml @@ -14,6 +14,10 @@ stages: - Int: - echo `ruby -v` - echo `pwd` + - APT GET: + - apt-get update + - apt-get install cmake + - apt-get install pkg-config - Install RubyENV: - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ - gem install rest-client @@ -21,12 +25,12 @@ stages: - gem install base64 - gem install rubocop -v0.81.0 - gem install rubocop-performance - - gem install pronto - - gem install pronto-rubocop + - gem install pronto -v0.11.0 + - gem install pronto-rubocop -v0.11.0 - Run Script: - git fetch https://gitee.com/${AGILE_MODULE_NAME}.git pull/${AGILE_PULL_ID}/head:pr_${AGILE_PULL_ID} - - git check pr_${AGILE_PULL_ID} + - git checkout pr_${AGILE_PULL_ID} - ruby "./script/rubocop_check.rb" ${AGILE_MODULE_NAME} ${AGILE_SOURCE_REVISION} ${AGILE_REVISION} ${AGILE_PULL_ID} ${ACCESS_TOKEN} triggers: pr: diff --git a/app/models/program.rb b/app/models/program.rb new file mode 100644 index 0000000000000000000000000000000000000000..7ea7e1adb299b243bb16956e3a813b998ead8992 --- /dev/null +++ b/app/models/program.rb @@ -0,0 +1,45 @@ +class Program < ActiveRecord::Base + acts_as_cached(:version => 3, :expires_in => 1.day) + attr_accessible :name, :description, :assignee_id, :author_id, :outsourced, :user_ids, :project_ids, + + validates :name, presence: true, length: { maximum: 191 } + + validate :validate_category + belongs_to :assignee, class_name: 'User' #liwen test + + STANDARD = 'standard' #常规项目 + SCRUM = 'scrum' # scrum项目 + CATEGORIES = [STANDARD, SCRUM] + + class << self + def fuzzy_search(keyword) + keyword.strip! + where('`programs`.name LIKE :name', name: "%#{keyword}%") + end + end + + def is_assignee?(user_id) + user_id == assignee_id + end + + def is_scrum? + SCRUM == category + end + + # 生成项目编号 + def generate_ident + ident = enterprise.enterprise_info.lastest_ident + end + + def kafka_topic_key + "#{self.class.name}-#{self.id}" + end + + protected + + def format_content + self.outsourced ||= 0 + self.status ||= 0 + end + +end diff --git a/app/models/scrum_sprint_member.rb b/app/models/scrum_sprint_member.rb new file mode 100644 index 0000000000000000000000000000000000000000..360660de5938b8a1d36164d01897e7161005b7b8 --- /dev/null +++ b/app/models/scrum_sprint_member.rb @@ -0,0 +1,17 @@ +class ScrumSprintMember < ActiveRecord::Base + MEMBER = 1 + ASSIGNEE = 2 + ROLE_LEVELS = [MEMBER, ASSIGNEE] + + validates_uniqueness_of :user_id, scope: :scrum_sprint_id + validate :validate_role_level + + private + + def validate_role_level + return unless role_level_changed? + return if ROLE_LEVELS.include?(role_level) + + errors.add(:role_level, :error) + end +end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index cd03da41b27efaf2f7d97f6ae6f917b363c8144c..ff6f7fdb4db4947819619a2cb6224aa6ebc1d6b9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,13 +1,3 @@ class User < ApplicationRecord end -# == Schema Information -# -# Table name: users -# -# id :bigint(8) not null, primary key -# email :string -# name :string -# created_at :datetime not null -# updated_at :datetime not null -# diff --git a/script/rubocop_check.rb b/script/rubocop_check.rb index 1bb2e7f9ccd3698d9d1877f0ab9524d60c64e3c3..706c8077154678693b27a4faa73af67ece4b13e1 100644 --- a/script/rubocop_check.rb +++ b/script/rubocop_check.rb @@ -70,10 +70,14 @@ class RubocopAnalysis start_line = file.line.new_lineno end_line = file.line.new_lineno - message, *suggestion = file.msg.split("\n") + if file.msg.include?("suggestion") + message, suggestion = file.msg.match(/(.*)(\n\n```suggestion\n.*\n```)*/)&.captures + else + message = file.msg + end annotation_level = annotation_level_list[file.level] - unless suggestion.empty? - body = "Rubocop suggestion#{suggestion.join("\n")}" + unless suggestion.nil? + body = "Rubocop suggestion#{suggestion}" can_insert, suggestion = can_insert_suggestion?(file, body) suggestions.push(suggestion) if can_insert end @@ -116,8 +120,8 @@ class RubocopAnalysis body: body, access_token: @access_token, path: file.path, - # position: file.line.commit_line.position, - position: file.line.commit_line.position + 1, + position: file.line.commit_line.position, + # position: file.line.commit_line.position + 1, commit_id: file.commit_sha } if get_exists_suggestions.find{|s| s[:path] == file.path && file.msg.include?(s[:body][20..-1]) && s[:commit_id] == file.commit_sha && s[:new_line] == file.line.new_lineno}.nil?