From b4108874b843476fabb91a2ef551122fb906b59f Mon Sep 17 00:00:00 2001 From: Formasitchijoh Date: Tue, 14 Jan 2025 14:39:43 +0100 Subject: [PATCH 1/5] Fix ImageMagick compatibility for Paperclip by installing imagemagick in CI, creating symlinks, updating paths, and caching binaries --- .github/workflows/ci.yml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95f823c302..70a332604a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,32 @@ jobs: with: pandoc-version: '2.9.2.1' + - name: install ImageMagick + uses: mfinelli/setup-imagemagick@v6 + with: + cache: true + + # Cache ImageMagick binaries + - name: Cache Latest ImageMagick + uses: actions/cache@v3 + with: + path: /home/runner/bin/magick + key: ${{ runner.os }}-imagemagick-latest + restore-keys: | + ${{ runner.os }}-imagemagick-latest + + # Update PATH for ImageMagick + - name: Update PATH for ImageMagick + run: echo "/home/runner/bin" >> $GITHUB_PATH + + - name: Create symlink for identify and convert + run: | + for cmd in identify convert; do + if ! [ -x "$(command -v $cmd)" ]; then + sudo ln -s $(which magick) /usr/bin/$cmd + fi + done + - name: setup Redis uses: supercharge/redis-github-action@1.4.0 @@ -91,4 +117,4 @@ jobs: if-no-files-found: ignore - name: Ruby linting - run: bundle exec rubocop + run: bundle exec rubocop \ No newline at end of file From fc684e220b616df57086b23963df2b8ef0424b91 Mon Sep 17 00:00:00 2001 From: Formasitchijoh Date: Tue, 14 Jan 2025 14:42:55 +0100 Subject: [PATCH 2/5] =?UTF-8?q?Set=20Paperclip=E2=80=99s=20command=20path?= =?UTF-8?q?=20to=20/usr/bin=20in=20test=20environment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/environments/test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/environments/test.rb b/config/environments/test.rb index 086d2a3ccc..3900247e72 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -54,6 +54,8 @@ def dump_js_coverage # Settings specified here will take # precedence over those in config/application.rb. + Paperclip.options[:command_path] = "/usr/bin" + # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped From f8c72f60f746e6337d7d305ae684287dad5888e3 Mon Sep 17 00:00:00 2001 From: Formasitchijoh Date: Tue, 7 Jan 2025 08:35:58 +0100 Subject: [PATCH 3/5] fix: updated directory for saving screenshot --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95f823c302..e7bb66f24d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,7 +87,7 @@ jobs: if: failure() with: name: dist-without-markdown - path: tmp/capybara/*.png + path: tmp/screenshots/*.png if-no-files-found: ignore - name: Ruby linting From 5840b6025e803775b63fd3e18ab7fba2ad463838 Mon Sep 17 00:00:00 2001 From: Abishek Das Date: Tue, 14 Jan 2025 20:51:44 +0530 Subject: [PATCH 4/5] Fix: Prevent state mutation in course wikis update logic - Replaced direct mutation of "props.course.wikis" using ".push()" with an immutable update by dispatching the updated state. - Moved the dispatch logic into "useEffect" to avoid React warnings about state updates during render. - Resolves Redux error: "A state mutation was detected between dispatches, in the path 'course.wikis.o' " --- .../components/course_creator/course_form.jsx | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/components/course_creator/course_form.jsx b/app/assets/javascripts/components/course_creator/course_form.jsx index c7230ec749..4fba63d553 100644 --- a/app/assets/javascripts/components/course_creator/course_form.jsx +++ b/app/assets/javascripts/components/course_creator/course_form.jsx @@ -1,4 +1,5 @@ -import React from 'react'; +import React, { useEffect } from 'react'; +import { useDispatch } from 'react-redux'; import { Link } from 'react-router-dom'; import TextAreaInput from '../common/text_area_input.jsx'; import CreatableInput from '../common/creatable_input.jsx'; @@ -12,6 +13,7 @@ import selectStyles from '../../styles/select'; import WikiSelect from '../common/wiki_select.jsx'; import AcademicSystem from '../common/academic_system.jsx'; import WIKI_OPTIONS from '../../utils/wiki_options'; +import { updateCourse } from '@actions/course_actions.js'; const CourseForm = (props) => { const handleWikiChange = (wiki) => { @@ -31,6 +33,15 @@ const CourseForm = (props) => { props.updateCourseProps({ wikis }); }; + const dispatch = useDispatch(); + + useEffect(() => { + if (props.course.wikis && !props.course.wikis.length) { + dispatch(updateCourse({ wikis: [{ language: 'en', project: 'wikipedia' }] })); + } + }, []); + + let term; let courseSubject; let expectedStudents; @@ -133,17 +144,11 @@ const CourseForm = (props) => { ); } - - let privacyCheckbox; let campaign; let home_wiki; let multi_wiki; - if (props.course.wikis && !props.course.wikis.length) { - props.course.wikis.push({ language: 'en', project: 'wikipedia' }); - } - if (props.defaultCourse !== 'ClassroomProgramCourse') { home_wiki = (
@@ -181,6 +186,7 @@ const CourseForm = (props) => { /> ); } + if (props.course.initial_campaign_title) { campaign = ( { /> ); } + let backCondition; + if (Features.wikiEd) { backCondition = props.previousWikiEd; } else { @@ -198,15 +206,15 @@ const CourseForm = (props) => { let backOrCancelButton; -// Displays "Back" button if the user has clonable courses or is on the P&E dashboard; otherwise shows "Cancel" link. -if (props.hasClonableCourses || props.defaultCourse !== 'ClassroomProgramCourse') { - backOrCancelButton = ( - - ); - } else { - backOrCancelButton = ( - {I18n.t('application.cancel')} - ); + // Displays "Back" button if the user has clonable courses or is on the P&E dashboard; otherwise shows "Cancel" link. + if (props.hasClonableCourses || props.defaultCourse !== 'ClassroomProgramCourse') { + backOrCancelButton = ( + + ); + } else { + backOrCancelButton = ( + {I18n.t('application.cancel')} + ); } return ( From f75b30509a73fc4096c1d07e1ef2716b4c637a5c Mon Sep 17 00:00:00 2001 From: gabina Date: Fri, 17 Jan 2025 16:52:53 -0300 Subject: [PATCH 5/5] Fix linting --- app/services/copy_course.rb | 7 +++---- app/services/update_course_wiki_timeslices.rb | 9 ++++----- lib/revision_data_manager.rb | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/services/copy_course.rb b/app/services/copy_course.rb index fb277287fb..3f20c24c54 100644 --- a/app/services/copy_course.rb +++ b/app/services/copy_course.rb @@ -92,10 +92,9 @@ def copy_tracked_categories_data end def maybe_copy_user_data - if @user_data.present? && @user_data != '0' - @users_data = retrieve_users_data - copy_users_data - end + return unless @user_data.present? && @user_data != '0' + @users_data = retrieve_users_data + copy_users_data end def copy_users_data diff --git a/app/services/update_course_wiki_timeslices.rb b/app/services/update_course_wiki_timeslices.rb index e1e35fa8c7..e5795d37e1 100644 --- a/app/services/update_course_wiki_timeslices.rb +++ b/app/services/update_course_wiki_timeslices.rb @@ -92,11 +92,10 @@ def fetch_data(wiki, timeslice_start, timeslice_end) update_service: self) # Only for wikidata project, fetch wikidata stats - if wiki.project == 'wikidata' && @revisions.present? - wikidata_revisions = @revisions[wiki][:revisions].reject(&:deleted) - @revisions[wiki][:revisions] = - @wikidata_stats_updater.update_revisions_with_stats(wikidata_revisions) - end + return unless wiki.project == 'wikidata' && @revisions.present? + wikidata_revisions = @revisions[wiki][:revisions].reject(&:deleted) + @revisions[wiki][:revisions] = + @wikidata_stats_updater.update_revisions_with_stats(wikidata_revisions) # TODO: replace the logic on ArticlesCourses.update_from_course to remove all # the ArticlesCourses that do not correspond to course revisions. # That may happen if the course dates changed, so some revisions are no diff --git a/lib/revision_data_manager.rb b/lib/revision_data_manager.rb index 5849b83838..ce5ca53b71 100644 --- a/lib/revision_data_manager.rb +++ b/lib/revision_data_manager.rb @@ -22,7 +22,7 @@ def initialize(wiki, course, update_service: nil) # As a side effect, it imports Article records. def fetch_revision_data_for_course(timeslice_start, timeslice_end) all_sub_data, scoped_sub_data = get_course_revisions(@course.students, timeslice_start, - timeslice_end) + timeslice_end) @revisions = [] # Extract all article data from the slice. Outputs a hash with article attrs.