Making WordPress.org

Changeset 10410


Ignore:
Timestamp:
10/27/2020 02:41:36 AM (6 years ago)
Author:
dd32
Message:

Theme Directory: Add a callback to an experimental theme-review workflow.

Props dufresnesteven.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-upload.php

    r10243 r10410  
    11<?php
     2use WordPressdotorg\Theme_Directory\Lib\GitHub;
    23
    34/**
    … …  
    323324
    324325                do_action( 'theme_upload', $this->theme, $this->theme_post );
     326
     327                // Initiate a GitHub actions run for the theme.
     328                $this->trigger_e2e_run( $ticket_id );
    325329
    326330                // Success!
    … …  
    948952        }
    949953
     954        /**
     955         * Triggers a GitHub actions run for the upload.
     956         */
     957        public function trigger_e2e_run( $ticket_id ) {
     958                $api = GitHub::api(
     959                        '/repos/' . WPORG_THEMES_E2E_REPO . '/dispatches',
     960                        json_encode([
     961                                'event_type'     => $this->theme->display( 'Name' ),
     962                                'client_payload' => [
     963                                        'theme_slug'       => $this->theme_slug,
     964                                        'theme_zip'        => "https://wordpress.org/themes/download/{$this->theme_slug}.{$this->theme->display( 'Version' )}.zip?nostats=1",
     965                                        'accessible_ready' => in_array( 'accessibility-ready', $this->theme->get( 'Tags' ) ),
     966                                        'trac_ticket_id'   => $ticket_id,
     967                                ],
     968                        ])
     969                );
     970       
     971                // Upon failure a message is returned, success returns nothing.
     972                return empty( $api );
     973        }
     974
    950975        // Helper
    951976
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/lib/class-github.php

    r10409 r10410  
    11<?php
    2 namespace WordPressdotorg\Plugin_Directory\Clients;
     2namespace WordPressdotorg\Theme_Directory\Lib;
    33use Ahc\Jwt\JWT;
    44
    55/**
    6  * Simple GitHub client.
     6 * Simple GitHub API client.
    77 *
    8  * @package WordPressdotorg\Plugin_Directory\Clients
     8 * @package WordPressdotorg\Theme_Directory
    99 */
    1010class GitHub {
    … …  
    1212        public static function api( $url, $args = null, $headers = [], $method = null ) {
    1313                // Verify the configuration variables are available.
     14                // This re-uses the Plugin Directory constants deliberately.
    1415                if ( ! defined( 'PLUGIN_GITHUB_APP_ID' ) || ! defined( 'PLUGIN_GITHUB_APP_PRIV_KEY' ) ) {
    1516                        return false;
    … …  
    2021                        $url = 'https://api.github.com' . $url;
    2122                }
    22        
     23
    2324                $request = wp_remote_request(
    2425                        $url,
    … …  
    105106                // This should be replaced with an Autoloader.
    106107                if ( ! class_exists( 'Ahc\Jwt\JWT' ) ) {
    107                         require_once dirname( __DIR__ ) . '/libs/adhocore-php-jwt/JWTException.php';
    108                         require_once dirname( __DIR__ ) . '/libs/adhocore-php-jwt/ValidatesJWT.php';
    109                         require_once dirname( __DIR__ ) . '/libs/adhocore-php-jwt/JWT.php';
     108                        require_once __DIR__ . '/adhocore-php-jwt/JWTException.php';
     109                        require_once __DIR__ . '/adhocore-php-jwt/ValidatesJWT.php';
     110                        require_once __DIR__ . '/adhocore-php-jwt/JWT.php';
    110111                }
    111112
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r10311 r10410  
    3535new WordPressdotorg\Theme_Directory\Jobs\Manager();
    3636
     37// Load the GitHub API client.
     38include __DIR__ . '/lib/class-github.php';
     39
    3740define( 'WPORG_THEMES_DEFAULT_BROWSE', 'popular' );
     41
     42define( 'WPORG_THEMES_E2E_REPO', 'WordPress/theme-review-e2e' );
    3843
    3944/**
Note: See TracChangeset for help on using the changeset viewer.