Linter fix on CI.
The CI wasn't properly reporting linting, as it turns out the output of `arc lint --output json` is not what the Jenkins plugin expects. This adds a custom lint printer that is compatible with the plugin expectations. Also delete the coala/ folder forgotten in the original diff. Differential Revision: https://code.wildfiregames.com/D3709 This was SVN commit r25082.
This commit is contained in:
parent
ce0fb7770c
commit
d751927b89
@ -10,11 +10,13 @@ phutil_register_library_map(array(
|
||||
'__library_version__' => 2,
|
||||
'class' => array(
|
||||
'ESLintLinter' => 'src/ESLintLinter.php',
|
||||
'JenkinsRenderer' => 'src/JenkinsRenderer.php',
|
||||
'LicenceYearLinter' => 'src/LicenceYearLinter.php',
|
||||
),
|
||||
'function' => array(),
|
||||
'xmap' => array(
|
||||
'ESLintLinter' => 'ArcanistExternalLinter',
|
||||
'JenkinsRenderer' => 'ArcanistLintRenderer',
|
||||
'LicenceYearLinter' => 'ArcanistLinter',
|
||||
),
|
||||
));
|
||||
|
49
build/arclint/pyrolint/src/JenkinsRenderer.php
Normal file
49
build/arclint/pyrolint/src/JenkinsRenderer.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021 Wildfire Games.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The phabricator-jenkins-plugin expects a lint format
|
||||
* that isn't quite compatible with `arc lint --output json`.
|
||||
* This adds a custom output style `jenkins` that is.
|
||||
* It's heavily based on Arcanist's regular JSON renderer.
|
||||
* See https://github.com/uber/phabricator-jenkins-plugin/issues/255.
|
||||
* The expected format is one line per message, as a dictionary.
|
||||
*/
|
||||
|
||||
final class JenkinsRenderer extends ArcanistLintRenderer {
|
||||
|
||||
const RENDERERKEY = 'jenkins';
|
||||
|
||||
const LINES_OF_CONTEXT = 3;
|
||||
|
||||
public function renderLintResult(ArcanistLintResult $result) {
|
||||
$messages = $result->getMessages();
|
||||
$path = $result->getPath();
|
||||
$data = explode("\n", $result->getData());
|
||||
array_unshift($data, ''); // make the line numbers work as array indices
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$dictionary = $message->toDictionary();
|
||||
$dictionary['context'] = implode("\n", array_slice(
|
||||
$data,
|
||||
max(1, $message->getLine() - self::LINES_OF_CONTEXT),
|
||||
self::LINES_OF_CONTEXT * 2 + 1));
|
||||
$dictionary['path'] = $path;
|
||||
$this->writeOut(json_encode(json_decode(json_encode($dictionary)))."\n");
|
||||
}
|
||||
}
|
||||
}
|
@ -133,8 +133,8 @@ pipeline {
|
||||
sh '''
|
||||
for file in builderr-*.txt ; do
|
||||
if [ -s "$file" ]; then
|
||||
echo "$file" >> build-errors.txt
|
||||
cat "$file" >> build-errors.txt
|
||||
echo "$file" >> build-errors.txt
|
||||
cat "$file" >> build-errors.txt
|
||||
fi
|
||||
done
|
||||
'''
|
||||
@ -147,9 +147,14 @@ pipeline {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh 'arc lint --output json > .phabricator-lint'
|
||||
// arc lint outputs an empty file on success - unless there is nothing to lint.
|
||||
// On failure, it'll output the file and a failure error code.
|
||||
// Explicitly checking for the file presence is thus best to detect the linter did run
|
||||
sh 'arc lint --output jenkins --outfile .phabricator-lint && touch .phabricator-lint'
|
||||
} catch (e) {
|
||||
sh 'echo \"{ \\\"name\\\": \\\"error\\\", \\\"severity\\\": \\\"error\\\", \\\"code\\\": \\\"0\\\", \\\"description\\\": \\\"lint could not run\\\" }\" > .phabricator-lint '
|
||||
if (!fileExists(".phabricator-lint")) {
|
||||
sh '''echo '{ "path": "general", code": "Jenkins", "severity": "error", "name": "ci-error", "description": "Error running lint", "bypassChangedLineFiltering": true }' > .phabricator-lint '''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user