diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1477ea2..6da4321 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,22 +3,21 @@ on: branches: - main - master - - availability pull_request: branches: - main - master - - availability name: tests jobs: setup: name: setup - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Slack Notification on Start uses: rtCamp/action-slack-notify@v2.2.0 + if: env.SLACK_WEBHOOK != '' env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests @@ -28,7 +27,7 @@ jobs: tests: name: tests needs: setup - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest strategy: matrix: php: [ '7.1', '7.2', '7.3', '7.4' ] @@ -44,10 +43,14 @@ jobs: MYSQL_VERSION: ${{ matrix.mysql }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: cakephp_test + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 + - name: Fix up git URLs + run: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig + - name: environment run: | echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" @@ -58,7 +61,7 @@ jobs: - name: docker-compose install run: | - curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose + curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose chmod +x ~/docker-compose sudo mv ~/docker-compose /usr/local/bin/docker-compose docker-compose --version @@ -88,46 +91,53 @@ jobs: docker-compose exec -T nc3app bash /opt/scripts/app-build.sh - name: phpcs (PHP CodeSniffer) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpcs.sh - name: phpmd (PHP Mess Detector) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpmd.sh - name: phpcpd (PHP Copy/Paste Detector) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpcpd.sh - name: gjslint (JavaScript Style Check) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/gjslint.sh - name: phpdoc (PHP Documentor) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpdoc.sh - name: phpunit (PHP UnitTest) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpunit.sh sudo -s chmod a+w -R ${NC3_BUILD_DIR}/build - - name: push coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_FLAG_NAME: ${{ matrix.php }} - run: | - cd ${NC3_BUILD_DIR} - ls -la ${NC3_BUILD_DIR} - vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v +# - name: push coveralls +# env: +# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# COVERALLS_FLAG_NAME: ${{ matrix.php }} +# run: | +# cd ${NC3_BUILD_DIR} +# ls -la ${NC3_BUILD_DIR} +# vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v - name: docker-compose remove + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose rm -f @@ -135,7 +145,7 @@ jobs: # テスト失敗時はこちらのステップが実行される - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.2.0 - if: failure() + if: env.SLACK_WEBHOOK != '' && failure() env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests @@ -144,13 +154,13 @@ jobs: teardown: name: teardown - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest needs: tests steps: # テスト成功時はこちらのステップが実行される - name: Slack Notification on Success - if: success() uses: rtCamp/action-slack-notify@v2.2.0 + if: env.SLACK_WEBHOOK != '' && success() env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests diff --git a/Config/Migration/1711535474_update_2024_holidays.php b/Config/Migration/1711535474_update_2024_holidays.php new file mode 100644 index 0000000..57a3312 --- /dev/null +++ b/Config/Migration/1711535474_update_2024_holidays.php @@ -0,0 +1,136 @@ + + * @link http://www.netcommons.org NetCommons Project + * @license http://www.netcommons.org/license.txt NetCommons License + * @copyright Copyright 2014, NetCommons Project + */ + +App::uses('NetCommonsMigration', 'NetCommons.Config/Migration'); +App::uses('CurrentLib', 'NetCommons.Lib'); + +/** + * 令和3年の祝日の修正 + * + * @author Shohei Nakajima + * @package NetCommons\Holidays\Config\Migration + * @see https://github.com/NetCommons3/NetCommons3/issues/1621 + */ +class Update2024Holidays extends NetCommonsMigration { + +/** + * Migration description + * + * @var string + */ + public $description = 'update_2024_holidays'; + +/** + * Actions to be performed + * + * @var array $migration + */ + public $migration = array( + 'up' => array( + ), + 'down' => array( + ), + ); + +/** + * HolidayRruleモデル + * + * @var HolidayRrule + */ + private $__HolidayRrule; + +/** + * Holidayモデル + * + * @var HolidayRrule + */ + private $__Holiday; + +/** + * Before migration callback + * + * @param string $direction Direction of migration process (up or down) + * @return bool Should process continue + */ + public function before($direction) { + $this->__HolidayRrule = ClassRegistry::init('Holidays.HolidayRrule'); + $this->__Holiday = ClassRegistry::init('Holidays.Holiday'); + return true; + } + +/** + * After migration callback + * + * @param string $direction Direction of migration process (up or down) + * @return bool Should process continue + */ + public function after($direction) { + if ($direction === 'up') { + CurrentLib::write('Language.id', 2); + //秋分日の更新 + $this->__updateAutumnalEquinoxDay(); + } + return true; + } + +/** + * 秋分日の更新 + * + * @return void + */ + private function __updateAutumnalEquinoxDay() { + $count = $this->__Holiday->find('count', array( + 'conditions' => array( + 'holiday' => '2024-09-23', + ), + 'recursive' => -1, + )); + if ($count > 0) { + return; + } + + $params = [ + 'HolidayRrule' => [ + 'id' => '146', + 'input_month_day' => [ + 'day' => '22', + 'month' => '9', + ], + 'can_substitute' => '1', + 'is_variable' => '0', + 'week' => '1', + 'day_of_the_week' => 'SU', + 'start_year' => '2024', + 'end_year' => '2024', + ], + 'Holiday' => [ + 2 => [ + 'id' => '', + 'key' => '', + 'language_id' => '2', + 'title' => '秋分の日', + 'is_origin' => true, + 'is_translation' => true, + ], + 1 => [ + 'id' => '', + 'key' => '', + 'language_id' => '1', + 'title' => 'Autumnal Equinox Day', + 'is_origin' => false, + 'is_translation' => true, + ], + ], + ]; + $this->__HolidayRrule->create(null); + $this->__HolidayRrule->saveHolidayRrule($params); + } + +} diff --git a/Config/Migration/1771893343_update_20260922_holiday.php b/Config/Migration/1771893343_update_20260922_holiday.php new file mode 100644 index 0000000..1a57a0e --- /dev/null +++ b/Config/Migration/1771893343_update_20260922_holiday.php @@ -0,0 +1,136 @@ + + * @link http://www.netcommons.org NetCommons Project + * @license http://www.netcommons.org/license.txt NetCommons License + * @copyright Copyright 2014, NetCommons Project + */ + +App::uses('NetCommonsMigration', 'NetCommons.Config/Migration'); +App::uses('CurrentLib', 'NetCommons.Lib'); + +/** + * 「2026/09/26 国民の休日」追加 + * + * @author Shohei Nakajima + * @package NetCommons\Holidays\Config\Migration + * @see https://github.com/NetCommons3/NetCommons3/issues/1621 + */ +class Update20260922Holiday extends NetCommonsMigration { + +/** + * Migration description + * + * @var string + */ + public $description = 'update_20260922_holiday'; + +/** + * Actions to be performed + * + * @var array $migration + */ + public $migration = array( + 'up' => array( + ), + 'down' => array( + ), + ); + +/** + * HolidayRruleモデル + * + * @var HolidayRrule + */ + private $__HolidayRrule; + +/** + * Holidayモデル + * + * @var HolidayRrule + */ + private $__Holiday; + +/** + * Before migration callback + * + * @param string $direction Direction of migration process (up or down) + * @return bool Should process continue + */ + public function before($direction) { + $this->__HolidayRrule = ClassRegistry::init('Holidays.HolidayRrule'); + $this->__Holiday = ClassRegistry::init('Holidays.Holiday'); + return true; + } + +/** + * After migration callback + * + * @param string $direction Direction of migration process (up or down) + * @return bool Should process continue + */ + public function after($direction) { + if ($direction === 'up') { + CurrentLib::write('Language.id', 2); + //秋分日の更新 + $this->__updateAutumnalEquinoxDay(); + } + return true; + } + +/** + * 秋分日の更新 + * + * @return void + */ + private function __updateAutumnalEquinoxDay() { + $count = $this->__Holiday->find('count', array( + 'conditions' => array( + 'holiday' => '2026-09-22', + ), + 'recursive' => -1, + )); + if ($count > 0) { + return; + } + + $params = [ + 'HolidayRrule' => [ + 'id' => '', + 'input_month_day' => [ + 'day' => '22', + 'month' => '9', + ], + 'can_substitute' => '0', + 'is_variable' => '0', + 'week' => '1', + 'day_of_the_week' => 'MO', + 'start_year' => '2026', + 'end_year' => '2026', + ], + 'Holiday' => [ + 2 => [ + 'id' => '', + 'key' => '', + 'language_id' => '2', + 'title' => '国民の休日', + 'is_origin' => true, + 'is_translation' => true, + ], + 1 => [ + 'id' => '', + 'key' => '', + 'language_id' => '1', + 'title' => 'National People\'s Day Holiday', + 'is_origin' => false, + 'is_translation' => true, + ], + ], + ]; + $this->__HolidayRrule->create(null); + $this->__HolidayRrule->saveHolidayRrule($params); + } + +} diff --git a/Model/Holiday.php b/Model/Holiday.php index 4d262be..de37395 100644 --- a/Model/Holiday.php +++ b/Model/Holiday.php @@ -93,12 +93,17 @@ public function isHoliday($date = null) { */ public function getHoliday($from, $to) { $holidays = $this->cacheFindQuery('all', array( + 'fields' => array( + 'Holiday.id', + 'Holiday.holiday', + 'Holiday.title' + ), 'conditions' => array( 'language_id' => Current::read('Language.id'), 'holiday >=' => $from, 'holiday <=' => $to ), - 'recursive' => 0, + 'recursive' => -1, 'order' => array('holiday') )); return $holidays; @@ -120,7 +125,15 @@ public function getHolidayInYear($year = null) { } $from = $year . '-01-01'; $to = $year . '-12-31'; - $holidays = $this->getHoliday($from, $to); + $holidays = $this->Find('all', array( + 'conditions' => array( + 'language_id' => Current::read('Language.id'), + 'holiday >=' => $from, + 'holiday <=' => $to + ), + 'recursive' => 0, + 'order' => array('holiday') + )); return $holidays; } diff --git a/VERSION.txt b/VERSION.txt index fa7adc7..86fb650 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.5 +3.3.7