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..eb2068b --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,170 @@ +on: + push: + branches: + - main + - master + - availability + pull_request: + branches: + - main + - master + - availability + +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 acfb2de..0000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - -sudo: false - -env: - matrix: - - NETCOMMONS_VERSION=master DB=mysql - global: - - secure: "TTEVvTjbwUpxFv+KI5ABe5kR25AzbktixeBYmeJ+xZn99fpW2GZ4slLwVmAL6+/qnXez06tKJalSbU5D4Z+s12c0WEbo2vLgviYrhe4/iW0Pzry3CCTrWVXE/F5KlzSH3BWIt1hIG3Qkjk4K0FqfmXDlvt4Tg4Jmq5oUhpHf5gI=" - - 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/Controller/AnnouncementBlockRolePermissionsController.php b/Controller/AnnouncementBlockRolePermissionsController.php old mode 100755 new mode 100644 diff --git a/Controller/AnnouncementsController.php b/Controller/AnnouncementsController.php index 052e62e..efedc09 100644 --- a/Controller/AnnouncementsController.php +++ b/Controller/AnnouncementsController.php @@ -78,6 +78,14 @@ public function view() { * @return void */ public function edit() { + //お知らせは、新規登録と編集が同じアクションであるため、block_idにあたる部分に + //不正な文字を入力しても、無視されてしまうため、チェック処理を別途追加。 + if (empty($this->params['block_id']) && + !empty($this->params['pass'][0]) && + !is_numeric($this->params['pass'][0])) { + return $this->throwBadRequest(); + } + if ($this->request->is('post') || $this->request->is('put')) { $data = $this->data; $data['Announcement']['status'] = $this->Workflow->parseStatus(); diff --git a/Model/Announcement.php b/Model/Announcement.php old mode 100755 new mode 100644 index 0f72080..ecf9cbc --- a/Model/Announcement.php +++ b/Model/Announcement.php @@ -130,6 +130,12 @@ public function beforeValidate($options = array()) { * @see Model::save() */ public function beforeSave($options = array()) { + // 新規登録時でCurrent Frame.block_idがnullならCurrent Frame.block_idをセットする + // ここでFrame.block_idをセットしておかないと新着プラグインにFrame.idが登録されない。 + // @see app/Plugin/Topics/Model/Behavior/TopicsBaseBehavior.php:109 + if (Current::read('Frame.block_id') === null) { + Current::write('Frame.block_id', Current::read('Block.id')); + } $this->loadModels([ 'AnnouncementSetting' => 'Announcements.AnnouncementSetting', ]); diff --git a/README.md b/README.md index 255e566..d82123a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,6 @@ Announcements ============== -Announcements for NetComomns3 - -[](https://travis-ci.org/NetCommons3/Announcements) -[](https://coveralls.io/r/NetCommons3/Announcements?branch=master) - -| dependencies | status | -| ------------- | ------ | -| composer.json | [](https://www.versioneye.com/user/projects/544a13d2c310f93677000088) | +[](https://github.com/NetCommons3/Announcements/actions/workflows/tests.yml) +[](https://coveralls.io/r/NetCommons3/Announcements?branch=master) +[](https://packagist.org/packages/netcommons/announcements) diff --git a/Test/Case/Controller/AnnouncementBlocksController/EditTest.php b/Test/Case/Controller/AnnouncementBlocksController/EditTest.php index af885d5..dddc544 100644 --- a/Test/Case/Controller/AnnouncementBlocksController/EditTest.php +++ b/Test/Case/Controller/AnnouncementBlocksController/EditTest.php @@ -47,7 +47,7 @@ private function __getData($isEdit) { $frameId = '6'; if ($isEdit) { - $blockId = '4'; + $blockId = '2'; $blockKey = 'block_3'; $anouncementId = '4'; $anouncementKey = 'announcement_3'; @@ -154,7 +154,7 @@ public function dataProviderEdit() { * @return void */ public function dataProviderDelete() { - $blockId = '4'; + $blockId = '2'; $data = array( 'Block' => array( diff --git a/Test/Case/Model/Announcement/GetAnnouncementTest.php b/Test/Case/Model/Announcement/GetAnnouncementTest.php index 9703d02..b01f6b5 100644 --- a/Test/Case/Model/Announcement/GetAnnouncementTest.php +++ b/Test/Case/Model/Announcement/GetAnnouncementTest.php @@ -60,7 +60,7 @@ class AnnouncementGetAnnouncementTest extends WorkflowGetTest { */ public function testGetAnnouncementWOContentEditable() { //事前データセット - Current::$current['Permission']['content_editable']['value'] = false; + Current::writePermission('2', 'content_editable', false); $announcementId = '1'; //期待値 @@ -82,6 +82,7 @@ public function testGetAnnouncementWOContentEditable() { */ public function testGetAnnouncementContentEditable() { //事前データセット + Current::writePermission('2', 'content_editable', true); $announcementId = '2'; //期待値 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/View/Announcements/edit.ctp b/View/Announcements/edit.ctp index fd5aea0..ffb7242 100644 --- a/View/Announcements/edit.ctp +++ b/View/Announcements/edit.ctp @@ -20,8 +20,8 @@ $announcement = NetCommonsAppController::camelizeKeyRecursive(array('announcemen ng-init="initialize()">