Fix matchers and add tests

This commit is contained in:
Shivam Mathur
2019-12-19 02:38:12 +05:30
parent 8039546df3
commit 1798f4d615
7 changed files with 103 additions and 40 deletions

24
src/configs/phpunit.json Normal file
View File

@ -0,0 +1,24 @@
{
"problemMatcher": [
{
"owner": "phpunit",
"pattern": [
{
"regexp": "^\\d+\\)\\s.*$"
},
{
"regexp": "^(.*)$",
"message": 1
},
{
"regexp": "^\\s*$"
},
{
"regexp": "^(.*):(\\d+)$",
"file": 1,
"line": 2
}
]
}
]
}

View File

@ -4,7 +4,7 @@ import * as config from './config';
import * as coverage from './coverage';
import * as extensions from './extensions';
import * as utils from './utils';
import {addMatchers} from './matchers';
import * as matchers from './matchers';
/**
* Build the script
@ -26,6 +26,7 @@ export async function build(
(await utils.getInput('ini-values', false)) ||
(await utils.getInput('ini-values-csv', false));
const coverage_driver: string = await utils.getInput('coverage', false);
const setup_matchers: string = await utils.getInput('matchers', false);
let script: string = await utils.readScript(filename, version, os_version);
if (extension_csv) {
@ -69,8 +70,7 @@ export async function run(): Promise<void> {
);
break;
}
addMatchers();
await matchers.addMatchers();
} catch (error) {
core.setFailed(error.message);
}

View File

@ -1,10 +1,18 @@
import * as path from 'path';
import * as utils from './utils';
import * as io from '@actions/io';
/**
* Add matches using the Actions Toolkit problem matchers syntax
* https://github.com/actions/toolkit/blob/master/docs/problem-matchers.md
* Cache json files for problem matchers
*/
export function addMatchers(): void {
const matchersPath = path.join(__dirname, '..', '.github/matchers');
console.log(`##[add-matcher]${path.join(matchersPath, 'phpunit.json')}`);
export async function addMatchers(): Promise<void> {
const config_path = path.join(
__dirname,
'..',
'src',
'configs',
'phpunit.json'
);
const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false);
await io.cp(config_path, runner_dir);
}