Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #1

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b9dbb8e
refactored - into a class
SteveJonesDev Mar 4, 2024
fe90745
added - npm, composer, linting, and test framework
SteveJonesDev Mar 4, 2024
0447ac0
removed - cs step
SteveJonesDev Mar 4, 2024
61dc6ca
updated - bootstrap path
SteveJonesDev Mar 4, 2024
f52d149
added - README.md
SteveJonesDev Mar 4, 2024
bf9db0c
updated - url
SteveJonesDev Mar 4, 2024
532d9ab
Removed - lint badge
SteveJonesDev Mar 4, 2024
ca6d06b
added - unit tests
SteveJonesDev Mar 4, 2024
d0b3174
updated - test file name
SteveJonesDev Mar 4, 2024
b0e1512
included - void
SteveJonesDev Mar 4, 2024
e4500e6
removed - load_plugin_textdomain method and test
SteveJonesDev Mar 4, 2024
b2d4a6b
added - assertion to test_init
SteveJonesDev Mar 4, 2024
fe938b6
updated - dist files
SteveJonesDev Mar 4, 2024
85547a2
fixed - class namespace
SteveJonesDev Mar 7, 2024
156e4c9
updated - readme
SteveJonesDev Jun 5, 2024
50978f6
updated - dist to include vendor folder
SteveJonesDev Jun 5, 2024
9b96ad1
updated - composer
SteveJonesDev Jun 5, 2024
f900288
added - github files
SteveJonesDev Jun 6, 2024
9dcc150
added - playground workflow
SteveJonesDev Jun 6, 2024
6898d52
update - playground workflow
SteveJonesDev Jun 6, 2024
087b898
updated - playground workflow to create a contributor user
SteveJonesDev Jun 6, 2024
dd0066d
added - script to create a user
SteveJonesDev Jun 6, 2024
6da30af
reverted - workflow
SteveJonesDev Jun 6, 2024
ba5b830
updated - playground workflow to build the zip
SteveJonesDev Jun 6, 2024
118582e
fixed - message input
SteveJonesDev Jun 6, 2024
89dcf0a
reverted - workflow
SteveJonesDev Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[*.{yml,yaml}]
indent_style = space
indent_size = 2

[*.{gradle,java,kt}]
indent_style = space

[packages/react-native-*/**.xml]
indent_style = space

51 changes: 51 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Contribution Guidelines

Before filing a bug report or a feature request, be sure to read the contribution guidelines.

## How to use GitHub
We use GitHub exclusively for well-documented bugs, feature requests and code contributions. Communication is always done in English.

To receive free support for Enable Contributor Uploads:
* [Support forums](https://wordpress.org/support/plugin/enable-contributor-uploads/) on WordPress.org

Thanks for your understanding.

## Security issues
Please do not report security issues here. Instead, email them to security at our domain so we can deal with them securely and quickly.

## I have found a bug
Before opening a new issue, please:
* update to the newest versions of WordPress and the Enable Contributor Uploads plugins.
* search for duplicate issues to prevent opening a duplicate issue. If there is already an open existing issue, please comment on that issue.
* follow our _New issue_ template when creating a new issue.
* add as much information as possible. For example: add screenshots, relevant links, step by step guides etc.

## I have a feature request
Before opening a new issue, please:
* search for duplicate issues to prevent opening a duplicate feature request. If there is already an open existing request, please leave a comment there.
* add as much information as possible. For example: give us a clear explanation of why you think the feature request is something we should consider for the plugin.

## I want to create a patch
Community made patches, localizations, bug reports and contributions are very welcome and help us tremendously.

When contributing please ensure you follow the guidelines below so that we can keep on top of things.

#### Submitting an issue you found
Make sure your problem does not exist as a ticket already by searching through [the existing issues](https://github.com/equalizedigital/enable-contributor-uploads/issues). If you cannot find anything which resembles your problem, please [create a new issue](https://github.com/equalizedigital/enable-contributor-uploads/issues/new).

#### Fixing an issue

* Fork the repository on GitHub (make sure to use the `develop` branch).
* Make the changes to your forked repository.
* Ensure you stick to the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/) and you properly document any new functions, actions and filters following the [documentation standards](https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/).
* When committing, reference your issue and include a note about the fix.
* Push the changes to your fork and submit a pull request to the `develop` branch of the Enable Contributor Uploads repository.

We will review your pull request and merge when everything is in order. We will help you to make sure the code complies with the standards described above.

#### 'Patch welcome' issues
Some issues are labeled 'patch-welcome'. This means we see the value in the particular enhancement being suggested but have decided for now not to prioritize it. If you however decide to write a patch for it, we'll gladly include it after some code review.

#### Additional Resources
* [General GitHub Documentation](https://help.github.com/)
* [GitHub Pull Request documentation](https://help.github.com/send-pull-requests/)
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve

---

<!-- Please use this template when creating an issue.
- Please check the boxes after you've created your issue.
- Please use the latest version of Enable Contributor Uploads.-->

* [ ] I've read and understood the [contribution guidelines](https://github.com/equalizedigital/enable-contributor-uploads/blob/develop/.github/CONTRIBUTING.md).
* [ ] I've searched for any related issues and avoided creating a duplicate issue.

### Please give us a description of what happened.




### Please describe what you expected to happen and why.




### How can we reproduce this behavior?
1.
2.
3.

### Technical info
* WordPress version:
* Enable Contributor Uploads version:

* Relevant plugins in case of a bug:
<!-- Please make sure you can reproduce this bug with a default theme such as Twenty Seventeen. Sometimes issues may occur due to theme conflicts. -->
* Tested with theme:
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Feature request
about: Suggest an idea for this project

---

<!-- Before opening a new issue, please search for duplicate issues to prevent opening a duplicate feature request. If there is already an open existing request, please leave a comment there. -->

## Is your feature request related to a problem? Please describe.

## Describe the solution you'd like

## Why do you think this feature is something we should consider for this plugin?

## Additional context
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
58 changes: 58 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CS

on:
# Run on all pushes (except to main) and on all pull requests.
push:
branches:
- '*'
pull_request:
branches:
- '*'
# Allow manually triggering the workflow.
workflow_dispatch:

# 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:
checkcs:
name: 'Check code style'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: cs2pr

# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- name: Validate Composer installation
run: composer validate --no-check-all

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
# Bust the cache at least once a month - output format: YYYY-MM-DD.
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")

# Check the codestyle of the files.
# The results of the CS check will be shown inline in the PR via the CS2PR tool.
# @link https://github.com/staabm/annotate-pull-request-from-checkstyle/
- name: Check PHP code style
id: phpcs
run: composer check-cs -- --report-full --report-checkstyle=./phpcs-report.xml --ignore=vendor

- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./phpcs-report.xml
72 changes: 72 additions & 0 deletions .github/workflows/lint-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Lint PHP

on:
# Run on pushes to select branches and on all pull requests.
push:
branches:
- master
- develop
- trunk
- 'feature/**'
- 'release/**'
- 'hotfix/[0-9]+.[0-9]+*'
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

# 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:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
# Lint against the highest/lowest supported versions of each PHP major.
# And also do a run against "nightly" (the current dev version of PHP).
php_version: ['7.4', '8.0', '8.1', '8.2']

name: "Lint: PHP ${{ matrix.php_version }}"

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install PHP for the composer install
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none

# The lint stage doesn't run the unit tests or use code style, so no need for PHPUnit, WPCS or phpcompatibility.
- name: 'Composer: adjust dependencies - remove PHPUnit'
run: composer remove --no-update --dev phpunit/phpunit --no-scripts --no-interaction
- name: 'Composer: adjust dependencies - remove Yoast test urils'
run: composer remove --no-update --dev yoast/wp-test-utils --no-scripts --no-interaction
- name: 'Composer: adjust dependencies - remove PHPCompatibility'
run: composer remove --no-update --dev phpcompatibility/phpcompatibility-wp --no-scripts --no-interaction
- name: 'Composer: adjust dependencies - remove WPCS'
run: composer remove --no-update --dev wp-coding-standards/wpcs --no-scripts --no-interaction

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
# Bust the cache at least once a month - output format: YYYY-MM-DD.
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")

- name: Install PHP for the actual test
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: none
tools: cs2pr

- name: Lint against parse errors
run: composer lint -- --checkstyle | cs2pr
90 changes: 90 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Test

on:
# Run on pushes to select branches and on all pull requests.
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

# 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:
integration:
runs-on: ubuntu-latest

strategy:
matrix:
include:
- php_version: '8.1'
wp_version: '6.2'
multisite: false

- php_version: '8.1'
wp_version: 'latest'
multisite: false

- php_version: '8.1'
wp_version: 'latest'
multisite: true

- php_version: '8.2'
wp_version: 'latest'
multisite: true

name: "Integration Test: PHP ${{ matrix.php_version }} | WP ${{ matrix.wp_version }}${{ matrix.multisite == true && ' (+ ms)' || '' }}"

# Allow builds to fail on as-of-yet unreleased WordPress versions.
continue-on-error: ${{ matrix.wp_version == 'trunk' }}

services:
mysql:
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: none

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: "Composer: remove the PHP platform requirement"
run: composer config --unset platform.php

- name: "Install Composer dependencies"
uses: ramsey/composer-install@v2
with:
# Force a `composer update` run.
dependency-versions: "highest"
# But make it selective.
composer-options: "yoast/wp-test-utils --with-dependencies"
# Bust the cache at least once a month - output format: YYYY-MM-DD.
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")

- name: Install WP
shell: bash
run: tests/bin/install-wp-tests.sh wordpress_tests root '' 127.0.0.1:3306 ${{ matrix.wp_version }}

- name: Run unit tests - single site
run: composer test

- name: Run unit tests - multisite
if: ${{ matrix.multisite == true }}
run: composer test
env:
WP_MULTISITE: 1
34 changes: 34 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Security

on:
# Run on all pushes and on all pull requests.
push:
pull_request:
# Also run this workflow every Monday at 6:00.
schedule:
- cron: '0 6 * * 1'
# Allow manually triggering the workflow.
workflow_dispatch:

# 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:
security:
name: 'Security check'
runs-on: ubuntu-latest

# Don't run the cronjob in this workflow on forks.
if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'Yoast')

steps:
- name: Checkout code
uses: actions/checkout@v3

# This action checks the `composer.lock` file against known security vulnerabilities in the dependencies.
# https://github.com/marketplace/actions/the-php-security-checker
- name: Run Security Check
uses: symfonycorp/security-checker-action@v5
Loading
Loading