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 3f29ca4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,54 +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: "ETR0GRqjEv6OAGGpr0eNQ2mCdPFLVV4ppmU6cDbGdHyfr1a/SVA2Do75gDx/qwjf9FAXb0qNPypCU7CIJ6L+U2yVpn65qbAZ5fgKLk2xA8xjkfrn2W5Fcif7kxusvqJyYXmq1mhIBkZdNQjwfJPsSO5zZjGUeqv/cBUz5lvfa/I=" - - GIT_COMMITTER_NAME=akagane99 - - GIT_COMMITTER_EMAIL=akagane99@gmail.com - - GIT_AUTHOR_NAME=akagane99 - - GIT_AUTHOR_EMAIL=akagane99@gmail.com - -matrix: - allow_failures: - # PHP 7.4 testing is allowed to fail because the GD extension and ZipArchive is not packaged on Travis CI yet. - # See https://travis-ci.community/t/some-extensions-are-missing-in-php-7-4-0-zip-gmp-sodium/6320/9 - - php: 7.4 - -addons: - apt: - packages: - - libav-tools - - libavcodec-extra - -before_script: - - sudo ln -s /usr/bin/avconv /usr/bin/ffmpeg - - 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 - - . tools/build/plugins/cakephp/travis/pre.sh - -script: - - travis_wait . 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/VideoFilesController.php b/Controller/VideoFilesController.php index e19c3ba..9823b03 100644 --- a/Controller/VideoFilesController.php +++ b/Controller/VideoFilesController.php @@ -11,6 +11,7 @@ App::uses('Controller', 'Controller'); App::uses('Current', 'NetCommons.Utility'); +App::uses('NetCommonsSecurity', 'NetCommons.Utility'); /** * サムネイル、動画の表示 Controller @@ -67,6 +68,10 @@ public function beforeFilter() { * @throws NotFoundException 表示できない記事へのアクセス */ public function file() { + if (! (new NetCommonsSecurity())->enableBadIps()) { + throw new NotFoundException(); + } + // ここから元コンテンツを取得する処理 $key = $this->params['key']; $conditions = $this->Video->getConditions(); @@ -80,10 +85,26 @@ public function file() { // ダウンロード実行 if ($video) { - return $this->Download->doDownload($video['Video']['id']); + //NC2からNC3で移行するとサムネイルが移行されないため、サムネイル画像がないときはNoImageを表示させる + //@see https://github.com/NetCommons3/NetCommons3/issues/1617 + try { + $response = $this->Download->doDownload($video['Video']['id']); + } catch (Exception $ex) { + if (!empty($this->request->params['pass']) && + $this->request->params['pass'][0] === Video::THUMBNAIL_FIELD) { + //NoImageを表示する + $noimagePath = CakePlugin::path('Videos') . + 'webroot' . DS . 'img' . DS . 'thumbnail_noimage.png'; + $this->response->file($noimagePath, ['name' => 'No Image']); + $response = $this->response; + } else { + throw $ex; + } + } + return $response; } else { // 表示できないなら404 - throw new NotFoundException(__d('videos', 'Invalid video entry')); + throw new NotFoundException(); } } } diff --git a/Controller/VideosEditController.php b/Controller/VideosEditController.php index 35cee2f..d76e4e9 100644 --- a/Controller/VideosEditController.php +++ b/Controller/VideosEditController.php @@ -138,6 +138,9 @@ public function edit() { 'Video.key' => $videoKey ) )); + if (empty($video)) { + return $this->throwBadRequest(); + } $this->set('video', $video); if (! $this->Video->canEditWorkflowContent($video)) { diff --git a/Model/Behavior/VideoValidationBehavior.php b/Model/Behavior/VideoValidationBehavior.php index e5e15f9..83a3406 100644 --- a/Model/Behavior/VideoValidationBehavior.php +++ b/Model/Behavior/VideoValidationBehavior.php @@ -172,6 +172,14 @@ public function rules(Model $model, $options = array()) { ), ), )); + + //NC2からNC3で移行するとサムネイルが移行されないため、サムネイルのupload_idが空であれば、 + //エラーにならないようにunsetする。 + //@see https://github.com/NetCommons3/NetCommons3/issues/1617 + if (isset($model->data['UploadFile']['thumbnail']['id']) && + ! $model->data['UploadFile']['thumbnail']['id']) { + unset($model->data['UploadFile']['thumbnail']); + } } return $rules; diff --git a/README.md b/README.md index a66cafc..3831b77 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -# Videos -Videos for NetCommons3 +Videos +======== -[![Build Status](https://api.travis-ci.org/NetCommons3/Videos.svg?branch=master)](https://travis-ci.org/NetCommons3/Videos) +[![Tests Status](https://github.com/NetCommons3/Videos/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/NetCommons3/Videos/actions/workflows/tests.yml) [![Coverage Status](https://coveralls.io/repos/NetCommons3/Videos/badge.svg?branch=master)](https://coveralls.io/r/NetCommons3/Videos?branch=master) +[![Stable Version](https://img.shields.io/packagist/v/netcommons/videos.svg?label=stable)](https://packagist.org/packages/netcommons/videos) ### [phpdoc](https://netcommons3.github.io/NetCommons3Docs/phpdoc/Videos/) diff --git a/Test/Case/Model/Video/DeleteVideoTest.php b/Test/Case/Model/Video/DeleteVideoTest.php index 882e4d8..308acb7 100644 --- a/Test/Case/Model/Video/DeleteVideoTest.php +++ b/Test/Case/Model/Video/DeleteVideoTest.php @@ -41,6 +41,8 @@ class VideoDeleteVideoTest extends WorkflowDeleteTest { 'plugin.content_comments.content_comment', 'plugin.site_manager.site_setting', 'plugin.categories.category', + 'plugin.categories.category_order', + 'plugin.categories.categories_language', ); /** diff --git a/Test/Case/Model/VideoSetting/SaveVideoSettingTest.php b/Test/Case/Model/VideoSetting/SaveVideoSettingTest.php index 640be22..43a2deb 100644 --- a/Test/Case/Model/VideoSetting/SaveVideoSettingTest.php +++ b/Test/Case/Model/VideoSetting/SaveVideoSettingTest.php @@ -27,6 +27,10 @@ class VideoSettingSaveVideoSettingTest extends NetCommonsSaveTest { */ public $fixtures = array( 'plugin.videos.video_setting', + 'plugin.videos.video', + 'plugin.categories.category', + 'plugin.categories.category_order', + 'plugin.categories.categories_language', ); /** diff --git a/VERSION.txt b/VERSION.txt index 4772543..86fb650 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.2 +3.3.7 diff --git a/View/VideosEdit/edit.ctp b/View/VideosEdit/edit.ctp index 4ef6283..f4fa83d 100644 --- a/View/VideosEdit/edit.ctp +++ b/View/VideosEdit/edit.ctp @@ -103,7 +103,7 @@ $video = NetCommonsAppController::camelizeKeyRecursive(array('video' => $this->d 'key' => $this->request->data('Video.key') ))); ?> - Form->end(); ?> + NetCommonsForm->end(); ?> Workflow->canDelete('Videos.Video', $this->request->data('Video'))) : ?>