Skip to content

Commit

Permalink
First attempt #yolo
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Oct 20, 2023
1 parent 9c2bc9d commit c0abb9d
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'test'
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
- 'releases/*'

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run plugin check
uses: ./
with:
build-dir: 'hello-dolly'
1 change: 1 addition & 0 deletions .wp-env.override.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "plugins": [ "plugin-under-test", "plugin-check" ] }
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# wp-plugin-check-action

A GitHub action to run [Plugin Check](https://wordpress.org/plugins/plugin-check/) against your plugin.

Results are posted as comments and annotations.
80 changes: 80 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: 'wp-plugin-check-action'
description: 'Test your WordPress plugin with Plugin Check'
author: 'Pascal Birchler'
branding:
color: 'blue'
icon: 'trending-up'
inputs:
repo-token:
description: 'The GITHUB_TOKEN secret'
required: false
default: ${{ github.token }}
build-dir:
description: 'Build directory'
required: false
default: './'

runs:
using: "composite"
steps:
- name: Setup PHP
uses: shivammathur/setup-php@7fdd3ece872ec7ec4c098ae5ab7637d5e0a96067
with:
php-version: 'latest'
coverage: none
tools: composer

- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mkdir -p bin
mv wp-cli.phar bin/wp
echo "${PWD}/bin" >> $GITHUB_PATH
shell: bash

- name: WP-CLI Info
run: wp cli info
shell: bash

- name: Checkout Plugin Check
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
repository: 'WordPress/plugin-check'
path: 'plugin-check'

- name: Build Plugin Check
run: |
composer install
shell: bash
working-directory: 'plugin-check'

- name: Move Plugin Check out of plugin folder
run: |
mv plugin-check ${{ runner.temp }}/plugin-check
shell: bash

- name: Set PLUGIN_DIR
run: |
PLUGIN_DIR=$(realpath "$BUILD_DIR")
echo "PLUGIN_DIR=$PLUGIN_DIR" >> "$GITHUB_ENV"
PLUGIN_SLUG=$(dirname $PLUGIN_DIR)
echo "PLUGIN_SLUG=$PLUGIN_SLUG" >> "$GITHUB_ENV"
shell: bash
env:
BUILD_DIR: ${{ inputs.build-dir }}

- name: Setup wp-env
run: |
echo "{ \"plugins\": [ \"$PLUGIN_DIR\", \"${{ runner.temp }}/plugin-check\" ] }" >> .wp-env.override.json
npm -g i @wordpress/env
wp-env start --update
shell: bash

- name: Run Plugin Check
run: |
wp-env run cli wp plugin list
wp-env run cli wp plugin check $PLUGIN_SLUG --require=./wp-content/plugins/plugin-check/cli.php
shell: bash
100 changes: 100 additions & 0 deletions hello-dolly/hello.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
/**
* @package Hello_Dolly
* @version 1.7.2
*/
/*
Plugin Name: Hello Dolly
Plugin URI: http://wordpress.org/plugins/hello-dolly/
Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
Author: Matt Mullenweg
Version: 1.7.2
Author URI: http://ma.tt/
*/

function hello_dolly_get_lyric() {
/** These are the lyrics to Hello Dolly */
$lyrics = "Hello, Dolly
Well, hello, Dolly
It's so nice to have you back where you belong
You're lookin' swell, Dolly
I can tell, Dolly
You're still glowin', you're still crowin'
You're still goin' strong
I feel the room swayin'
While the band's playin'
One of our old favorite songs from way back when
So, take her wrap, fellas
Dolly, never go away again
Hello, Dolly
Well, hello, Dolly
It's so nice to have you back where you belong
You're lookin' swell, Dolly
I can tell, Dolly
You're still glowin', you're still crowin'
You're still goin' strong
I feel the room swayin'
While the band's playin'
One of our old favorite songs from way back when
So, golly, gee, fellas
Have a little faith in me, fellas
Dolly, never go away
Promise, you'll never go away
Dolly'll never go away again";

// Here we split it into lines.
$lyrics = explode( "\n", $lyrics );

// And then randomly choose a line.
return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
}

// This just echoes the chosen line, we'll position it later.
function hello_dolly() {
$chosen = hello_dolly_get_lyric();
$lang = '';
if ( 'en_' !== substr( get_user_locale(), 0, 3 ) ) {
$lang = ' lang="en"';
}

printf(
'<p id="dolly"><span class="screen-reader-text">%s </span><span dir="ltr"%s>%s</span></p>',
__( 'Quote from Hello Dolly song, by Jerry Herman:', 'hello-dolly' ),
$lang,
$chosen
);
}

// Now we set that function up to execute when the admin_notices action is called.
add_action( 'admin_notices', 'hello_dolly' );

// We need some CSS to position the paragraph.
function dolly_css() {
echo "
<style type='text/css'>
#dolly {
float: right;
padding: 5px 10px;
margin: 0;
font-size: 12px;
line-height: 1.6666;
}
.rtl #dolly {
float: left;
}
.block-editor-page #dolly {
display: none;
}
@media screen and (max-width: 782px) {
#dolly,
.rtl #dolly {
float: none;
padding-left: 0;
padding-right: 0;
}
}
</style>
";
}

add_action( 'admin_head', 'dolly_css' );
13 changes: 13 additions & 0 deletions hello-dolly/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== Hello Dolly ===
Contributors: matt, wordpressdotorg
Stable tag: 1.7.2
Tested up to: 6.1
Requires at least: 4.6

This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong.

== Description ==

This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.

Thanks to Sanjib Ahmad for the artwork.
5 changes: 5 additions & 0 deletions wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"core": null,
"port": 8880,
"testsPort": 8881
}

0 comments on commit c0abb9d

Please sign in to comment.