From 0a563e7b743db56575276af95fa0643d47e7b346 Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Tue, 5 Feb 2019 20:29:06 +0900 Subject: [PATCH 01/19] =?UTF-8?q?fix:=20=E3=81=84=E3=81=84=E3=81=AD?= =?UTF-8?q?=E3=80=81=E3=82=8F=E3=82=8B=E3=81=84=E3=81=AD=E3=81=AE=E3=82=AB?= =?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=88=E6=95=B0=E3=81=8C=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E3=83=90=E3=82=B0=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=20https://github.com/NetCommons3/NetCommons3/issues/1?= =?UTF-8?q?374?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/LikeBehavior.php | 72 ++++++++++++++------------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/Model/Behavior/LikeBehavior.php b/Model/Behavior/LikeBehavior.php index 094b608..d1946a2 100644 --- a/Model/Behavior/LikeBehavior.php +++ b/Model/Behavior/LikeBehavior.php @@ -86,50 +86,40 @@ public function setup(Model $model, $config = array()) { * @return array タグ検索条件を加えたfind条件 */ public function beforeFind(Model $model, $query) { - if (Hash::get($query, 'recursive') > -1) { - $joinTable = false; - - $conditions = $query['conditions']; - if (is_array($conditions) === false) { - return $query; - } - $columns = array_keys($conditions); - // 条件あったらLikeテーブルとリンクテーブルをJOIN - if (preg_grep('/^Like\./', $columns) || preg_grep('/^LikesUser\./', $columns)) { - $joinTable = true; + if (Hash::get($query, 'recursive', $model->recursive) > -1) { + $likesUserConditions = array( + 'Like.id = LikesUser.like_id', + ); + if (Current::read('User.id')) { + $likesUserConditions['LikesUser.user_id'] = Current::read('User.id'); + } else { + $likesUserConditions['LikesUser.session_key'] = CakeSession::id(); } - if ($joinTable) { - $likesUserConditions = array( - 'Like.id = LikesUser.like_id', - ); - if (Current::read('User.id')) { - $likesUserConditions['LikesUser.user_id'] = Current::read('User.id'); - } else { - $likesUserConditions['LikesUser.session_key'] = CakeSession::id(); - } + $fieldName = $this->settings[$model->alias]['model'] . '.' . + $this->settings[$model->alias]['field']; - $LikesUser = ClassRegistry::init('Likes.LikesUser'); - $Like = ClassRegistry::init('Likes.Like'); - - $fieldName = $this->settings[$model->alias]['model'] . '.' . - $this->settings[$model->alias]['field']; - $query['joins'][] = [ - 'type' => 'LEFT', - 'table' => $Like->table, - 'alias' => $Like->alias, - 'conditions' => [ - 'Like.plugin_key' => Inflector::underscore($model->plugin), - $fieldName . ' = ' . 'Like.content_key', - ] - ]; - $query['joins'][] = [ - 'type' => 'LEFT', - 'table' => $LikesUser->table, - 'alias' => $LikesUser->alias, - 'conditions' => $likesUserConditions, - ]; - } + // joinではfieldsを指定しないと値を取得できない。 + // fieldsはほぼNULLのため、fieldsを追加対応ができない。そのためbindModelで対応する + // bindModelの場合、うまいことfieldsを設定してくれる。 + $model->bindModel(array( + 'belongsTo' => array( + 'Like' => array( + 'className' => 'Likes.Like', + 'foreignKey' => false, + 'conditions' => array( + 'Like.plugin_key' => Inflector::underscore($model->plugin), + //$this->__model . '.' . $this->__field . ' = ' . 'Like.content_key', + $fieldName . ' = ' . 'Like.content_key', + ), + ), + 'LikesUser' => array( + 'className' => 'Likes.LikesUser', + 'foreignKey' => false, + 'conditions' => $likesUserConditions, + ), + ) + ), true); } return $query; } From e693fd60cdb829219c4406588c5fa89d265af7b3 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Thu, 9 May 2019 11:22:52 +0900 Subject: [PATCH 02/19] =?UTF-8?q?change:=20beforeValidate()=E3=82=92?= =?UTF-8?q?=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=99=E3=81=9F=E3=81=B3=E3=81=AB?= =?UTF-8?q?Hash::merge=E3=81=A7=E3=83=90=E3=83=AA=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=AB=E3=83=BC=E3=83=AB=E3=81=8C?= =?UTF-8?q?=E5=A2=97=E3=81=88=E3=82=8B=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82?= =?UTF-8?q?=E3=82=8B=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82ValidateM?= =?UTF-8?q?erge::merge=E3=81=B8=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88?= =?UTF-8?q?=E3=81=9F=20Refs=20https://github.com/NetCommons3/NetCommons3/i?= =?UTF-8?q?ssues/1486?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Like.php | 2 +- Model/LikesUser.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Like.php b/Model/Like.php index 13fb63b..68fc326 100644 --- a/Model/Like.php +++ b/Model/Like.php @@ -72,7 +72,7 @@ class Like extends LikesAppModel { * @see Model::save() */ public function beforeValidate($options = array()) { - $this->validate = Hash::merge($this->validate, array( + $this->validate = ValidateMerge::merge($this->validate, array( 'plugin_key' => array( 'notBlank' => array( 'rule' => array('notBlank'), diff --git a/Model/LikesUser.php b/Model/LikesUser.php index 6a82647..5a402e9 100644 --- a/Model/LikesUser.php +++ b/Model/LikesUser.php @@ -55,7 +55,7 @@ class LikesUser extends LikesAppModel { * @see Model::save() */ public function beforeValidate($options = array()) { - $this->validate = Hash::merge($this->validate, array( + $this->validate = ValidateMerge::merge($this->validate, array( 'is_liked' => array( 'boolean' => array( 'rule' => array('boolean'), From ed10ef6db2950b8898d007a136bd55ac38bc00b7 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 12 Aug 2019 07:31:53 +0900 Subject: [PATCH 03/19] =?UTF-8?q?fix:=20test:=20travis=20php7.2=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=20https://github.com/NetCommons3/NetCommons3/issues/1?= =?UTF-8?q?451?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 4 +++- phpunit.xml.dist | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dcad8f5..b29f028 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,10 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 -sudo: required +sudo: false +dist: trusty env: matrix: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 22c1fb3..331b598 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,6 +14,5 @@ - From 722580b70636a7a66cd760387bc0c846346fcbef Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 9 Mar 2020 23:00:38 +0900 Subject: [PATCH 04/19] =?UTF-8?q?change:=20test:=20travis.yml=E3=81=8B?= =?UTF-8?q?=E3=82=89php5.4,5.5=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82php7.3,7?= =?UTF-8?q?.4=E3=82=92=E8=BF=BD=E5=8A=A0=20https://github.com/NetCommons3/?= =?UTF-8?q?NetCommons3/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b29f028..453257d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: php php: - - 5.4 - - 5.5 - 5.6 - 7.0 - 7.1 - 7.2 + - 7.3 + - 7.4 sudo: false dist: trusty From 62364c7288b5a7795d34829abbf9c68c1816a4c1 Mon Sep 17 00:00:00 2001 From: ryu818 Date: Mon, 30 Mar 2020 10:41:51 +0900 Subject: [PATCH 05/19] =?UTF-8?q?change:=20=EF=BC=92=E9=87=8D=E7=99=BB?= =?UTF-8?q?=E9=8C=B2=E3=81=95=E3=81=9B=E3=81=AA=E3=81=84=E5=88=B6=E5=BE=A1?= =?UTF-8?q?=E3=82=92session=5Fid=E3=81=A7=E5=88=A4=E6=96=AD=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=81=AE=E3=81=A7=E3=81=AF=E3=81=AA=E3=81=8F=E3=80=81?= =?UTF-8?q?=E3=82=BB=E3=83=83=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AB=E7=99=BB?= =?UTF-8?q?=E9=8C=B2=E3=81=95=E3=82=8C=E3=81=9F=E3=82=AD=E3=83=BC=E3=81=A7?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=20https://github.com/researchmap/RmNetCommon?= =?UTF-8?q?s3/issues/1750#issuecomment-596823362?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/LikesController.php | 22 ++++++++++++++++++++-- Model/Like.php | 10 +++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Controller/LikesController.php b/Controller/LikesController.php index 4fc087f..57bfe2d 100644 --- a/Controller/LikesController.php +++ b/Controller/LikesController.php @@ -47,8 +47,8 @@ public function like() { if (! $this->request->is('post')) { return $this->throwBadRequest(); } - - if ($this->Like->existsLike($this->data['Like']['content_key'])) { + $md5SessionKey = $this->__getKey(); + if ($this->Like->existsLike($this->data['Like']['content_key'], $md5SessionKey)) { return; } @@ -58,9 +58,27 @@ public function like() { 'conditions' => array('content_key' => $data['Like']['content_key']) )); $data = Hash::merge($like, $data); + if (!Current::read('User.id')) { + $data['LikesUser']['session_key'] = $md5SessionKey; + } if ($this->Like->saveLike($data)) { return; } $this->NetCommons->handleValidationError($this->Like->validationErrors); } + +/** + * session_keyを返す + * + * @return string + */ + private function __getKey() { + $md5SessionKey = $this->Session->read('Likes.md5_session_key'); + if ($md5SessionKey) { + return $md5SessionKey; + } + $md5SessionKey = md5(CakeSession::id()); + $this->Session->write('Likes.md5_session_key', $md5SessionKey); + return $md5SessionKey; + } } diff --git a/Model/Like.php b/Model/Like.php index 68fc326..fe99f0c 100644 --- a/Model/Like.php +++ b/Model/Like.php @@ -176,9 +176,11 @@ public function afterSave($created, $options = array()) { * Exists like data * * @param string $contentKey Content key of each plugin. + * @param string $md5SessionKey md5(SessionKey) + * @see https://github.com/researchmap/RmNetCommons3/issues/1750#issuecomment-596823362 * @return bool */ - public function existsLike($contentKey) { + public function existsLike($contentKey, $md5SessionKey = null) { $this->LikesUser = ClassRegistry::init('Likes.LikesUser'); $joinConditions = array( @@ -186,8 +188,11 @@ public function existsLike($contentKey) { ); if (Current::read('User.id')) { $joinConditions[$this->LikesUser->alias . '.user_id'] = Current::read('User.id'); + } elseif (!is_null($md5SessionKey)) { + $joinConditions[$this->LikesUser->alias . '.session_key'] = (string)$md5SessionKey; } else { - $joinConditions[$this->LikesUser->alias . '.session_key'] = (string)CakeSession::id(); + // 常にインクリメント + return false; } $count = $this->find('count', array( @@ -224,7 +229,6 @@ public function saveLike($data) { $this->begin(); //バリデーション - $data['LikesUser']['session_key'] = CakeSession::id(); $this->set($data); if (! $this->validates()) { $this->rollback(); From f9092ec86193c3e596b5d8f1b1cda9601c0aa8c1 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 7 Aug 2020 21:41:16 +0900 Subject: [PATCH 06/19] =?UTF-8?q?change:=20test:=20Travis=E3=81=8B?= =?UTF-8?q?=E3=82=89PHP5.6=E3=82=92=E5=89=8A=E9=99=A4,php72=E4=BB=A5?= =?UTF-8?q?=E9=99=8D=E3=81=A7UnitTest=E3=81=A7Warning=E3=81=8C=E5=87=BA?= =?UTF-8?q?=E3=82=8B=E3=81=9F=E3=82=81=E4=BF=AE=E6=AD=A3=20https://github.?= =?UTF-8?q?com/NetCommons3/NetCommons3/issues/1588?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 1 - phpunit.xml.dist | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 453257d..e8efde3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.6 - 7.0 - 7.1 - 7.2 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 331b598..3caad3c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,11 @@ + + + + + + app/Plugin/Likes From 0cfb2614a1e9659d01bf70a69fd896ce67a52194 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 26 Aug 2020 20:19:14 +0900 Subject: [PATCH 07/19] change: Version number to 3.3.2 --- VERSION.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION.txt diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..4772543 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +3.3.2 From e96533d76a01d1c310662eaea6b50be58a55af98 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 13 Dec 2020 17:03:32 +0900 Subject: [PATCH 08/19] =?UTF-8?q?fix:=20test:=20TravisCI=E3=81=AEphp7.3?= =?UTF-8?q?=E3=81=A7=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C=E5=87=BA=E3=82=8B?= =?UTF-8?q?=E3=81=9F=E3=82=81=E4=BF=AE=E6=AD=A3=20https://github.com/NetCo?= =?UTF-8?q?mmons3/NetCommons3/issues/1618?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e8efde3..def352a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ php: - 7.0 - 7.1 - 7.2 - - 7.3 + - 7.3.24 - 7.4 sudo: false From b148959b99c991352e2aeb9be428531325072235 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Jan 2021 13:58:01 +0900 Subject: [PATCH 09/19] =?UTF-8?q?add:=20release=E3=82=BF=E3=82=B0=E4=BB=98?= =?UTF-8?q?=E3=81=91=E3=81=AEgithub=20action=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/NetCommons3/NetCommons3/issues/1619 --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a3225bc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +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: 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 From 4b8ec03210669dcc0fcdd17a7131079546eef297 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Jan 2021 13:58:06 +0900 Subject: [PATCH 10/19] change: Version number to 3.3.3 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 4772543..619b537 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.2 +3.3.3 From 86d0d558a5f7780eaa71327260c577a5f5176b01 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 31 Jul 2021 10:12:18 +0900 Subject: [PATCH 11/19] =?UTF-8?q?change:=20test:=20TravisCI=E3=81=8B?= =?UTF-8?q?=E3=82=89GithubAction=E3=81=AB=E5=A4=89=E6=9B=B4=20https://gith?= =?UTF-8?q?ub.com/NetCommons3/NetCommons3/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 137 ++++++++++++++++++++++++++++++++++++ .travis.yml | 43 ----------- README.md | 11 +-- phpunit.xml.dist | 4 +- 4 files changed, 141 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d6bd01e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,137 @@ +on: + push: + branches: + - main + - master + - availability + pull_request: + branches: + - main + - master + - availability + +name: tests + +jobs: + tests: + name: tests + runs-on: ubuntu-18.04 + strategy: + matrix: + php: [ '7.1', '7.2', '7.3', '7.4' ] + + 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_ROOT_PASSWORD: root + MYSQL_DATABASE: cakephp_test + + steps: + - uses: actions/checkout@v2 + + - name: environment + run: | + echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" + echo "PLUGIN_BUILD_DIR=${PLUGIN_BUILD_DIR}" + echo "PHP_VERSION=${PHP_VERSION}" + ls -al ${PLUGIN_BUILD_DIR} + + - 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 + 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) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpcs.sh + + - name: phpmd (PHP Mess Detector) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpmd.sh + + - name: phpcpd (PHP Copy/Paste Detector) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpcpd.sh + + - name: gjslint (JavaScript Style Check) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/gjslint.sh + + - name: phpdoc (PHP Documentor) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpdoc.sh + + - name: phpunit (PHP UnitTest) + 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 + run: | + cd ${NC3_DOCKER_DIR} + docker-compose rm -f + + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on Success + if: success() + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: notify-netcommons3 + SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" + SLACK_COLOR: good + + # テスト失敗時はこちらのステップが実行される + - name: Slack Notification on Failure + uses: rtCamp/action-slack-notify@v2.2.0 + if: failure() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: notify-netcommons3 + SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" + SLACK_COLOR: danger diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index def352a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -language: php - -php: - - 7.0 - - 7.1 - - 7.2 - - 7.3.24 - - 7.4 - -sudo: false -dist: trusty - -env: - matrix: - - NETCOMMONS_VERSION=master DB=mysql - global: - - secure: "eOJhJHrLG6nQUX222m/g/g1LR+k/W/mtdvJsxyHRx++Robu6EIDuXmE6Y4SuIi0vlvJbdhrOx9Gu0oKIkX5RYXbY0iwFnoQ1iXYnPBH9DoBp7ucr2ddd/UDsIkR40k6v8m2Dunzzk1xfiZvXw0UUxL/ulMQLBqvjEZu+pgLM9sc=" - - 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/README.md b/README.md index 8c586ea..e5128bf 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,9 @@ Likes ============== -Likes for NetComomns3 - -[![Build Status](https://api.travis-ci.org/NetCommons3/Likes.png?branch=master)](https://travis-ci.org/NetCommons3/Likes) -[![Coverage Status](https://coveralls.io/repos/NetCommons3/Likes/badge.png?branch=master)](https://coveralls.io/r/NetCommons3/Likes?branch=master) - -| dependencies | status | -| ------------- | ------ | -| composer.json | [![Dependency Status](https://www.versioneye.com/user/projects/55208049529844d45300001f/badge.png)](https://www.versioneye.com/user/projects/55208049529844d45300001f) | +[![Tests Status](https://github.com/NetCommons3/Likes/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/NetCommons3/Likes/actions/workflows/tests.yml) +[![Coverage Status](https://coveralls.io/repos/NetCommons3/Likes/badge.svg?branch=master)](https://coveralls.io/r/NetCommons3/Likes?branch=master) +[![Stable Version](https://img.shields.io/packagist/v/netcommons/likes.svg?label=stable)](https://packagist.org/packages/netcommons/likes) ### 概要 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3caad3c..ec59634 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,9 +3,6 @@ - - - app/Plugin/Likes @@ -20,5 +17,6 @@ + From 60101e1204c41135f0a5c59c6038684cc494debd Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 11 Aug 2021 10:11:00 +0900 Subject: [PATCH 12/19] =?UTF-8?q?change:=20test:=20Slack=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3,=20mysql8.0=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20https://github.com/NetCommons3/NetCommons3?= =?UTF-8?q?/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 35 ++++++++++++++++++++++++-- .github/workflows/tests.yml | 47 +++++++++++++++++++++++++---------- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a3225bc..592d72f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,16 +4,25 @@ on: tags: - '3*' -name: Create Release +name: create_release jobs: build: - name: Create Release + 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 @@ -26,3 +35,25 @@ jobs: 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 index d6bd01e..1477ea2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,12 +13,26 @@ on: name: tests jobs: + setup: + name: setup + runs-on: ubuntu-18.04 + steps: + - name: Slack Notification on Start + uses: rtCamp/action-slack-notify@v2.2.0 + 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-18.04 strategy: matrix: php: [ '7.1', '7.2', '7.3', '7.4' ] + mysql: [ '5.7', '8.0' ] env: NC3_BUILD_DIR: "/opt/nc3" @@ -27,6 +41,7 @@ jobs: 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 @@ -38,6 +53,7 @@ jobs: 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 @@ -116,22 +132,27 @@ jobs: cd ${NC3_DOCKER_DIR} docker-compose rm -f - # テスト成功時はこちらのステップが実行される - - name: Slack Notification on Success - if: success() - uses: rtCamp/action-slack-notify@v2.2.0 - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - SLACK_CHANNEL: notify-netcommons3 - SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" - SLACK_COLOR: good - # テスト失敗時はこちらのステップが実行される - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.2.0 if: failure() env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - SLACK_CHANNEL: notify-netcommons3 - SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" + 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-18.04 + needs: tests + steps: + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on Success + if: success() + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: good From 5a070e10ca6e5395dc8db2047f2c47f12a24e8c4 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 13 Aug 2021 16:11:27 +0900 Subject: [PATCH 13/19] change: Version number to 3.3.4 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 619b537..a0891f5 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.3 +3.3.4 From a5d99168f5c886a2434ea1880c61116f9b896119 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 11 Feb 2022 19:46:40 +0900 Subject: [PATCH 14/19] change: Version number to 3.3.5 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index a0891f5..fa7adc7 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.4 +3.3.5 From 282b2064587c446f22da511230ad573006189f4f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Apr 2022 09:10:47 +0900 Subject: [PATCH 15/19] =?UTF-8?q?test:=20github=20actions=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1477ea2..9501566 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,6 +48,9 @@ jobs: 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 From 8f88dd08b8adf581279638031a5f510d997376a7 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 24 Feb 2023 14:39:54 +0900 Subject: [PATCH 16/19] =?UTF-8?q?test:=20Github=20Action=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9501566..7cfa881 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,6 +44,7 @@ jobs: MYSQL_VERSION: ${{ matrix.mysql }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: cakephp_test + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 From 576497cfbd77c5742a22eceb0598e7953b9ae602 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 26 Feb 2023 00:57:24 +0900 Subject: [PATCH 17/19] change: Version number to 3.3.6 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index fa7adc7..9c25013 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.5 +3.3.6 From 792e3fb629a427d4c4aab012c863076a51d6260d Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Thu, 5 Oct 2023 18:53:24 +0900 Subject: [PATCH 18/19] =?UTF-8?q?test:=20github=20action=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7cfa881..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' ] @@ -92,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 @@ -139,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 @@ -148,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 From 06045e5aade579f4194030c2eda1832f81824bd5 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 9 Oct 2023 18:41:30 +0900 Subject: [PATCH 19/19] change: Version number to 3.3.7 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 9c25013..86fb650 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.6 +3.3.7