Skip to content

Commit

Permalink
Dropping support for PHP 7.4 (#13)
Browse files Browse the repository at this point in the history
* Update dependencies for PHP >= 8.0.

Add dev dependencies for GitHub Actions and linting.

* Version 0.7.0.

* Update README.

* Add new GitHub Actions workflows.

* Code updates for PHP 8.0

* Disable install shell.

* Add phpcs-ruleset
  • Loading branch information
thefrosty committed Nov 2, 2023
1 parent b1cb65e commit ce84cc3
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 16 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: weekly
target-branch: "develop"
open-pull-requests-limit: 10
75 changes: 75 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Main PHP Version(s) CI

on:
push:
branches:
- develop
pull_request:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Test:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.0', '8.1', '8.2' ]
wp-versions: [ 'latest' ]
coverage: [ true ]
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: wordpress_test
MYSQL_PASSWORD: password
MYSQL_USER: wp
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10

name: WP ${{ matrix.wp-versions }} on PHP ${{ matrix.php-versions }}
env:
WORDPRESS_DB_NAME: wordpress_test
WORDPRESS_DB_PASS: password
WORDPRESS_DB_USER: wp
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # No shallow clone, we need all history!

- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mysql, mysqli
coverage: xdebug
tools: composer, cs2pr, phpunit

# - name: Setup WordPress ${{ matrix.wp-versions }}
# run: bash bin/install-wp-tests.sh wordpress_test wp password localhost ${{ matrix.wp-versions }} true

- name: Install dependencies
run: composer update --prefer-dist --no-interaction

- name: Create all branches
run: source ./vendor/thefrosty/wp-utilities/bin/create-all-branches.sh

- name: Run composer tests
run: composer tests
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}

- name: Show PHPCS results in PR
run: cs2pr ./phpcs-report.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false
84 changes: 84 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
####################################################################################
# GitHub Action:
# Whenever creating a new release of the source code.
####################################################################################
# Steps to execute:
# - Checkout the source code
# - Run "composer install" for production (required dependencies are already under vendor/)
# - Create a .zip file, excluding:
# - All hidden files (.git, .gitignore, etc)
# - All development files, ending in .dist or .xml
# - All composer files <= after installing dependencies, no need for them anymore
# - Markdown files concerning development
# - JS Package files.
# - Folder build/ <= created only to store the .zip file
# - Folder bin/ <= not needed for the plugin
# - Folder tests/ <= not needed for the plugin
# - Upload the .zip file as an artifact to the action (this step is possibly optional)
# - Upload the .zip file as a release, for download
####################################################################################
name: Generate Installable Plugin and Upload as Release Asset

on:
release:
types: [ published ]

jobs:
Build:
name: Build and Upload Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set Release Version env
run: |
VERSION=${{ github.event.release.tag_name }}
echo "Release Version: ${VERSION//v}"
echo "RELEASE_VERSION=${VERSION//v}" >> $GITHUB_ENV
# see https://github.com/shivammathur/setup-php
- name: Use PHP 8.0
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build project for production
run: |
echo "Release Version: ${{ github.event.release.tag_name }}"
composer update --no-dev --optimize-autoloader
mkdir build
- name: Create artifact
uses: montudor/action-zip@v0.1.1
with:
args: zip -X -r build/wp-email-download.zip . -x *.git* bin** node_modules/\* .* "*/\.*" *.dist *.xml composer.* package*.json tests** build**

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: wp-email-download
path: build/wp-email-download.zip

- name: Upload to release
uses: JasonEtco/upload-to-release@master
with:
args: build/wp-email-download.zip application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token

- name: Duplicate asset for GitHub Updater
# @see https://github.com/afragen/github-updater/wiki/Settings#release-assets
uses: montudor/action-zip@v0.1.1
with:
args: zip -X -r build/wp-email-download-${{ env.RELEASE_VERSION }}.zip . -x *.git* bin** node_modules/\* .* "*/\.*" *.dist *.xml composer.* package*.json tests** build**

- name: Upload duplicate to release
uses: JasonEtco/upload-to-release@master
with:
args: build/wp-email-download-${{ env.RELEASE_VERSION }}.zip application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
[![Latest Stable Version](https://img.shields.io/packagist/v/dwnload/wp-email-download.svg)](https://packagist.org/packages/dwnload/wp-email-download)
[![Total Downloads](https://img.shields.io/packagist/dt/dwnload/wp-email-download.svg)](https://packagist.org/packages/dwnload/wp-email-download)
[![License](https://img.shields.io/packagist/l/dwnload/wp-email-download.svg)](https://packagist.org/packages/dwnload/wp-email-download)
[![Build Status](https://travis-ci.org/dwnload/wp-email-download.svg?branch=master)](https://travis-ci.org/dwnload/wp-email-download)
![Build Status](https://github.com/dwnload/wp-email-download/actions/workflows/main.yml/badge.svg)

### Allow users to download any WordPress managed file if they're subscribed to your MailChimp list

**Contributors:** [thefrosty](https://github.com/thefrosty)
**Tags**: wordpress-plugin, downloader, email-subscription, mailchimp, wp-api
**Requires at least:** 5.7
**Tested up to**: 5.8
**Requires PHP**: 7.4.0
**Requires at least:** 6.1
**Tested up to**: 6.3
**Requires PHP**: 8.0
**Stable tag**: master
**License**: GPLv2 or later
**License URI**: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down
35 changes: 30 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,37 @@
"config": {
"allow-plugins": {
"composer/installers": true,
"roots/wordpress-core-installer": true
"roots/wordpress-core-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true
},
"optimize-autoloader": true,
"platform": {
"php": "7.4"
"php": "8.0"
},
"preferred-install": "dist",
"sort-packages": true
},
"require": {
"php": "^7.4 || ^8.0",
"php": "~8.0",
"drewm/mailchimp-api": "2.4",
"dwnload/wp-settings-api": "^3.3",
"egulias/email-validator": "~2.1",
"thefrosty/wp-utilities": "^2.8",
"thefrosty/wp-utilities": "^3.2",
"ext-openssl": "*",
"ext-json": "*"
},
"require-dev": {
"roots/wordpress": "~5.8.1"
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"ext-simplexml": "*",
"phpunit/php-code-coverage": "^9",
"phpcompatibility/php-compatibility": "*",
"phpunit/phpunit": "^9",
"roave/security-advisories": "dev-master",
"roots/wordpress": "~6.3",
"slevomat/coding-standard": "~8.14",
"squizlabs/php_codesniffer": "^3.2",
"wp-phpunit/wp-phpunit": "^6.0.0",
"yoast/phpunit-polyfills": "^1.0.5 || ^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -43,5 +54,19 @@
"files": [
"src/includes/functions.php"
]
},
"scripts": {
"install-codestandards": [
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
],
"phpcs": [
"bash ./vendor/thefrosty/wp-utilities/bin/phpcs.sh"
],
"phpmd": [
"bash ./vendor/thefrosty/wp-utilities/bin/phpmd.sh"
],
"tests": [
"@phpcs"
]
}
}
8 changes: 4 additions & 4 deletions email-download.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Plugin Name: Email Download
* Plugin URI: https://github.com/dwnload/wp-email-download
* Description: Allow users to download any WordPress managed file if they're subscribed to you MailChimp list.
* Version: 0.6.3
* Requires PHP: 7.4
* Version: 0.7.0
* Requires PHP: 8.0
* Author: Austin Passy
* Author URI: https://austin.passy.co
* Text Domain: email-download
Expand All @@ -13,12 +13,12 @@
* Primary Branch: master
* Release Asset: true
*
* Copyright (c) 2019 - 2022 Passy.co, LLC (https://passy.co/)
* Copyright (c) 2019 - 2024 Passy.co, LLC (https://passy.co/)
*/

use Dwnload\WpEmailDownload\EmailDownload;

if (version_compare(phpversion(), '7.4', '>=')) {
if (version_compare(phpversion(), '8.0', '>=')) {
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
}
Expand Down
41 changes: 41 additions & 0 deletions phpcs-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0"?>
<ruleset name="WP-Email-Download" namespace="Dwnload\WpEmailDownload">

<description>Coding Standards for the WP Email Download codebase.</description>

<!-- What to scan -->
<file>src</file>
<!-- Exclude the tests directory. -->
<exclude-pattern>*/tests/*</exclude-pattern>
<!-- Third-party code -->
<exclude-pattern>*/bower-components/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- Ensure certain file types aren't sniffed -->
<exclude-pattern>*.js</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>

<!-- How to scan -->
<arg value="sp"/> <!-- Show sniff and progress -->
<arg name="basepath" value="."/><!-- Strip the file paths down to the relevant bit -->
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="tab-width" value="4"/>
<!-- For CI, don't fail on warnings -->
<config name="ignore_warnings_on_exit" value="1"/>
<config name="minimum_supported_wp_version" value="6.2" />

<rule ref="PSR12">
<exclude name="PSR12.Classes.OpeningBraceSpace.Found"/>
<exclude name="PSR12.Files.FileHeader.IncorrectOrder"/>
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
<exclude name="PSR12.Files.OpenTag.NotAlone"/>
<exclude name="PSR12.Traits.UseDeclaration.MultipleImport"/>
<exclude name="PSR12.Traits.UseDeclaration.UseAfterBrace"/>
</rule>

<!-- Loads the PHP Compatibility ruleset. -->
<rule ref="PHPCompatibility" />
<!-- Check for cross-version support for PHP 8.0 and higher. -->
<config name="testVersion" value="8.0-"/>
</ruleset>
4 changes: 2 additions & 2 deletions src/EmailDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class EmailDownload
/**
* Initiate all class hookups.
*/
public function hookup()
public function hookup(): void
{
$settings = SettingsApiFactory::create([
'domain' => 'email-download',
Expand All @@ -61,7 +61,7 @@ public function hookup()
/**
* @param string $file
*/
public static function setFile(string $file)
public static function setFile(string $file): void
{
self::$file = $file;
}
Expand Down
2 changes: 1 addition & 1 deletion src/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function version_error()
function php_version_text()
{
return sprintf(
esc_html__('%s plugin error: Your version of PHP is too old to run this plugin. You must be running PHP 7.4 or higher.',
esc_html__('%s plugin error: Your version of PHP is too old to run this plugin. You must be running PHP 8.0 or higher.',
'email-download'),
PLUGIN_NAME
);
Expand Down

0 comments on commit ce84cc3

Please sign in to comment.