Skip to content

Commit 4dd5624

Browse files
authored
New workflows part 1
1 parent 4e664f9 commit 4dd5624

5 files changed

Lines changed: 385 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: PHP {{ env.PHP_VERSION }} Compatibility Test Failure
3+
labels: bug, compatibility, automated
4+
assignees: []
5+
---
6+
7+
## PHP Compatibility Test Failure
8+
9+
The automated compatibility test for PHP {{ env.PHP_VERSION }} has failed.
10+
11+
### Details
12+
13+
- **PHP Version:** {{ env.PHP_VERSION }}
14+
- **WordPress Version:** Latest
15+
- **Test Date:** {{ date | date('YYYY-MM-DD HH:mm:ss') }}
16+
- **Workflow Run:** [View detailed logs]({{ env.WORKFLOW_URL }})
17+
18+
### Next Steps
19+
20+
This issue has been automatically created because the Simple WP Optimizer plugin failed to load properly with PHP {{ env.PHP_VERSION }}. This could indicate compatibility issues that need to be addressed.
21+
22+
#### Recommended Actions:
23+
24+
1. Review the workflow logs for specific error messages
25+
2. Check for PHP {{ env.PHP_VERSION }} specific syntax or function compatibility issues
26+
3. Test locally with PHP {{ env.PHP_VERSION }} to reproduce the issue
27+
4. Make necessary code updates to ensure compatibility
28+
29+
Once fixed, please close this issue and reference it in the changelog.
30+
31+
---
32+
33+
*This issue was automatically generated by the PHP Compatibility WordPress Test workflow.*
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: WordPress Plugin Check Failure
3+
labels: bug, plugin-check, automated
4+
assignees: []
5+
---
6+
7+
## WordPress Plugin Check Failure
8+
9+
The WordPress Plugin Check action has identified issues with the Simple WP Optimizer plugin.
10+
11+
### Details
12+
13+
- **Test Date:** {{ date | date('YYYY-MM-DD HH:mm:ss') }}
14+
- **Workflow Run:** [View detailed logs]({{ env.WORKFLOW_URL }})
15+
16+
### Next Steps
17+
18+
This issue has been automatically created because the WordPress Plugin Check found issues with the plugin that should be addressed. The check performed the following specific tests:
19+
20+
#### Categories:
21+
- **Accessibility**: Checks for accessibility compliance issues
22+
- **General**: General WordPress coding standards and best practices
23+
- **Performance**: Tests that identify performance bottlenecks
24+
- **Plugin Repo**: Requirements for WordPress.org plugin repository
25+
- **Security**: Security-focused checks to identify vulnerabilities
26+
27+
#### Specific Checks:
28+
- **i18n_usage**: Proper internationalization usage
29+
- **code_obfuscation**: Detecting potentially obfuscated code
30+
- **direct_db_queries**: Identifying direct database queries that bypass WordPress APIs
31+
- **enqueued_scripts_in_footer**: Ensuring scripts are properly enqueued in the footer
32+
- **enqueued_scripts_size**: Checking for excessively large script files
33+
- **enqueued_styles_scope**: Ensuring styles are properly scoped
34+
- **file_type**: Checking for proper file types and formats
35+
- **late_escaping**: Ensuring output is properly escaped
36+
- **localhost**: Checking for references to localhost or development environments
37+
- **no_unfiltered_uploads**: Ensuring uploads are properly filtered
38+
- **performant_wp_query_params**: Checking for inefficient WP_Query parameters
39+
- **plugin_header_text_domain**: Verifying correct text domain in plugin header
40+
- **plugin_readme**: Checking the plugin readme file format
41+
- **plugin_review_phpcs**: PHP CodeSniffer checks for WordPress standards
42+
- **plugin_updater**: Checking plugin update mechanisms
43+
- **trademarks**: Checking for potential trademark violations
44+
45+
#### Recommended Actions:
46+
47+
1. Review the workflow logs for specific error messages and warnings
48+
2. Address each identified issue in the plugin code
49+
3. Test locally using the [WordPress Plugin Check tool](https://github.com/WordPress/plugin-check) to verify fixes
50+
4. Submit a pull request with the necessary changes
51+
52+
Once all issues are fixed, please close this issue and reference it in the changelog.
53+
54+
### About WordPress Plugin Check
55+
56+
The WordPress Plugin Check tool helps plugin authors create plugins that follow WordPress best practices. It checks for issues related to security, performance, and compatibility to ensure plugins work well in the WordPress ecosystem.
57+
58+
---
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# This workflow runs continuous integration checks on the Simple WP Optimizer plugin.
2+
# It performs code linting for both PHP and JavaScript files and builds the plugin package.
3+
# The workflow is triggered on push to main branch and on pull requests to ensure code quality.
4+
# It creates and stores a plugin zip file as an artifact that can be used for testing.
5+
6+
name: Continuous Integration
7+
8+
on:
9+
push:
10+
branches: [ main ]
11+
pull_request:
12+
branches: [ main ]
13+
14+
# Define explicit permissions to follow principle of least privilege
15+
permissions:
16+
contents: read # Allows read access to repository contents
17+
actions: read # Allows read access to GitHub Actions
18+
checks: write # Allows creating/updating checks on the workflow run
19+
pull-requests: write # Allows commenting on PRs for feedback
20+
packages: read # Allows reading packages
21+
22+
jobs:
23+
lint:
24+
name: Lint PHP and JavaScript
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Setup PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: '7.4'
34+
tools: composer:v2, phpcs
35+
36+
- name: Check for package-lock.json
37+
id: check-lockfile
38+
run: |
39+
if [ -f "package-lock.json" ]; then
40+
echo "lockfile_exists=true" >> $GITHUB_OUTPUT
41+
else
42+
echo "lockfile_exists=false" >> $GITHUB_OUTPUT
43+
echo "package-lock.json not found. Caching will be skipped."
44+
fi
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: '16'
50+
# Use conditional caching based on package-lock.json existence
51+
cache: ${{ steps.check-lockfile.outputs.lockfile_exists == 'true' && 'npm' || '' }}
52+
cache-dependency-path: |
53+
**/package-lock.json
54+
!**/node_modules/
55+
56+
- name: Install PHP dependencies
57+
run: |
58+
if [ -f composer.json ]; then
59+
# Configure platform to ensure compatibility
60+
composer config platform.php 7.4
61+
composer install --prefer-dist --no-progress || {
62+
echo "Standard install failed, trying with --ignore-platform-reqs"
63+
composer install --prefer-dist --no-progress --ignore-platform-reqs
64+
}
65+
else
66+
echo "No composer.json found. Skipping composer install."
67+
fi
68+
69+
- name: Install JS dependencies
70+
run: |
71+
if [ -f package.json ]; then
72+
npm ci || npm install
73+
else
74+
echo "No package.json found. Skipping npm install."
75+
fi
76+
77+
- name: Lint PHP
78+
run: |
79+
if [ -f composer.json ] && ([ -f .phpcs.xml ] || [ -f phpcs.xml.dist ]); then
80+
if grep -q "\"lint:php\"" composer.json; then
81+
composer run lint:php
82+
else
83+
echo "No lint:php script found in composer.json. Skipping."
84+
fi
85+
else
86+
echo "No PHP linting configuration found. Skipping."
87+
fi
88+
89+
- name: Lint JavaScript
90+
run: |
91+
if [ -f package.json ] && ([ -f .eslintrc.js ] || [ -f .eslintrc.json ]); then
92+
npm run lint:js || echo "Lint script not found in package.json. Skipping."
93+
else
94+
echo "No JS linting configuration found. Skipping."
95+
fi
96+
97+
build:
98+
name: Build Plugin
99+
runs-on: ubuntu-latest
100+
needs: lint
101+
steps:
102+
- name: Checkout code
103+
uses: actions/checkout@v4
104+
105+
- name: Check for package-lock.json in build
106+
id: check-lockfile-build
107+
run: |
108+
if [ -f "package-lock.json" ]; then
109+
echo "lockfile_exists=true" >> $GITHUB_OUTPUT
110+
else
111+
echo "lockfile_exists=false" >> $GITHUB_OUTPUT
112+
echo "package-lock.json not found. Caching will be skipped."
113+
fi
114+
115+
- name: Setup Node.js
116+
uses: actions/setup-node@v4
117+
with:
118+
node-version: '16'
119+
# Use conditional caching based on package-lock.json existence
120+
cache: ${{ steps.check-lockfile-build.outputs.lockfile_exists == 'true' && 'npm' || '' }}
121+
cache-dependency-path: |
122+
**/package-lock.json
123+
!**/node_modules/
124+
125+
- name: Setup PHP
126+
uses: shivammathur/setup-php@v2
127+
with:
128+
php-version: '7.4'
129+
tools: composer:v2
130+
131+
- name: Install dependencies
132+
run: |
133+
if [ -f composer.json ]; then
134+
# Configure platform to ensure compatibility
135+
composer config platform.php 7.4
136+
composer install --no-dev --prefer-dist --no-progress || {
137+
echo "Standard install failed, trying with --ignore-platform-reqs"
138+
composer install --no-dev --prefer-dist --no-progress --ignore-platform-reqs
139+
}
140+
else
141+
echo "No composer.json found. Skipping composer install."
142+
fi
143+
144+
if [ -f package.json ]; then
145+
npm ci || npm install
146+
else
147+
echo "No package.json found. Skipping npm install."
148+
fi
149+
150+
- name: Build frontend assets
151+
run: |
152+
if [ -f package.json ]; then
153+
if grep -q "\"build\"" package.json; then
154+
npm run build
155+
else
156+
echo "No build script found in package.json. Skipping."
157+
fi
158+
else
159+
echo "No package.json found. Skipping build."
160+
fi
161+
162+
- name: Create plugin package
163+
run: |
164+
mkdir -p build/simple-wp-optimizer
165+
166+
# Copy main plugin file
167+
cp simple-wp-optimizer.php build/simple-wp-optimizer/
168+
169+
# Copy directories if they exist
170+
[ -d assets ] && cp -r assets build/simple-wp-optimizer/ || echo "No assets directory found"
171+
[ -d includes ] && cp -r includes build/simple-wp-optimizer/ || echo "No includes directory found"
172+
[ -d languages ] && cp -r languages build/simple-wp-optimizer/ || echo "No languages directory found"
173+
[ -d templates ] && cp -r templates build/simple-wp-optimizer/ || echo "No templates directory found"
174+
175+
# Copy additional files if they exist
176+
[ -f readme.txt ] && cp readme.txt build/simple-wp-optimizer/ || echo "No readme.txt found"
177+
[ -f LICENSE ] && cp LICENSE build/simple-wp-optimizer/ || echo "No LICENSE file found"
178+
179+
# Create zip file
180+
cd build
181+
zip -r simple-wp-optimizer.zip simple-wp-optimizer
182+
183+
- name: Upload build artifact
184+
uses: actions/upload-artifact@v4
185+
with:
186+
name: simple-wp-optimizer
187+
path: build/simple-wp-optimizer.zip
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: WordPress Plugin Check
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
# Allow manually triggering the workflow
8+
workflow_dispatch:
9+
10+
# Cancels all previous workflow runs for the same branch that have not yet completed
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
issues: write
18+
19+
jobs:
20+
plugin-check:
21+
name: WordPress Plugin Check
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: '8.0'
32+
extensions: mysqli, curl, zip, intl, gd, mbstring, fileinfo, xml
33+
coverage: none
34+
tools: composer:v2
35+
36+
- name: Install Composer dependencies
37+
uses: ramsey/composer-install@v3
38+
with:
39+
dependency-versions: highest
40+
composer-options: "--prefer-dist --no-progress"
41+
42+
- name: WordPress Plugin Check
43+
uses: WordPress/plugin-check-action@v1.1.2
44+
with:
45+
# Build directory - using repository root
46+
build-dir: './'
47+
48+
# Configure which categories to check
49+
categories: |
50+
accessibility
51+
general
52+
performance
53+
plugin_repo
54+
security
55+
56+
# Whether to include experimental checks
57+
include-experimental: false
58+
59+
# Don't ignore warnings or errors
60+
ignore-warnings: false
61+
ignore-errors: false
62+
63+
# WordPress version to use
64+
wp-version: 'latest'
65+
66+
- name: Create issue on plugin check failure
67+
if: ${{ failure() }}
68+
uses: JasonEtco/create-an-issue@v2
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
RUN_ID: ${{ github.run_id }}
72+
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
73+
with:
74+
filename: .github/ISSUE_TEMPLATE/plugin-check-failure.md
75+
update_existing: false
76+
77+
- name: Mark job as failed after issue creation
78+
if: ${{ failure() }}
79+
run: |
80+
echo "::error::WordPress Plugin Check failed. Created issue for tracking."
81+
exit 1
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: WordPress Version Checker
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
schedule:
7+
- cron: '0 0 * * 0' # Run once a week on Sunday at midnight
8+
workflow_dispatch: # Allow manual triggering
9+
10+
permissions:
11+
issues: write # Required for creating issues about WordPress version mismatches
12+
contents: read # Required for reading repository content including readme.txt
13+
pull-requests: write # Required for creating PRs to update WordPress version compatibility
14+
15+
jobs:
16+
wordpress-version-checker:
17+
name: WordPress version checker
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: WordPress version checker
24+
uses: skaut/wordpress-version-checker@v2.2.3
25+
with:
26+
repo-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)