Skip to content

Commit

Permalink
Merge branch 'trunk' into fix-output-escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
gudmdharalds authored Aug 6, 2024
2 parents 9c379f4 + 6fc2858 commit 7d30f4e
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ TODO:
- [ ] Added patch for [describe issue]
- [ ] Add/update tests -- unit/integrated/E2E (if needed)
- [ ] Ensure only one function/functionality is tested per test file.
- [ ] New/updated software requirements?
- [ ] Update README.md
- [ ] Update defines.php
- [ ] Add to, or update, `Scan run detail` report as applicable
- [ ] Check status of automated tests
- [ ] Ensure `PHPDoc` comments are up to date for functions added or altered
Expand All @@ -31,6 +34,9 @@ TODO:
- [ ] Add to, or update, `Scan run detail` report as applicable
- [ ] Add/update tests -- unit/integrated/E2E
- [ ] Ensure only one function/functionality is tested per test file.
- [ ] New/updated software requirements?
- [ ] Update README.md
- [ ] Update defines.php
- [ ] Ensure `PHPDoc` comments are up to date for functions added or altered
- [ ] Update repository documentation (README.md, RELEASING.md, TESTING.md, TOOLS-UPDATE.md)
- [ ] Assign appropriate [priority](https://github.com/Automattic/vip-go-ci/blob/trunk/CONTRIBUTING.md#priorities) and [type of change labels](https://github.com/Automattic/vip-go-ci/blob/trunk/CONTRIBUTING.md#type-of-change-labels).
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file.

## [1.3.13](https://github.com/Automattic/vip-go-ci/releases/tag/1.3.13) - 2024-05-23
- [389](https://github.com/Automattic/vip-go-ci/pull/389): Upgrade to PHPCS 3.10.1

## [1.3.12](https://github.com/Automattic/vip-go-ci/releases/tag/1.3.12) - 2024-05-22
- [#386](https://github.com/Automattic/vip-go-ci/pull/386): Update VIPCS + dependencies
- [#388](https://github.com/Automattic/vip-go-ci/pull/388): Update PHPCS, PHPUtils and PHPCompatibility dependencies

## [1.3.11](https://github.com/Automattic/vip-go-ci/releases/tag/1.3.11) - 2023-11-02
- [#383](https://github.com/Automattic/vip-go-ci/pull/383): Temporarily roll back git requirement

## [1.3.10](https://github.com/Automattic/vip-go-ci/releases/tag/1.3.10) - 2023-11-02

### Updated
- [#380](https://github.com/Automattic/vip-go-ci/pull/380): Update --output functionality
- [#381](https://github.com/Automattic/vip-go-ci/pull/381): Update minimum requirements and TODO template

## [1.3.9](https://github.com/Automattic/vip-go-ci/releases/tag/1.3.9) - 2023-09-27

### Updated
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ If you have a feature request, please read the [file on contributing](CONTRIBUTI
* The PHP-based utlities — PHPCS, SVG scanner and PHP Lint — can be run using different PHP versions than `vip-go-ci` itself. See individual sections below on this.
* These utilities have their own requirements.
* Linux is recommended as a platform for `vip-go-ci`.
* git version 2.30 or later.
* git version 2.10 or later.
* Working bash shell.
* Access to GitHub API and other APIs configured.

Expand Down
4 changes: 2 additions & 2 deletions defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
/*
* Version number and default name to use.
*/
define( 'VIPGOCI_VERSION', '1.3.9' );
define( 'VIPGOCI_VERSION', '1.3.13' );
define( 'VIPGOCI_DEFAULT_NAME_TO_USE', 'vip-go-ci' );

/*
* Define minimum version requirements.
*/
define( 'VIPGOCI_GIT_VERSION_MINIMUM', '2.10' );
define( 'VIPGOCI_PHP_VERSION_MINIMUM', '7.3.0' );
define( 'VIPGOCI_PHP_VERSION_MINIMUM', '8.0.0' );

/*
* Client-ID for HTTP requests.
Expand Down
5 changes: 3 additions & 2 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function vipgoci_help_print() :void {
"\t" . ' to be PHPCS scanned to be specified in file in root' . PHP_EOL .
"\t" . ' of repository (.vipgoci_phpcs_skip_folders).' . PHP_EOL .
"\t" . ' Folders should be separated by newlines.' . PHP_EOL .
"\t" . '--output=FILE Where to save PHPCS output.' . PHP_EOL .
PHP_EOL .
'SVG scanning configuration:' . PHP_EOL .
"\t" . '--svg-checks=BOOL Enable or disable SVG checks, both auto-approval of SVG' . PHP_EOL .
Expand Down Expand Up @@ -215,6 +214,8 @@ function vipgoci_help_print() :void {
"\t" . '--scan-details-msg-include=BOOL If to include additional detail about the scan, versions of' . PHP_EOL .
"\t" . ' software used, options altered and so forth. Enabled by default.' . PHP_EOL .
PHP_EOL .
"\t" . '--output=FILE Where to save results output.' . PHP_EOL .
PHP_EOL .
'Generic support comments configuration:' . PHP_EOL .
"\t" . '--post-generic-pr-support-comments=BOOL Whether to post generic comment to pull requests' . PHP_EOL .
"\t" . ' with support-related information for users. Will' . PHP_EOL .
Expand Down Expand Up @@ -3080,7 +3081,7 @@ function vipgoci_run_scan(
'repo-owner' => $options['repo-owner'],
'repo-name' => $options['repo-name'],
'commit' => $options['commit'],
'prs_implicated' => array_keys( $prs_implicated ),
'prs_implicated' => $prs_implicated,
)
);
}
Expand Down
64 changes: 55 additions & 9 deletions results.php
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,14 @@ function vipgoci_results_filter_duplicate(
function vipgoci_results_output_dump(
string $output_file,
array $data
) :void {
): void {
vipgoci_log(
'Preparing to dump results to file',
array(
'output' => $output_file,
)
);

if (
( is_file( $output_file ) ) &&
( ! is_writeable( $output_file ) )
Expand All @@ -1089,15 +1096,54 @@ function vipgoci_results_output_dump(
'output_file' => $output_file,
)
);

return;
}

if ( isset( $data['prs_implicated'] ) ) {
$tmp_prs_implicated = $data['prs_implicated'];

$data['prs_implicated'] = array();

foreach ( $tmp_prs_implicated as $pr_number => $pr_data ) {
if ( isset( $pr_data->title ) ) {
$data['prs_implicated'][ $pr_number ]['title'] = $pr_data->title;
}

if ( isset( $pr_data->base->ref ) ) {
$data['prs_implicated'][ $pr_number ]['base_branch'] = $pr_data->base->ref;
}

if ( isset( $pr_data->head->ref ) ) {
$data['prs_implicated'][ $pr_number ]['head_branch'] = $pr_data->head->ref;
}

if ( isset( $pr_data->user->login ) ) {
$data['prs_implicated'][ $pr_number ]['creator'] = $pr_data->user->login;
}
}

unset( $tmp_prs_implicated );
unset( $pr_number );
unset( $pr_data );
}

$res = file_put_contents(
$output_file,
json_encode(
$data,
JSON_PRETTY_PRINT
),
FILE_APPEND
);

if ( false === $res ) {
vipgoci_log(
'Unable to write results to output file due to error',
);
} else {
file_put_contents(
$output_file,
json_encode(
$data,
JSON_PRETTY_PRINT
),
FILE_APPEND
vipgoci_log(
'Successfully wrote results to file'
);
}
}

53 changes: 47 additions & 6 deletions tests/integration/ResultsOutputDumpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ final class ResultsOutputDumpTest extends TestCase {
*
* @return void
*/
protected function setUp() :void {
protected function setUp(): void {
require_once __DIR__ . '/../../results.php';
require_once __DIR__ . '/../../log.php';

$this->temp_dump_file = tempnam(
sys_get_temp_dir(),
Expand Down Expand Up @@ -63,11 +64,32 @@ public function testDumpResults(): void {
'repo-name' => 'test-repo',
'commit' => 'abc123',
'prs_implicated' => array(
1 => array(
'test1',
1 => (object) array(
'title' => 'testing #1',
'base' => (object) array(
'ref' => 'main',
),
'head' => (object) array(
'ref' => 'add/testing1',
),
'user' => (object) array(
'login' => 'user1',
),
),
2 => array(
'test2',
2 => (object) array(
'title' => 'testing #2',
'base' => (object) array(
'ref' => 'main',
),
'head' => (object) array(
'ref' => 'add/testing2',
),
'user' => (object) array(
'login' => 'user2',
),
),
3 => (object) array(
'invalid' => false,
),
),
);
Expand All @@ -87,7 +109,26 @@ public function testDumpResults(): void {
);

$this->assertSame(
$data,
array(
'results' => array( 1, 2, 3, 4 ),
'repo-owner' => 'test-owner',
'repo-name' => 'test-repo',
'commit' => 'abc123',
'prs_implicated' => array(
1 => array(
'title' => 'testing #1',
'base_branch' => 'main',
'head_branch' => 'add/testing1',
'creator' => 'user1',
),
2 => array(
'title' => 'testing #2',
'base_branch' => 'main',
'head_branch' => 'add/testing2',
'creator' => 'user2',
),
),
),
$dumped_contents
);
}
Expand Down
36 changes: 18 additions & 18 deletions tools-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ set -e
# https://github.com/Automattic/vip-go-ci/#updating-tools-initsh-with-new-versions
#

# https://github.com/squizlabs/PHP_CodeSniffer
export PHP_CODESNIFFER_REPO="squizlabs/PHP_CodeSniffer"
export PHP_CODESNIFFER_VER="3.7.2"
# https://github.com/PHPCSStandards/PHP_CodeSniffer
export PHP_CODESNIFFER_REPO="PHPCSStandards/PHP_CodeSniffer"
export PHP_CODESNIFFER_VER="3.10.1"
export PHP_CODESNIFFER_VER_FILE="php-codesniffer-$PHP_CODESNIFFER_VER.txt"
export PHP_CODESNIFFER_SHA1SUM="f20912a426eff7a7547947f00f1ea0db097a7ffb"
export PHP_CODESNIFFER_SHA1SUM="b8aca4578b3afbc3fb9162a59fa075b209e2c611"

# https://github.com/WordPress/WordPress-Coding-Standards
export WP_CODING_STANDARDS_REPO="WordPress/WordPress-Coding-Standards"
export WP_CODING_STANDARDS_VER="3.0.1"
export WP_CODING_STANDARDS_VER="3.1.0"
export WP_CODING_STANDARDS_VER_FILE="wp-coding-standards-$WP_CODING_STANDARDS_VER.txt"
export WP_CODING_STANDARDS_SHA1SUM="25f3cc04c7484cc50104a6ca2bf5fcadd447d9d0"
export WP_CODING_STANDARDS_SHA1SUM="e499d90ab2ca6d60b119049b9410c351780d2ebd"

# https://github.com/automattic/vip-coding-standards
export VIP_CODING_STANDARDS_REPO="automattic/vip-coding-standards"
export VIP_CODING_STANDARDS_VER="3.0.0"
export VIP_CODING_STANDARDS_VER="3.0.1"
export VIP_CODING_STANDARDS_VER_FILE="vip-coding-standards-$VIP_CODING_STANDARDS_VER.txt"
export VIP_CODING_STANDARDS_SHA1SUM="c38362e2463f2cfc2c9cabe48011f921843f3bf4"
export VIP_CODING_STANDARDS_SHA1SUM="73f113f13b8747aeed8f93a827e34fd4125c3b81"

# https://github.com/sirbrillig/phpcs-variable-analysis
export PHPCS_VARIABLE_ANALYSIS_REPO="sirbrillig/phpcs-variable-analysis"
export PHPCS_VARIABLE_ANALYSIS_VER="v2.11.17"
export PHPCS_VARIABLE_ANALYSIS_VER="v2.11.18"
export PHPCS_VARIABLE_ANALYSIS_VER_FILE="phpcs-variable-analysis-$PHPCS_VARIABLE_ANALYSIS_VER.txt"
export PHPCS_VARIABLE_ANALYSIS_SHA1SUM="8effbc612733ec3fc0d7e623b5b3af912d5febb8"
export PHPCS_VARIABLE_ANALYSIS_SHA1SUM="f54bd764751ceabc89b377730638ffd871f74f1a"

# https://github.com/phpcompatibility/phpcompatibility
export PHP_COMPATIBILITY_REPO="phpcompatibility/phpcompatibility"
Expand All @@ -40,27 +40,27 @@ export PHP_COMPATIBILITY_SHA1SUM="ee2b066a386664419f190ef55850a68172fd29e5"

# https://github.com/phpcompatibility/phpcompatibilitywp
export PHP_COMPATIBILITY_WP_REPO="phpcompatibility/phpcompatibilitywp"
export PHP_COMPATIBILITY_WP_VER="2.1.4"
export PHP_COMPATIBILITY_WP_VER="2.1.5"
export PHP_COMPATIBILITY_WP_VER_FILE="php-compatibility-wp-$PHP_COMPATIBILITY_WP_VER.txt"
export PHP_COMPATIBILITY_WP_SHA1SUM="e1f90246005b6265428e6c7313cd7335a49b9ac6"
export PHP_COMPATIBILITY_WP_SHA1SUM="ed0f9717fde6dd295f2fe64b834051e13908203d"

# https://github.com/phpcompatibility/phpcompatibilityparagonie
export PHP_COMPATIBILITY_PARAGONIE_REPO="phpcompatibility/phpcompatibilityparagonie"
export PHP_COMPATIBILITY_PARAGONIE_VER="1.3.2"
export PHP_COMPATIBILITY_PARAGONIE_VER="1.3.3"
export PHP_COMPATIBILITY_PARAGONIE_VER_FILE="php-compatibility-paragonie-$PHP_COMPATIBILITY_PARAGONIE_VER.txt"
export PHP_COMPATIBILITY_PARAGONIE_SHA1SUM="7aa800cf9b2737ad64082cb70b4b4113d8c19cdb"
export PHP_COMPATIBILITY_PARAGONIE_SHA1SUM="ce612de4aa56e6184570c69d5cabf56c29e90d30"

# https://github.com/PHPCSStandards/PHPCSUtils
export PHPCS_UTILS_REPO="PHPCSStandards/PHPCSUtils"
export PHPCS_UTILS_VER="1.0.8"
export PHPCS_UTILS_VER="1.0.12"
export PHPCS_UTILS_VER_FILE="phpcs-utils-$PHPCS_UTILS_VER.txt"
export PHPCS_UTILS_SHA1SUM="50dc4e4a5138179e0ef481b1af5aa7dc51817dfc"
export PHPCS_UTILS_SHA1SUM="3877b9c263dee2b490520c58b98ad8c407d810b3"

# https://github.com/PHPCSStandards/PHPCSExtra
export PHPCS_EXTRA_REPO="PHPCSStandards/PHPCSExtra"
export PHPCS_EXTRA_VER="1.1.2"
export PHPCS_EXTRA_VER="1.2.1"
export PHPCS_EXTRA_VER_FILE="phpcs-extra-$PHPCS_EXTRA_VER.txt"
export PHPCS_EXTRA_SHA1SUM="7c1d6d6d454106d46446f43324b4297b7caa8fbe"
export PHPCS_EXTRA_SHA1SUM="76cda4f26f099e588ba531bf41ac173b7ad02e17"

# https://github.com/Automattic/vip-go-svg-sanitizer
export VIP_GO_SVG_SANITIZER_REPO="Automattic/vip-go-svg-sanitizer"
Expand Down

0 comments on commit 7d30f4e

Please sign in to comment.