From 7ca7e4d54163e79beb48a0e791ef6c2163f45b89 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 3 Jul 2021 13:16:43 +1200 Subject: [PATCH] dev/core#2659 Move group cleanup to latest release --- .github/workflows/regen.yml | 117 ++++++++++++++++++ .../Incremental/php/FiveThirtyNine.php | 64 +++++++--- CRM/Upgrade/Incremental/php/FiveTwenty.php | 42 ------- 3 files changed, 166 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/regen.yml diff --git a/.github/workflows/regen.yml b/.github/workflows/regen.yml new file mode 100644 index 000000000000..33a041f382ed --- /dev/null +++ b/.github/workflows/regen.yml @@ -0,0 +1,117 @@ +# Helper to run bin/regen.sh to regenerate civicrm_generated.mysql +# 1. In your civicrm-core fork on github.com, click on the Actions tab. +# 2. Click on Regen on the left. +# 3. On the right you'll see a dropdown "Run workflow". +# 4. From the Branch field in the dropdown pick your branch. +# 5. Optionally choose to have it add a commit with the new file to your branch at the end, otherwise it will give you the file to download. +# Note it does not autosquash but typically this would be done at the end and is acceptable as its own commit. +# 6. Wait about 2-3 minutes until the spinning yellow turns green. +# 7. If you didn't choose to commit, then to get to the download click on the green. +# 7. Scroll down to Artifacts. +# 8. There's your file available for download. +name: Regen +on: + workflow_dispatch: + inputs: + civiver: + description: CiviCRM version + required: true + default: 'master' + autocommit: + description: Autocommit to branch (y or n) + required: false + default: 'n' +jobs: + runregen: + runs-on: ubuntu-latest + name: Run Regen + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: no + MYSQL_DATABASE: db + MYSQL_ROOT_PASSWORD: passpasspw + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + steps: + - uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, soap, intl, gd, exif, iconv + coverage: none + tools: composer:v2 + - name: Sanity check + run: | + if [ "$GITHUB_REPOSITORY" = "civicrm/civicrm-core" ]; then + echo "You need to run this in your own fork." + exit -1 + fi + - name: Download cv + run: | + cd $GITHUB_WORKSPACE + git clone https://github.com/civicrm/cv.git civicrm-cv + cd civicrm-cv + # downloads-plugin is locked at 2.1 but that doesn't work with composer v2 + rm composer.lock + COMPOSER_MEMORY_LIMIT=-1 composer install + - name: Download and install stuff + run: | + cd $GITHUB_WORKSPACE + export DRUPVER=`php -r '$xml = simplexml_load_file("https://updates.drupal.org/release-history/drupal/7.x"); echo $xml->releases[0]->release->version;'` + curl -L -o drupal.tgz https://ftp.drupal.org/files/projects/drupal-$DRUPVER.tar.gz + tar xzf drupal.tgz + mv drupal-$DRUPVER drupal + cd drupal + composer require drush/drush:'^8' + ./vendor/drush/drush/drush -y -l http://civi.localhost site-install standard --db-url='mysql://root:passpasspw@127.0.0.1:${{ job.services.mysql.ports[3306] }}/db' --site-name=TestCivi --account-pass=admin + chmod +w sites/default + cd sites/all/modules + # check out my fork's branch as selected from the dropdown + BRANCHNAME=${GITHUB_REF##*/} + echo "Cloning branch $BRANCHNAME from $GITHUB_SERVER_URL/$GITHUB_REPOSITORY" + git clone -b $BRANCHNAME --depth 1 $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git civicrm + cd civicrm + git clone -b 7.x-${{ github.event.inputs.civiver }} --depth 1 https://github.com/civicrm/civicrm-drupal.git drupal + git clone -b ${{ github.event.inputs.civiver }} --depth 1 https://github.com/civicrm/civicrm-packages.git packages + COMPOSER_MEMORY_LIMIT=-1 composer install + npm install + cd xml + php GenCode.php + cd .. + $GITHUB_WORKSPACE/civicrm-cv/bin/cv core:install --cms-base-url=http://civi.localhost + # In this environment in this particular repo, we are under a workspace folder that contains the literal "civicrm-core" in the path, which makes civicrm.config.php think we are a composer install, so it gets the paths wrong. + echo ' settings_location.php + - name: regen + run: | + cd $GITHUB_WORKSPACE/drupal/sites/all/modules/civicrm/bin + export PATH=$PATH:$GITHUB_WORKSPACE/drupal/vendor/drush/drush + cp setup.conf.txt setup.conf + sed -i -e "s#CIVISOURCEDIR=#CIVISOURCEDIR=$GITHUB_WORKSPACE/drupal/sites/all/modules/civicrm#" setup.conf + sed -i -e 's/DBUSER=/DBUSER=root/' setup.conf + sed -i -e 's/DBPASS=/DBPASS=passpasspw/' setup.conf + sed -i -e 's/DBNAME=/DBNAME=db/' setup.conf + sed -i -e 's/DBHOST=/DBHOST=127.0.0.1/' setup.conf + sed -i -e 's/DBPORT=/DBPORT=${{ job.services.mysql.ports[3306] }}/' setup.conf + sed -i -e 's/GENCODE_CMS=""/GENCODE_CMS=Drupal/' setup.conf + # next two lines just make it easier to see what's going on if it fails + cat setup.conf + sed -i -e 's/set -e/set -e\nset -x/' setup.sh + cd .. + bin/regen.sh + - name: maybe commit + if: ${{ success() && github.event.inputs.autocommit == 'y' }} + run: | + cd $GITHUB_WORKSPACE/drupal/sites/all/modules/civicrm + git config --global user.name "$GITHUB_ACTOR" + git config --global user.email "regen@civicrm.org" + # We don't use `-a` because often there's other files that get spurious updates like composer.lock + git commit -m "regenerate civicrm_generated" sql/civicrm_generated.mysql + git remote add mine https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git + git push mine + - uses: actions/upload-artifact@v2 + if: ${{ success() }} + with: + name: the_file_you_requested + path: '/home/runner/work/civicrm-core/civicrm-core/drupal/sites/all/modules/civicrm/sql/civicrm_generated.mysql' diff --git a/CRM/Upgrade/Incremental/php/FiveThirtyNine.php b/CRM/Upgrade/Incremental/php/FiveThirtyNine.php index 4ad6125a3954..7d668819f1df 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirtyNine.php +++ b/CRM/Upgrade/Incremental/php/FiveThirtyNine.php @@ -55,21 +55,55 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { * (change the x in the function name): */ - // /** - // * Upgrade function. - // * - // * @param string $rev - // */ - // public function upgrade_5_0_x($rev) { - // $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); - // $this->addTask('Do the foo change', 'taskFoo', ...); - // // Additional tasks here... - // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex. - // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable. - // } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_5_39_0($rev) { + $this->addTask('Update smart groups to rename filters on case_from and case_to to case_start_date and case_end_date', 'updateSmartGroups', [ + 'renameField' => [ + ['old' => 'case_from_relative', 'new' => 'case_start_date_relative'], + ['old' => 'case_from_start_date_high', 'new' => 'case_start_date_high'], + ['old' => 'case_from_start_date_low', 'new' => 'case_start_date_low'], + ['old' => 'case_to_relative', 'new' => 'case_end_date_relative'], + ['old' => 'case_to_end_date_high', 'new' => 'case_end_date_high'], + ['old' => 'case_to_end_date_low', 'new' => 'case_end_date_low'], + ['old' => 'mailing_date_relative', 'new' => 'mailing_job_start_date_relative'], + ['old' => 'mailing_date_high', 'new' => 'mailing_job_start_date_high'], + ['old' => 'mailing_date_low', 'new' => 'mailing_job_start_date_low'], + ['old' => 'relation_start_date_low', 'new' => 'relationship_start_date_low'], + ['old' => 'relation_start_date_high', 'new' => 'relationship_start_date_high'], + ['old' => 'relation_start_date_relative', 'new' => 'relationship_start_date_relative'], + ['old' => 'relation_end_date_low', 'new' => 'relationship_end_date_low'], + ['old' => 'relation_end_date_high', 'new' => 'relationship_end_date_high'], + ['old' => 'relation_end_date_relative', 'new' => 'relationship_end_date_relative'], + ['old' => 'event_start_date_low', 'new' => 'event_low'], + ['old' => 'event_end_date_high', 'new' => 'event_high'], + ], + ]); + $this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [ + 'datepickerConversion' => [ + 'birth_date', + 'deceased_date', + 'case_start_date', + 'case_end_date', + 'mailing_job_start_date', + 'relationship_start_date', + 'relationship_end_date', + 'event', + 'relation_active_period_date', + 'created_date', + 'modified_date', + ], + ]); - // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) { - // return TRUE; - // } + $this->addTask('Convert Log date searches to their final names either created date or modified date', 'updateSmartGroups', [ + 'renameLogFields' => [], + ]); + $this->addTask('Convert Custom data based smart groups from jcalendar to datepicker', 'updateSmartGroups', [ + 'convertCustomSmartGroups' => NULL, + ]); + } } diff --git a/CRM/Upgrade/Incremental/php/FiveTwenty.php b/CRM/Upgrade/Incremental/php/FiveTwenty.php index 4087b441359d..4ba3102d981c 100644 --- a/CRM/Upgrade/Incremental/php/FiveTwenty.php +++ b/CRM/Upgrade/Incremental/php/FiveTwenty.php @@ -93,49 +93,7 @@ public function upgrade_5_20_alpha1($rev) { } $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); $this->addTask('Add "Template" contribution status', 'templateStatus'); - $this->addTask('Update smart groups to rename filters on case_from and case_to to case_start_date and case_end_date', 'updateSmartGroups', [ - 'renameField' => [ - ['old' => 'case_from_relative', 'new' => 'case_start_date_relative'], - ['old' => 'case_from_start_date_high', 'new' => 'case_start_date_high'], - ['old' => 'case_from_start_date_low', 'new' => 'case_start_date_low'], - ['old' => 'case_to_relative', 'new' => 'case_end_date_relative'], - ['old' => 'case_to_end_date_high', 'new' => 'case_end_date_high'], - ['old' => 'case_to_end_date_low', 'new' => 'case_end_date_low'], - ['old' => 'mailing_date_relative', 'new' => 'mailing_job_start_date_relative'], - ['old' => 'mailing_date_high', 'new' => 'mailing_job_start_date_high'], - ['old' => 'mailing_date_low', 'new' => 'mailing_job_start_date_low'], - ['old' => 'relation_start_date_low', 'new' => 'relationship_start_date_low'], - ['old' => 'relation_start_date_high', 'new' => 'relationship_start_date_high'], - ['old' => 'relation_start_date_relative', 'new' => 'relationship_start_date_relative'], - ['old' => 'relation_end_date_low', 'new' => 'relationship_end_date_low'], - ['old' => 'relation_end_date_high', 'new' => 'relationship_end_date_high'], - ['old' => 'relation_end_date_relative', 'new' => 'relationship_end_date_relative'], - ['old' => 'event_start_date_low', 'new' => 'event_low'], - ['old' => 'event_end_date_high', 'new' => 'event_high'], - ], - ]); - $this->addTask('Convert Log date searches to their final names either created date or modified date', 'updateSmartGroups', [ - 'renameLogFields' => [], - ]); - $this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [ - 'datepickerConversion' => [ - 'birth_date', - 'deceased_date', - 'case_start_date', - 'case_end_date', - 'mailing_job_start_date', - 'relationship_start_date', - 'relationship_end_date', - 'event', - 'relation_active_period_date', - 'created_date', - 'modified_date', - ], - ]); $this->addTask('Clean up unused table "civicrm_persistent"', 'dropTableIfEmpty', 'civicrm_persistent'); - $this->addTask('Convert Custom data based smart groups from jcalendar to datepicker', 'updateSmartGroups', [ - 'convertCustomSmartGroups' => NULL, - ]); } public static function templateStatus(CRM_Queue_TaskContext $ctx) {