diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..592d72f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - '3*' + +name: create_release + +jobs: + build: + name: create_release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Slack Notification on Start + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }} + SLACK_CHANNEL: notify-nc3-release + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: "#f0ad4e" + SLACK_MESSAGE: "Start Job" + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + body: | + NetCommons ${{ github.ref }} released. + draft: false + prerelease: false + + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on Finish + uses: rtCamp/action-slack-notify@v2.2.0 + if: success() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }} + SLACK_CHANNEL: notify-nc3-release + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: good + SLACK_MESSAGE: "Job Success" + + # テスト失敗時はこちらのステップが実行される + - name: Slack Notification on Failure + uses: rtCamp/action-slack-notify@v2.2.0 + if: failure() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: danger + SLACK_MESSAGE: "Job Failure" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6da4321 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,168 @@ +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +name: tests + +jobs: + setup: + name: setup + 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 + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: "#f0ad4e" + + tests: + name: tests + needs: setup + runs-on: ubuntu-latest + strategy: + matrix: + php: [ '7.1', '7.2', '7.3', '7.4' ] + mysql: [ '5.7', '8.0' ] + + env: + NC3_BUILD_DIR: "/opt/nc3" + NC3_DOCKER_DIR: "/opt/docker" + NC3_GIT_URL: "git://github.com/NetCommons3/NetCommons3.git" + NC3_GIT_BRANCH: "master" + PLUGIN_BUILD_DIR: ${{ github.workspace }} + PHP_VERSION: ${{ matrix.php }} + 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}" + echo "PLUGIN_BUILD_DIR=${PLUGIN_BUILD_DIR}" + echo "PHP_VERSION=${PHP_VERSION}" + echo "MYSQL_VERSION=${MYSQL_VERSION}" + ls -al ${PLUGIN_BUILD_DIR} + + - name: docker-compose install + run: | + 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 + + - name: git clone nc3 + run: git clone -b ${NC3_GIT_BRANCH} ${NC3_GIT_URL} ${NC3_BUILD_DIR} + + - name: git clone nc3_docker + run: git clone https://github.com/NetCommons3/nc3app-docker.git ${NC3_DOCKER_DIR} + + - name: docker-compose start + run: | + cd ${NC3_DOCKER_DIR} + docker-compose up -d + docker-compose start + + - run: docker ps + + - name: check libraries + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/start-on-docker.sh + + - name: nc3 build + run: | + cd ${NC3_DOCKER_DIR} + 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: docker-compose remove + if: always() + run: | + cd ${NC3_DOCKER_DIR} + docker-compose rm -f + + # テスト失敗時はこちらのステップが実行される + - name: Slack Notification on Failure + uses: rtCamp/action-slack-notify@v2.2.0 + if: env.SLACK_WEBHOOK != '' && failure() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}(php${{ matrix.php }}, mysql${{ matrix.mysql }})" + SLACK_COLOR: danger + + teardown: + name: teardown + runs-on: ubuntu-latest + needs: tests + steps: + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on 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 + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: good diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 62c8424..0000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - -sudo: required - -env: - matrix: - - NETCOMMONS_VERSION=master DB=mysql - global: - - secure: "SmIg7RRMzmInqAsvXdypo4YmL/DMQzT3x5quxcmxqiMlwIyzNA+ETag4hi9/+U6Nmajo7rjEJ6uqUELpmuR6grNZQNTU1fMT59Ay3GGatPc/sHu4yTkwORw8rtsQeCdNAx1IyL4oHGoGA7jjC0IMMMr100VT9iBk+XfpMxWPM7MXx6sJ3nItnmLkjnupQCw+/6QvHHMAe5MdU2L8a9rn2m5q70JoWIE2OR1K8ZapBZzfOdzUw/3S0YXrElJ9ovLzBk+ZvfozKK2Ewn13T8CCL3yQTfL9lnnlBrFZhJeCAzOF0ewfgQ0ERR8U916nchwT3G6dewQhHFXvWTbgMdTJWPYU438by0JS1SIJGkPtzY17lPf9k7tCfoCVp7tO0DgcbclAhnlKLzXG7Oz2L3ri0DEhqVWjO8KKZ3gcr2lI86xdbdPMlcr9cngKsorsn1o45/dqjmTQjisaN7VxH8GsFF0KQgEX9WbwnEx9dV86XY/C1iedCHbXi5OgK8cqr0Xs2TWdxzMDxmre5LLwS3QN4JrMWjM9PkUa4I9UN5VW+BtWkoQv9kiAqlKg6y7DWrP1VAO8U+WZuugpPYJ5BB+//huiij/k7NgtMwPw+1yqkUNLl1LLUrYSE1gPrKZ2X3cYemMvZPaT+Fx4SyGupRbDFVilTTrE/NO8YawBAdG+PcY=" - - GIT_COMMITTER_NAME=s-nakajima - - GIT_COMMITTER_EMAIL=nakajimashouhei@gmail.com - - GIT_AUTHOR_NAME=s-nakajima - - GIT_AUTHOR_EMAIL=nakajimashouhei@gmail.com - -before_script: - - export NETCOMMONS_BUILD_DIR=`dirname $TRAVIS_BUILD_DIR`/NetCommons3 - - git clone git://github.com/NetCommons3/NetCommons3 $NETCOMMONS_BUILD_DIR - - cd $NETCOMMONS_BUILD_DIR - - git checkout $NETCOMMONS_VERSION - - travis_wait . tools/build/plugins/cakephp/travis/pre.sh - - . tools/build/plugins/cakephp/travis/environment.sh - -script: - - . tools/build/plugins/cakephp/travis/main.sh - -after_script: - - . tools/build/plugins/cakephp/travis/post.sh - -notifications: - email: - recipients: - - netcommons3@googlegroups.com - on_success: never # default: change - on_failure: always # default: always diff --git a/Locale/jpn/LC_MESSAGES/user_attributes.po b/Locale/jpn/LC_MESSAGES/user_attributes.po index fbe9b0e..a94ddaf 100644 --- a/Locale/jpn/LC_MESSAGES/user_attributes.po +++ b/Locale/jpn/LC_MESSAGES/user_attributes.po @@ -18,6 +18,11 @@ msgstr "" msgid "Item name" msgstr "項目名" +#: UserAttributes/Model/UserAttributeChoice.php:131 +#: UserAttributes/Test/Case/Model/UserAttributeChoice/ValidateTest.php:81;83 +msgid "Item choice name" +msgstr "選択肢名" + #: UserAttributes/View/Elements/UserAttributes/delete_form.ctp:25;35 msgid "User attribute" msgstr "会員項目" diff --git a/Model/Behavior/UserAttributeBehavior.php b/Model/Behavior/UserAttributeBehavior.php index 41473ae..c313219 100644 --- a/Model/Behavior/UserAttributeBehavior.php +++ b/Model/Behavior/UserAttributeBehavior.php @@ -64,7 +64,7 @@ public function saveDefaultUserAttributeRoles(Model $model, $data) { 'PluginsRole' => 'PluginManager.PluginsRole', ]); - $pluginsRoles = $model->PluginsRole->find('all', array( + $pluginsRoles = $model->PluginsRole->cacheFindQuery('all', array( 'recursive' => -1, 'fields' => [ 'id', 'role_key', 'plugin_key' diff --git a/Model/UserAttribute.php b/Model/UserAttribute.php index b97eaa6..18700af 100644 --- a/Model/UserAttribute.php +++ b/Model/UserAttribute.php @@ -175,7 +175,7 @@ class UserAttribute extends UserAttributesAppModel { * @see Model::save() */ public function beforeValidate($options = array()) { - $this->validate = Hash::merge($this->validate, array( + $this->validate = ValidateMerge::merge($this->validate, array( 'language_id' => array( 'numeric' => array( 'rule' => array('numeric'), diff --git a/Model/UserAttributeChoice.php b/Model/UserAttributeChoice.php index c21b8fd..501d1ac 100644 --- a/Model/UserAttributeChoice.php +++ b/Model/UserAttributeChoice.php @@ -108,7 +108,7 @@ class UserAttributeChoice extends UsersAppModel { * @see Model::save() */ public function beforeValidate($options = array()) { - $this->validate = Hash::merge($this->validate, array( + $this->validate = ValidateMerge::merge($this->validate, array( 'language_id' => array( 'numeric' => array( 'rule' => array('numeric'), diff --git a/Model/UserAttributeLayout.php b/Model/UserAttributeLayout.php index 05ad482..5e9760e 100644 --- a/Model/UserAttributeLayout.php +++ b/Model/UserAttributeLayout.php @@ -41,7 +41,7 @@ class UserAttributeLayout extends UserAttributesAppModel { * @see Model::save() */ public function beforeValidate($options = array()) { - $this->validate = Hash::merge($this->validate, array( + $this->validate = ValidateMerge::merge($this->validate, array( 'col' => array( 'numeric' => array( 'rule' => array('numeric'), @@ -79,7 +79,7 @@ public function updateUserAttributeLayout($data, $fieldName) { try { //UserAttributeLayoutテーブルの登録 - if (! $this->saveField($fieldName, $data[$this->alias][$fieldName], false)) { + if (! $this->saveField($fieldName, $data[$this->alias][$fieldName], ['callbacks' => false])) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } diff --git a/Model/UserAttributeSetting.php b/Model/UserAttributeSetting.php index afa1ebf..276cac1 100644 --- a/Model/UserAttributeSetting.php +++ b/Model/UserAttributeSetting.php @@ -60,7 +60,7 @@ class UserAttributeSetting extends UserAttributesAppModel { * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function beforeValidate($options = array()) { - $this->validate = Hash::merge($this->validate, array( + $this->validate = ValidateMerge::merge($this->validate, array( 'user_attribute_key' => array( 'notBlank' => array( 'rule' => array('notBlank'), @@ -274,7 +274,7 @@ public function updateDisplay($data, $fieldName) { try { //UserAttributeSettingテーブルの登録 - if (! $this->saveField($fieldName, $data[$this->alias][$fieldName], false)) { + if (! $this->saveField($fieldName, $data[$this->alias][$fieldName], ['callbacks' => false])) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } diff --git a/README.md b/README.md index 520e9bf..fab88ef 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,6 @@ UserAttributes ============== -UserAttributes for NetComomns3 - -[![Build Status](https://api.travis-ci.org/NetCommons3/UserAttributes.png?branch=master)](https://travis-ci.org/NetCommons3/UserAttributes) -[![Coverage Status](https://coveralls.io/repos/NetCommons3/UserAttributes/badge.png?branch=master)](https://coveralls.io/r/NetCommons3/UserAttributes?branch=master) - -| dependencies | status | -| ------------- | ------ | -| composer.json | [![Dependency Status](https://www.versioneye.com/user/projects/55cbc0a1b7d70b000f000250/badge.png)](https://www.versioneye.com/user/projects/55cbc0a1b7d70b000f000250) | +[![Tests Status](https://github.com/NetCommons3/UserAttributes/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/NetCommons3/UserAttributes/actions/workflows/tests.yml) +[![Coverage Status](https://coveralls.io/repos/NetCommons3/UserAttributes/badge.svg?branch=master)](https://coveralls.io/r/NetCommons3/UserAttributes?branch=master) +[![Stable Version](https://img.shields.io/packagist/v/netcommons/user-attributes.svg?label=stable)](https://packagist.org/packages/netcommons/user-attributes) diff --git a/Test/Case/Model/UserAttributeChoice/SaveUserAttributeChoicesTest.php b/Test/Case/Model/UserAttributeChoice/SaveUserAttributeChoicesTest.php index 78039fd..922d6d7 100644 --- a/Test/Case/Model/UserAttributeChoice/SaveUserAttributeChoicesTest.php +++ b/Test/Case/Model/UserAttributeChoice/SaveUserAttributeChoicesTest.php @@ -334,7 +334,9 @@ public function testSkipDataType($dataType, $count) { $method = $this->_methodName; //Mockの生成 - $this->_mockForReturn($model, 'UserAttributes.UserAttributeChoice', 'save', true, $count); + $this->_mockForReturn($model, 'UserAttributes.UserAttributeChoice', 'save', [ + 'UserAttributeChoice' => ['key' => $dataType . '_choice'] + ], $count); //テストデータ $data = $this->__data('default', $dataType); diff --git a/Test/Case/View/Helper/UserAttributeLayoutHelper/BeforeRenderTest.php b/Test/Case/View/Helper/UserAttributeLayoutHelper/BeforeRenderTest.php deleted file mode 100644 index ce2c166..0000000 --- a/Test/Case/View/Helper/UserAttributeLayoutHelper/BeforeRenderTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @author Shohei Nakajima - * @link http://www.netcommons.org NetCommons Project - * @license http://www.netcommons.org/license.txt NetCommons License - * @copyright Copyright 2014, NetCommons Project - */ - -App::uses('NetCommonsControllerTestCase', 'NetCommons.TestSuite'); - -/** - * UserAttributeLayoutHelper::beforeRender()のテスト - * - * @author Shohei Nakajima - * @package NetCommons\UserAttributes\Test\Case\Controller\Component\UserAttributeLayoutHelper - */ -class UserAttributeLayoutHelperBeforeRenderTest extends NetCommonsControllerTestCase { - -/** - * Fixtures - * - * @var array - */ - public $fixtures = array(); - -/** - * Plugin name - * - * @var string - */ - public $plugin = 'user_attributes'; - -/** - * setUp method - * - * @return void - */ - public function setUp() { - parent::setUp(); - - //テストプラグインのロード - NetCommonsCakeTestCase::loadTestPlugin($this, 'UserAttributes', 'TestUserAttributes'); - } - -/** - * beforeRender()のテスト - * - * @return void - */ - public function testBeforeRender() { - //テストコントローラ生成 - $this->generateNc('TestUserAttributes.TestUserAttributeLayoutHelperBeforeRender'); - - //テスト実行 - $this->_testGetAction('/test_user_attributes/test_user_attribute_layout_helper_before_render/index', - array('method' => 'assertNotEmpty'), null, 'view'); - - //チェック - $pattern = '/' . preg_quote('View/Helper/TestUserAttributeLayoutHelperBeforeRender', '/') . '/'; - $this->assertRegExp($pattern, $this->view); - - //cssのURLチェック - $pattern = '//'; - $this->assertRegExp($pattern, $this->contents); - } - -} diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..86fb650 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +3.3.7 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9b4caff..4bd31aa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,8 @@ + + + app/Plugin/UserAttributes @@ -14,6 +17,6 @@ - +