Skip to content

Support multiple PHP versions, improve display #109

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

Merged
merged 32 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4a4d302
Store php_version in post meta
swissspidy Mar 16, 2024
70871f5
Use different way of displaying results
swissspidy Mar 16, 2024
e2988df
Environment labels
swissspidy Mar 17, 2024
027f388
Host detail page
swissspidy Mar 17, 2024
4c89076
Fix orderby
swissspidy Mar 17, 2024
70ca3ce
no table, no heading
swissspidy Mar 17, 2024
c6c7ff5
styling
swissspidy Mar 17, 2024
a2d9732
link to archive page
swissspidy Mar 17, 2024
42608e9
layout
swissspidy Mar 17, 2024
7ccecac
Only report new failures in email
swissspidy Mar 17, 2024
dc3f828
remove debug cruft
swissspidy Mar 17, 2024
44cfbcb
don’t capitalize
swissspidy Mar 17, 2024
289c26a
Remove unused template
swissspidy Mar 23, 2024
de329aa
Add test date to single view
swissspidy Mar 23, 2024
f5248a3
Display execution time
swissspidy Mar 23, 2024
1b3dfb1
Fix implicit float conversion warning
swissspidy Mar 23, 2024
173f9e7
Switch from post meta to taxonomies for PHP versions and environment …
desrosj Sep 9, 2024
c8ad919
For now, don't make the taxonomies public.
desrosj Sep 9, 2024
cb7e662
Merge pull request #1 from desrosj/cloudfest-with-taxonomies
swissspidy Sep 9, 2024
5482334
Add a taxonomy for report result to simplify counting and querying.
desrosj Sep 11, 2024
feaf78a
Re-add saving of environment name as well as type.
desrosj Sep 11, 2024
29a4057
Fix author archive
swissspidy Sep 11, 2024
9847f92
Accept the term slug instead of a `bool` when counting test results.
desrosj Sep 12, 2024
dde08ba
Revert "Re-add saving of environment name as well as type."
desrosj Sep 12, 2024
165a1e2
Merge pull request #2 from desrosj/simplify-result-counting
swissspidy Sep 12, 2024
da3cfe8
Adjust environment to be a free-form name.
desrosj Sep 17, 2024
141109a
Save outcome status correctly.
desrosj Sep 17, 2024
4833c00
Correctly sanitize environment name and fix typo.
desrosj Sep 17, 2024
924795d
PHP version was moved to a taxonomy.
desrosj Sep 17, 2024
f424036
Fix displaying the username.
desrosj Sep 17, 2024
43f733a
Don't link to the author's archive for now.
desrosj Sep 17, 2024
2fe266f
Don't link to the author's archive for now.
desrosj Sep 17, 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
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 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
50 changes: 50 additions & 0 deletions parts/result-set-all.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
use PTR\Display;

echo Display::get_display_css(); ?>

<table class="ptr-test-reporter-table alignwide">
<thead>
<tr>
<th style="width:100px">Revision</th>
<th style="width:100px">Passed</th>
<th style="width:100px">Failed</th>
<th style="width:100px">➡️</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $revisions as $revision ) :
$rev_id = (int) ltrim( $revision->post_name, 'r' );

$num_passed = ptr_count_test_results( $revision->ID );
$num_failed = ptr_count_test_results( $revision->ID, 'failed' );
?>
<tr>
<td>
<a
href="<?php echo esc_url( sprintf( 'https://core.trac.wordpress.org/changeset/%d', $rev_id ) ); ?>"
title="<?php echo esc_attr( apply_filters( 'the_title', $revision->post_title ) ); ?>">
r<?php echo $rev_id; ?>
</a>
</td>

<td>
<span class="ptr-status-badge ptr-status-badge-passed">
<?php echo $num_passed; ?>
</span>
</td>
<td>
<span class="ptr-status-badge ptr-status-badge-failed">
<?php echo $num_failed; ?>
</span>
</td>
<td>
<a href="<?php the_permalink( $revision->ID ); ?>">
View
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
80 changes: 52 additions & 28 deletions parts/result-set.php → parts/result-set-single.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
<?php
use PTR\Display;

echo Display::get_display_css(); ?>
echo Display::get_display_css();

<table>
foreach ( $revisions as $revision ) :

$rev_id = (int) ltrim( $revision->post_name, 'r' );
?>

<div class="ptr-test-reporter-single-revision">
<a href="<?php echo esc_url( sprintf( 'https://core.trac.wordpress.org/changeset/%d', $rev_id ) ); ?>">
r<?php echo $rev_id; ?>
</a>: <?php echo esc_attr( apply_filters( 'the_title', $revision->post_title ) ); ?>
</div>

<table class="ptr-test-reporter-table alignwide">
<thead>
<tr>
<th style="width:100px">Revision</th>
<th>Host</th>
<th>PHP Version</th>
<th style="width:100px">Status</th>
<th style="width:150px">PHP Version</th>
<th>Database Version</th>
</tr>
</thead>
<tbody>
<?php
$total_cols = 5;
foreach ( $revisions as $revision ) :
$rev_id = (int) ltrim( $revision->post_name, 'r' );
?>
<tr>
<th colspan="<?php echo (int) $total_cols; ?>"><a href="<?php echo esc_url( sprintf( 'https://core.trac.wordpress.org/changeset/%d', $rev_id ) ); ?>">r<?php echo (int) $rev_id; ?></a>: <?php echo wp_kses_post( apply_filters( 'the_title', $revision->post_title ) ); ?></th>
</tr>

<?php
$query_args = array(
$query_args = array(
'posts_per_page' => $posts_per_page,
'author' => $post_author ?? null,
'post_type' => 'result',
'post_parent' => $revision->ID,
'orderby' => 'post_title',
'order' => 'ASC',
'orderby' => [ 'author' => 'ASC', 'env_name_clause' => 'ASC' ],
'meta_query' => array(
'relation' => 'OR',
'env_name_clause' => array(
'key' => 'environment_name',
'compare' => 'EXISTS',
),
array(
'key' => 'environment_name',
'compare' => 'NOT EXISTS',
)
),
);
$report_query = new WP_Query( $query_args );
if ( ! empty( $report_query->posts ) ) :

$prev_author = null;

foreach ( $report_query->posts as $report ) :
$status = 'Errored';
$status_title = 'No results found for test.';
Expand All @@ -55,35 +72,42 @@
'extra_attr' => 'style="vertical-align: middle;margin-right:5px;"',
)
);
if ( ! empty( $user->user_url ) ) {
$host .= '</a>';
}
if ( ! empty( $user->user_url ) ) {
$host .= '<a target="_blank" rel="nofollow" href="' . esc_url( $user->user_url ) . '">';
}
$host .= $user->display_name;

$host .= Display::get_display_reporter_name( $report->post_author );

if ( ! empty( $user->user_url ) ) {
$host .= '</a>';
}
}
?>
<?php if ( $prev_author !== $host ): ?>
<tr>
<td colspan="3">
<?php echo wp_kses_post( $host ); ?>
</td>
</tr>

<?php endif; ?>
<tr>
<td><a href="<?php echo esc_url( get_permalink( $report->ID ) ); ?>" title="<?php echo esc_attr( $status_title ); ?>" class="<?php echo esc_attr( 'ptr-status-badge ptr-status-badge-' . strtolower( $status ) ); ?>"><?php echo esc_html( $status ); ?></a></td>
<td><?php echo wp_kses_post( $host ); ?></td>
<td>
<a href="<?php echo esc_url( get_permalink( $report->ID ) ); ?>" title="<?php echo esc_attr( $status_title ); ?>" class="<?php echo esc_attr( 'ptr-status-badge ptr-status-badge-' . strtolower( $status ) ); ?>">
<?php echo esc_html( $status ); ?>
</a>
</td>
<td><?php echo esc_html( Display::get_display_php_version( $report->ID ) ); ?></td>
<td><?php echo esc_html( Display::get_display_mysql_version( $report->ID ) ); ?></td>
</tr>
<?php
$prev_author = $host;
endforeach;
else :
?>
<tr>
<td></td>
<td colspan="<?php echo (int) $total_cols - 1; ?>">
<td colspan="3">
No reports for changeset.
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php endforeach;
25 changes: 19 additions & 6 deletions parts/single-result.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
'extra_attr' => 'style="vertical-align: middle;margin-right:5px;"',
)
);
if ( ! empty( $user->user_url ) ) {
$host .= '</a>';
}
if ( ! empty( $user->user_url ) ) {
$host .= '<a target="_blank" rel="nofollow" href="' . esc_url( $user->user_url ) . '">';
}
$host .= $user->display_name;
if ( ! empty( $user->user_url ) ) {
$host .= '</a>';
Expand All @@ -54,6 +48,25 @@
<td><strong>Host</strong></td>
<td><?php echo wp_kses_post( $host ); ?></td>
</tr>
<tr>
<td><strong>Test Date</strong></td>
<td>
<?php the_date(); ?>
<?php the_time(); ?>
</td>
</tr>
<tr>
<td><strong>Execution Time</strong></td>
<td>
<?php echo esc_html( Display::get_display_time( $report->ID ) ); ?>
</td>
</tr>
<tr>
<td><strong>Environment Name</strong></td>
<td>
<?php echo esc_html( Display::get_display_environment_name( $report->ID ) ); ?>
</td>
</tr>
<tr>
<td><strong>PHP Version</strong></td>
<td><?php echo esc_html( Display::get_display_php_version( $report->ID ) ); ?></td>
Expand Down
33 changes: 32 additions & 1 deletion phpunit-test-reporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
add_action( 'post_class', array( 'PTR\Display', 'filter_post_class' ) );
add_action( 'the_content', array( 'PTR\Display', 'filter_the_content' ) );
add_action( 'rest_api_init', array( 'PTR\RestAPI', 'register_routes' ) );

add_action( 'load-edit.php', 'ptr_load_edit_php' );

/**
Expand Down Expand Up @@ -93,3 +92,35 @@ function ptr_get_template_part( $template, $vars = array() ) {
include $full_path;
return ob_get_clean();
}

/**
* Counts the number of failing or passing test reports for a revision.
*
* @param int $revision_parent_id The current revision's post ID.
* @param string $status The status term slug to count.
*
* @return int The number of reports for the given revision.
*/
function ptr_count_test_results( $revision_parent_id, $status = 'passed' ) {
$report_query = new WP_Query(
array(
'post_type' => 'result',
'post_parent' => $revision_parent_id,
'fields' => 'ids',
'posts_per_page' => 1,
'tax_query' => array(
array(
'taxonomy' => 'report-result',
'terms' => $status,
'field' => 'slug',
),
)
)
);

if ( ! $report_query->have_posts() ) {
return 0;
}

return $report_query->found_posts;
}
54 changes: 54 additions & 0 deletions src/class-content-model.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,60 @@ public static function action_init_register_post_type() {
),
)
);

register_taxonomy(
'php-version',
array( 'result' ),
array(
'labels' => array(
'name' => __( 'PHP Versions', 'ptr' ),
'singular_name' => __( 'PHP Version', 'ptr' ),
),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
'show_in_rest' => true,
)
);

register_taxonomy(
'db-version',
array( 'result' ),
array(
'labels' => array(
'name' => __( 'Database Versions', 'ptr' ),
'singular_name' => __( 'Database Version', 'ptr' ),
),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
'show_in_rest' => true,
)
);

register_taxonomy(
'report-result',
array( 'result' ),
array(
'labels' => array(
'name' => __( 'Result Status', 'ptr' ),
'singular_name' => __( 'Result Status', 'ptr' ),
),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
'show_in_rest' => true,
)
);
}

/**
Expand Down
Loading