diff --git a/.gitattributes b/.gitattributes index 2584f16..508317c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,12 @@ -composer.json export-ignore -.travis.yml export-ignore -.gitignore export-ignore +.editorconfig export-ignore .gitattributes export-ignore - +.gitignore export-ignore +composer.json export-ignore +composer.lock export-ignore +Dockerfile export-ignore +docker-compose.yml export-ignore +Makefile export-ignore +/assets export-ignore +/docs export-ignore +/.github export-ignore +.phpcs.xml export-ignore diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index 086633f..614262c 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -5,30 +5,91 @@ on: branches: [ 'master' ] jobs: - deploy-bmlt-versions-latest: + lint: + runs-on: ubuntu-latest + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + id: install-dependencies + run: make composer + + - name: PHPCS checker + id: php-codesniffer + run: make lint + + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#bmlt-versions' + if: failure() + + deploy: runs-on: ubuntu-latest permissions: id-token: write contents: write + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + S3_BUCKET: archives.bmlt.app + S3_KEY: bmlt-versions + BUILD_DIR: build + DIST_DIR_S3: dist/s3 + PLUGIN: "bmlt-versions" + needs: [ lint ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 id: code-checkout - - name: Prepare zip file + - name: Prepare to deploy run: | - export ARTIFACT_FILE=bmlt-versions - export ARTIFACT_FILENAME=bmlt-versions.zip - echo "ARTIFACT_FILENAME=${ARTIFACT_FILENAME}" >> $GITHUB_ENV - echo ${GITHUB_SHA} > ${ARTIFACT_FILE}/build.txt - zip -r ${ARTIFACT_FILENAME} ${ARTIFACT_FILE} + export FILENAME=${PLUGIN}-build-${GITHUB_RUN_NUMBER}-${GITHUB_SHA} + export ZIP_FILENAME=$FILENAME.zip + echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV + make build + mkdir -p ${DIST_DIR_S3} && cp ${BUILD_DIR}/${ZIP_FILENAME} ${DIST_DIR_S3}/${ZIP_FILENAME} - name: configure aws credentials uses: aws-actions/configure-aws-credentials@v1 with: role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions/gh-ci-s3-artifact - role-session-name: gh-actions-bmlt-versions + role-session-name: gh-actions-${{ env.PLUGIN }} aws-region: us-east-1 - name: copy artifact to s3 run: | - aws s3 cp ${ARTIFACT_FILENAME} s3://${{ secrets.S3_BUCKET }}/bmlt-versions/bmlt-versions-build${GITHUB_RUN_NUMBER}-${GITHUB_SHA}.zip + aws s3 cp $DIST_DIR_S3/$ZIP_FILENAME s3://$S3_BUCKET/$S3_KEY/$ZIP_FILENAME + + - name: Publish Release to Latest WP + id: publish_latest + uses: bmlt-enabled/wordpress-releases-github-action@v1 + with: + file: ${{ env.DIST_DIR_S3 }}/${{ env.ZIP_FILENAME }} + s3_key: ${{ env.S3_KEY }} + aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }} + + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#bmlt-versions' + if: failure() diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 141dbf0..3699c19 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -8,7 +8,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 id: code-checkout - name: Validate composer.json and composer.lock @@ -17,7 +17,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} @@ -27,8 +27,8 @@ jobs: - name: Install dependencies if: steps.composer-cache.outputs.cache-hit != 'true' id: install-dependencies - run: composer install --prefer-dist --no-progress --no-suggest + run: make composer - name: PHPCS checker id: php-codesniffer - run: vendor/squizlabs/php_codesniffer/bin/phpcs --warning-severity=6 --standard=PSR2 --ignore=vendor --extensions=php --report=summary ./ + run: make lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62a171b..276a02a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,31 +2,76 @@ name: 'release' on: push: - tags: ['*'] + tags: [ '*' ] jobs: - deploy-bmlt-versions-release: + lint: runs-on: ubuntu-latest + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} steps: - - uses: actions/checkout@v2 + - name: Check out code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + id: install-dependencies + run: make composer + + - name: PHPCS checker + id: php-codesniffer + run: make lint + + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#bmlt-versions' + if: failure() + + package: + runs-on: ubuntu-latest + env: + BUILD_DIR: "build" + DIST_DIR_GITHUB: "dist/github" + GITHUB_RELEASE_FILENAME: "bmlt-versions.zip" + PLUGIN: "bmlt-versions" + MAINFILE: "bmlt-versions.php" + needs: [ lint ] + steps: + - uses: actions/checkout@v3 id: code-checkout - - name: Prepare zip file + - name: Build package + id: build-package run: | - export ARTIFACT_FILE=bmlt-versions - export ARTIFACT_FILENAME=bmlt-versions.zip - echo "ARTIFACT_FILENAME=${ARTIFACT_FILENAME}" >> $GITHUB_ENV - echo ${GITHUB_SHA} > ${ARTIFACT_FILE}/build.txt - zip -r ${ARTIFACT_FILENAME} ${ARTIFACT_FILE} - curl -sLO https://raw.githubusercontent.com/bmlt-enabled/release-notes-tool/master/gh-release-notes.sh + export ZIP_FILENAME=${PLUGIN}-build${GITHUB_RUN_NUMBER}-${GITHUB_SHA}.zip + find ./ -type d | xargs chmod 755 + find ./ -name '*.php' | xargs chmod 644 + echo ${GITHUB_SHA} > build.txt + make build + zip $ZIP_FILENAME build.txt + mv $ZIP_FILENAME ${PLUGIN}-${GITHUB_REF##*/}.zip + mkdir -p $DIST_DIR_GITHUB && cp $BUILD_DIR/$ZIP_FILENAME $DIST_DIR_GITHUB/$GITHUB_RELEASE_FILENAME + curl -LO https://raw.githubusercontent.com/bmlt-enabled/release-notes-tool/master/gh-release-notes.sh chmod +x gh-release-notes.sh - ./gh-release-notes.sh bmlt-versions/readme.txt "wp" - - - name: Prepare artifact metadata - id: prepare_artifact_metadata - run: | - echo ::set-output name=ARTIFACT_PATH::./${ARTIFACT_FILENAME} - echo ::set-output name=ARTIFACT_NAME::${ARTIFACT_FILENAME} + ./gh-release-notes.sh readme.txt "wp" + echo "ARTIFACT_PATH=./${PLUGIN}-${GITHUB_REF##*/}.zip" >> $GITHUB_ENV + echo "ARTIFACT_NAME=${PLUGIN}-${GITHUB_REF##*/}.zip" >> $GITHUB_ENV - name: Release beta if: contains(github.ref, 'beta') @@ -48,8 +93,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.beta_release.outputs.upload_url }} - asset_path: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }} - asset_name: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }} + asset_path: ${{ env.ARTIFACT_PATH }} + asset_name: ${{ env.ARTIFACT_NAME }} asset_content_type: application/zip - name: Release stable @@ -73,6 +118,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.stable_release.outputs.upload_url }} - asset_path: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }} - asset_name: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }} + asset_path: ${{ env.ARTIFACT_PATH }} + asset_name: ${{ env.ARTIFACT_NAME }} asset_content_type: application/zip diff --git a/.gitignore b/.gitignore index 27fb1ca..b2a06a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ +.project +.settings/* +.vscode/* .DS_Store .idea -*.lock -logs/ vendor/ +logs/ +build/ diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 0000000..5197e03 --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,47 @@ + + + The BMLT Coding Standards + + . + + + + + + + + + + + + + + vendor/* + + + + + diff --git a/Dockerfile b/Dockerfile index 2415b7b..02b5836 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM wordpress:5.3.2-php7.2-apache +FROM wordpress:6.0.2-php8.0-apache RUN apt-get update && \ apt-get install -y --no-install-recommends ssl-cert && \ @@ -6,22 +6,17 @@ RUN apt-get update && \ a2enmod ssl rewrite expires && \ a2ensite default-ssl -ENV PHP_INI_PATH "/usr/local/etc/php/php.ini" +ENV PHP_INI_PATH /usr/local/etc/php/php.ini +ENV PHP_XDEBUG_ENABLED: 1 + +RUN echo "zend_extension=$(find /usr/lib/php/ -name xdebug.so)" >> ${PHP_INI_PATH} \ + && echo "xdebug.mode=coverage,debug" >> ${PHP_INI_PATH} \ + && echo "xdebug.client_port=9003" >> ${PHP_INI_PATH} \ + && echo "xdebug.client_host=host.docker.internal" >> ${PHP_INI_PATH} \ + && echo "xdebug.start_with_request=yes" >> ${PHP_INI_PATH} \ + && echo "xdebug.log=/tmp/xdebug.log" >> ${PHP_INI_PATH} \ + && echo "xdebug.idekey=IDE_DEBUG" >> ${PHP_INI_PATH} -RUN pecl install xdebug-2.6.1 \ - && docker-php-ext-enable xdebug \ - && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" >> ${PHP_INI_PATH} \ - && echo "xdebug.remote_port=9000" >> ${PHP_INI_PATH} \ - && echo "xdebug.remote_enable=1" >> ${PHP_INI_PATH} \ - && echo "xdebug.remote_connect_back=0" >> ${PHP_INI_PATH} \ - && echo "xdebug.remote_host=docker.for.mac.localhost" >> ${PHP_INI_PATH} \ - && echo "xdebug.idekey=IDEA_DEBUG" >> ${PHP_INI_PATH} \ - && echo "xdebug.remote_autostart=1" >> ${PHP_INI_PATH} \ - && echo "xdebug.remote_log=/tmp/xdebug.log" >> ${PHP_INI_PATH} \ - && echo "xdebug.profiler_enable_trigger=1" >> ${PHP_INI_PATH} \ - && echo "log_errors = On" >> ${PHP_INI_PATH} \ - && echo "error_reporting = E_ALL" >> ${PHP_INI_PATH} \ - && echo "error_log=/var/www/php_error.log" >> ${PHP_INI_PATH} EXPOSE 80 EXPOSE 443 diff --git a/Makefile b/Makefile index 973cb32..0d0b349 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,30 @@ +COMMIT := $(shell git rev-parse --short=8 HEAD) +ZIP_FILENAME := $(or $(ZIP_FILENAME),"bmlt-build-file.zip") +BUILD_DIR := $(or $(BUILD_DIR),"build") VENDOR_AUTOLOAD := vendor/autoload.php help: ## Print the help documentation @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' +.PHONY: build +build: ## Build + git archive --format=zip --output=${ZIP_FILENAME} $(COMMIT) + mkdir ${BUILD_DIR} && mv ${ZIP_FILENAME} ${BUILD_DIR}/ + +.PHONY: clean +clean: ## clean + rm -rf build dist + $(VENDOR_AUTOLOAD): - composer install + composer install --prefer-dist --no-progress --no-suggest .PHONY: composer composer: $(VENDOR_AUTOLOAD) ## Runs composer install -.PHONY: dev -run: ## Docker Run - docker-compose up --build - .PHONY: lint -lint: composer ## Lint - vendor/squizlabs/php_codesniffer/bin/phpcs --warning-severity=6 --standard=PSR2 --ignore=vendor --extensions=php --report=full . +lint: composer ## PHP Lint + vendor/squizlabs/php_codesniffer/bin/phpcs .PHONY: lint-fix -lint-fix: composer ## Lint Fix - vendor/squizlabs/php_codesniffer/bin/phpcbf --warning-severity=6 --standard=PSR2 --ignore=vendor --extensions=php --report=full . +lint-fix: composer ## PHP Lint Fix + vendor/squizlabs/php_codesniffer/bin/phpcbf diff --git a/README.md b/README.md index 7d20882..fa2968a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ This section describes how to install the plugin and get it working. # Changelog += 1.7.1 = +* Update user agent. + += 1.7.0 = +* Modified simple shortcode to display main bmlt apps and relevant info for bmlt.app + = 1.6.1 = * Fix for simple. diff --git a/bmlt-versions/bmlt-versions.php b/bmlt-versions.php similarity index 99% rename from bmlt-versions/bmlt-versions.php rename to bmlt-versions.php index 3c8ddb7..53e861d 100644 --- a/bmlt-versions/bmlt-versions.php +++ b/bmlt-versions.php @@ -5,7 +5,7 @@ Description: A simple content generator to display the versions and links of the various BMLT components. Add [bmlt_versions] to a page or a post to generate the list. Author: BMLT Authors Author URI: https://bmlt.app -Version: 1.6.1 +Version: 1.7.1 Install: Drop this directory into the "wp-content/plugins/" directory and activate it. */ /* Disallow direct access to the plugin file */ @@ -635,7 +635,7 @@ public function get($url, $cookies = null) $args = array( 'timeout' => '120', 'headers' => array( - 'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) +bmltVersions', + 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Firefox/105.0 +bmltVersions', 'Authorization' => "token $gitHubApiKey" ), 'cookies' => isset($cookies) ? $cookies : null diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..2504483 --- /dev/null +++ b/composer.lock @@ -0,0 +1,75 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "38a0c58c5584ad0dd5458c04c5e1129c", + "packages": [], + "packages-dev": [ + { + "name": "squizlabs/php_codesniffer", + "version": "3.7.1", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2022-06-18T07:21:10+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.3.0" +} diff --git a/bmlt-versions/css/bmlt-versions.css b/css/bmlt-versions.css similarity index 100% rename from bmlt-versions/css/bmlt-versions.css rename to css/bmlt-versions.css diff --git a/bmlt-versions/css/images/drupal.png b/css/images/drupal.png similarity index 100% rename from bmlt-versions/css/images/drupal.png rename to css/images/drupal.png diff --git a/bmlt-versions/css/images/github.png b/css/images/github.png similarity index 100% rename from bmlt-versions/css/images/github.png rename to css/images/github.png diff --git a/bmlt-versions/css/images/wordpress.png b/css/images/wordpress.png similarity index 100% rename from bmlt-versions/css/images/wordpress.png rename to css/images/wordpress.png diff --git a/docker-compose.yml b/docker-compose.yml index 292ff6d..3c8fd77 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,20 +2,27 @@ version: '3.1' services: wordpress: + depends_on: + - db build: . restart: always ports: - 8080:80 - 7443:443 environment: - WORDPRESS_DB_PASSWORD: example - VIRTUAL_HOST: localhost + WORDPRESS_DB_HOST: db:3306 + WORDPRESS_DB_USER: wordpress + WORDPRESS_DB_PASSWORD: wordpress + WORDPRESS_DB_NAME: wordpress volumes: - - ../bmlt-versions:/var/www/html/wp-content/plugins + - ../:/var/www/html/wp-content/plugins - ./logs/:/var/log/apache2 - mysql: + db: image: mysql:5.7 restart: always environment: - MYSQL_ROOT_PASSWORD: example + MYSQL_ROOT_PASSWORD: somewordpress + MYSQL_DATABASE: wordpress + MYSQL_USER: wordpress + MYSQL_PASSWORD: wordpress diff --git a/bmlt-versions/index.php b/index.php similarity index 100% rename from bmlt-versions/index.php rename to index.php diff --git a/bmlt-versions/license.txt b/license.txt similarity index 100% rename from bmlt-versions/license.txt rename to license.txt diff --git a/bmlt-versions/readme.txt b/readme.txt similarity index 98% rename from bmlt-versions/readme.txt rename to readme.txt index 8ea65e0..07c5e2a 100644 --- a/bmlt-versions/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: pjaudiomv, radius314 Tags: bmlt, meeting list Tested up to: 5.6.0 -Stable tag: 1.6.1 +Stable tag: 1.7.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -35,6 +35,9 @@ This section describes how to install the plugin and get it working. == Changelog == += 1.7.1 = +* Update user agent. + = 1.7.0 = * Modified simple shortcode to display main bmlt apps and relevant info for bmlt.app