From 991fbabd955efd8e0223840a3d505a3addd863d5 Mon Sep 17 00:00:00 2001 From: "Yuya.Nishida" Date: Sat, 26 Oct 2024 17:21:29 +0900 Subject: [PATCH 1/6] ci: change base branch from develop to yuya-develop - create patch from yuya-develop branch - ignore run on patch workflows when yuya-develop branch --- .github/workflows/comment-patch.yml | 1 + .github/workflows/create-patch.yml | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-patch.yml b/.github/workflows/comment-patch.yml index 0bdcb1d602..46f92567f4 100644 --- a/.github/workflows/comment-patch.yml +++ b/.github/workflows/comment-patch.yml @@ -9,6 +9,7 @@ on: branches-ignore: - master - develop + - yuya-develop jobs: create-patch: diff --git a/.github/workflows/create-patch.yml b/.github/workflows/create-patch.yml index 87acdd8e8c..a6ebc4a4f8 100644 --- a/.github/workflows/create-patch.yml +++ b/.github/workflows/create-patch.yml @@ -5,6 +5,7 @@ on: branches-ignore: - master - develop + - yuya-develop jobs: create-patch: @@ -18,12 +19,12 @@ jobs: git config user.email "$AUTHOR_EMAIL" git config user.name "$AUTHOR_NAME" git rev-parse --abbrev-ref HEAD > .branch-name - git checkout develop + git checkout yuya-develop git checkout -b patch git merge --squash `cat .branch-name` git commit -m "Patch for `cat .branch-name`" PATCH_FILE=`cat .branch-name | sed 's/\//_/g'`.patch # Replace forward slash in branch name with _ - git format-patch develop..HEAD --stdout -k > $PATCH_FILE + git format-patch yuya-develop..HEAD --stdout -k > $PATCH_FILE echo "::set-output name=PATCH_FILE::$PATCH_FILE" id: patch-creator env: From dc298468102961165e9ee646b62d8eaf36401f90 Mon Sep 17 00:00:00 2001 From: "Yuya.Nishida" Date: Sat, 26 Oct 2024 17:31:03 +0900 Subject: [PATCH 2/6] chore: fix rubocop --- Guardfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Guardfile b/Guardfile index 2ee21bd185..cf95b57067 100644 --- a/Guardfile +++ b/Guardfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + guard :minitest, all_on_start: false do watch(%r{^test/(.*)test(.*)\.rb$}) end From 5e5900f4ebd05726f9b2b3e27d6d4453070189a1 Mon Sep 17 00:00:00 2001 From: "Yuya.Nishida" Date: Sat, 26 Oct 2024 17:26:26 +0900 Subject: [PATCH 3/6] ci: bump ruby version --- .github/workflows/rubyonrails.yml | 2 +- .github/workflows/test.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml index 07882bdc87..1fe621e586 100644 --- a/.github/workflows/rubyonrails.yml +++ b/.github/workflows/rubyonrails.yml @@ -11,7 +11,7 @@ jobs: - name: Install Ruby and gems uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 with: - ruby-version: 3.2 + ruby-version: 3.3 bundler-cache: true - name: Lint Ruby files run: bundle exec rubocop --parallel diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a2c8c70972..f6b3bd1b47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['2.7', '3.0', '3.1', '3.2'] + ruby: ['3.1', '3.2', '3.3'] db_version: [5.7] runs-on: ubuntu-latest container: @@ -40,7 +40,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['2.7', '3.0', '3.1', '3.2'] + ruby: ['3.1', '3.2', '3.3'] db_version: [10] runs-on: ubuntu-latest container: @@ -74,7 +74,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ['2.7', '3.0', '3.1', '3.2'] + ruby: ['3.1', '3.2', '3.3'] runs-on: ubuntu-latest container: image: ruby:${{ matrix.ruby }} From 707da64cb3a7ca782c8f89aeb3f6c07a8c6d3d8a Mon Sep 17 00:00:00 2001 From: "Yuya.Nishida" Date: Sat, 26 Oct 2024 16:30:34 +0900 Subject: [PATCH 4/6] ci: use latest NodeJS run: git cococo sed -i -e 's|actions/checkout@v2|actions/checkout@v4|g' .github/workflows/comment-patch.yml .github/workflows/create-patch.yml .github/workflows/rubyonrails.yml .github/workflows/test.yml run: git cococo sed -i -e 's|actions/upload-artifact@v2|actions/upload-artifact@v4|g' .github/workflows/comment-patch.yml .github/workflows/create-patch.yml .github/workflows/rubyonrails.yml .github/workflows/test.yml --- .github/workflows/comment-patch.yml | 2 +- .github/workflows/create-patch.yml | 4 ++-- .github/workflows/rubyonrails.yml | 2 +- .github/workflows/test.yml | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/comment-patch.yml b/.github/workflows/comment-patch.yml index 46f92567f4..fb3f1b558f 100644 --- a/.github/workflows/comment-patch.yml +++ b/.github/workflows/comment-patch.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Install gems run: sudo gem install faraday - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Comment Patch URL run: ./.github/actions/comment_patch_url.rb env: diff --git a/.github/workflows/create-patch.yml b/.github/workflows/create-patch.yml index a6ebc4a4f8..f893ca9962 100644 --- a/.github/workflows/create-patch.yml +++ b/.github/workflows/create-patch.yml @@ -11,7 +11,7 @@ jobs: create-patch: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Create Patch @@ -30,7 +30,7 @@ jobs: env: AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }} AUTHOR_NAME: ${{ github.event.head_commit.author.name }} - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: patch path: ${{ steps.patch-creator.outputs.PATCH_FILE }} diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml index 1fe621e586..3b1ec5388a 100644 --- a/.github/workflows/rubyonrails.yml +++ b/.github/workflows/rubyonrails.yml @@ -9,7 +9,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Install Ruby and gems - uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 + uses: ruby/setup-ruby@v1.197.0 with: ruby-version: 3.3 bundler-cache: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f6b3bd1b47..4b68ff10c8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: ports: - 3306:3306 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache gems uses: actions/cache@v2 with: @@ -57,7 +57,7 @@ jobs: # needed because the postgres container does not provide a healthcheck options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache gems uses: actions/cache@v2 with: @@ -79,7 +79,7 @@ jobs: container: image: ruby:${{ matrix.ruby }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache gems uses: actions/cache@v2 with: From 288a6c1f37dc31be2349807032857c96630194da Mon Sep 17 00:00:00 2001 From: "Yuya.Nishida" Date: Sun, 27 Oct 2024 16:53:59 +0900 Subject: [PATCH 5/6] ci: follow database versions https://www.redmine.org/projects/redmine/wiki/Continuous_integration/15 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4b68ff10c8..501eb9e064 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: ruby: ['3.1', '3.2', '3.3'] - db_version: [5.7] + db_version: [8.0] runs-on: ubuntu-latest container: image: ruby:${{ matrix.ruby }} @@ -41,7 +41,7 @@ jobs: fail-fast: false matrix: ruby: ['3.1', '3.2', '3.3'] - db_version: [10] + db_version: [14] runs-on: ubuntu-latest container: image: ruby:${{ matrix.ruby }} From 3b1d76fa168da19e5bd160e48c777f7bc15087bd Mon Sep 17 00:00:00 2001 From: "Yuya.Nishida" Date: Sun, 27 Oct 2024 17:34:36 +0900 Subject: [PATCH 6/6] Fix lost backward compatibility about ProjectQuery#results_scope's return type --- app/models/project.rb | 19 +++++++++---------- app/models/project_query.rb | 8 +------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index c438be16d4..5ebae22a2a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -382,6 +382,7 @@ def reload(*args) @override_members = nil @assignable_users = nil @last_activity_date = nil + self.class.clear_last_activities base_reload(*args) end @@ -1009,18 +1010,16 @@ def visible_custom_field_values(user = nil) end end - def last_activity_date - @last_activity_date || fetch_last_activity_date + def self.last_activities + @last_activities ||= Redmine::Activity::Fetcher.new(User.current).events(nil, nil, :last_by_project => true).to_h end - # Preloads last activity date for a collection of projects - def self.load_last_activity_date(projects, user=User.current) - if projects.any? - last_activities = Redmine::Activity::Fetcher.new(User.current).events(nil, nil, :last_by_project => true).to_h - projects.each do |project| - project.instance_variable_set(:@last_activity_date, last_activities[project.id]) - end - end + def self.clear_last_activities + @last_activities = nil + end + + def last_activity_date + self.class.last_activities[id] || fetch_last_activity_date end private diff --git a/app/models/project_query.rb b/app/models/project_query.rb index a1bb52a2cf..4a054ed5af 100644 --- a/app/models/project_query.rb +++ b/app/models/project_query.rb @@ -165,12 +165,6 @@ def results_scope(options={}) if has_column?(:parent_id) scope = scope.preload(:parent) end - - projects = scope.to_a - if has_column?(:last_activity_date) - Project.load_last_activity_date(scope) - end - - projects + scope end end