This commit is contained in:
Aart Jan Kaptijn 2022-11-14 15:03:23 +01:00 committed by A. J. Kaptijn
parent e5aa1531a6
commit 411cf3d74b
19 changed files with 82 additions and 119 deletions

View file

@ -62,53 +62,7 @@
"import/resolver": { "import/resolver": {
"typescript": { "typescript": {
"alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist` "alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
}, }
},
"rules": {
"camelcase": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-shadow": "off",
"no-unused-vars": "off",
"prefer-template": "off",
"semi": [ "error", "never"],
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-unused-vars": ["error", {"varsIgnorePattern": "^_"}],
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
} }
} }
} }

3
dist/package.json generated vendored Normal file
View file

@ -0,0 +1,3 @@
{
"type": "module"
}

1
dist/sourcemap-register.cjs generated vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,9 +1,10 @@
{ {
"name": "test-check", "name": "test-check",
"version": "2.0.1", "version": "2.1.0",
"private": true, "private": true,
"description": "Presents test results from popular testing frameworks as Github check run", "description": "Presents test results from popular testing frameworks as Github check run",
"main": "lib/main.js", "main": "lib/main.js",
"type": "module",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"format": "prettier --write **/*.ts", "format": "prettier --write **/*.ts",
@ -32,14 +33,14 @@
"author": "Michal Dorner <dorner.michal@gmail.com>", "author": "Michal Dorner <dorner.michal@gmail.com>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.6.0", "@actions/core": "^1.10.0",
"@actions/exec": "^1.1.0", "@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"@slack/webhook": "^6.0.0", "@slack/webhook": "^6.1.0",
"adm-zip": "^0.5.10", "adm-zip": "^0.5.10",
"bent": "^7.3.12", "bent": "^7.3.12",
"fast-glob": "^3.3.2", "fast-glob": "^3.3.2",
"got": "^11.8.2", "got": "^12.5.2",
"picomatch": "^3.0.1", "picomatch": "^3.0.1",
"xml2js": "^0.6.2" "xml2js": "^0.6.2"
}, },
@ -49,7 +50,7 @@
"@octokit/webhooks-types": "^7.3.1", "@octokit/webhooks-types": "^7.3.1",
"@types/adm-zip": "^0.5.5", "@types/adm-zip": "^0.5.5",
"@types/bent": "^7.3.2", "@types/bent": "^7.3.2",
"@types/github-slugger": "^1.3.0", "@types/github-slugger": "^2.0.0",
"@types/jest": "^29.5.11", "@types/jest": "^29.5.11",
"@types/node": "^20.10.4", "@types/node": "^20.10.4",
"@types/picomatch": "^2.3.3", "@types/picomatch": "^2.3.3",

View file

@ -1,7 +1,7 @@
import * as fs from 'fs' import * as fs from 'fs'
import glob from 'fast-glob' import glob from 'fast-glob'
import {FileContent, InputProvider, ReportInput} from './input-provider' import {FileContent, InputProvider, ReportInput} from './input-provider.js'
import {listFiles} from '../utils/git' import {listFiles} from '../utils/git.js'
export class LocalFileProvider implements InputProvider { export class LocalFileProvider implements InputProvider {
constructor( constructor(

View file

@ -1,31 +1,28 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as github from '@actions/github' import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils' import {GitHub} from '@actions/github/lib/utils.js'
import {ArtifactProvider} from './input-providers/artifact-provider' import {ArtifactProvider} from './input-providers/artifact-provider.js'
import {LocalFileProvider} from './input-providers/local-file-provider' import {LocalFileProvider} from './input-providers/local-file-provider.js'
import {FileContent} from './input-providers/input-provider' import {FileContent} from './input-providers/input-provider.js'
import {ParseOptions, TestParser} from './test-parser' import {ParseOptions, TestParser} from './test-parser.js'
import {TestRunResult} from './test-results' import {TestRunResult} from './test-results.js'
import {getAnnotations} from './report/get-annotations' import {getAnnotations} from './report/get-annotations.js'
import {getReport} from './report/get-report' import {getReport} from './report/get-report.js'
import {DartJsonParser} from './parsers/dart-json/dart-json-parser' import {DartJsonParser} from './parsers/dart-json/dart-json-parser.js'
import {DotnetTrxParser} from './parsers/dotnet-trx/dotnet-trx-parser' import {DotnetTrxParser} from './parsers/dotnet-trx/dotnet-trx-parser.js'
import {JavaJunitParser} from './parsers/java-junit/java-junit-parser' import {JavaJunitParser} from './parsers/java-junit/java-junit-parser.js'
import {JestJunitParser} from './parsers/jest-junit/jest-junit-parser' import {JestJunitParser} from './parsers/jest-junit/jest-junit-parser.js'
import {MochaJsonParser} from './parsers/mocha-json/mocha-json-parser' import {MochaJsonParser} from './parsers/mocha-json/mocha-json-parser.js'
import {SwiftXunitParser} from './parsers/swift-xunit/swift-xunit-parser' import {SwiftXunitParser} from './parsers/swift-xunit/swift-xunit-parser.js'
import {normalizeDirPath, normalizeFilePath} from './utils/path-utils' import {normalizeDirPath, normalizeFilePath} from './utils/path-utils.js'
import {getCheckRunContext} from './utils/github-utils' import {getCheckRunContext} from './utils/github-utils.js'
import {IncomingWebhook} from '@slack/webhook' import {IncomingWebhook} from '@slack/webhook'
import fs from 'fs' import fs from 'fs'
//import fetch from 'node-fetch'
import bent from 'bent' import bent from 'bent'
import { cwd } from 'process'; import { cwd } from 'process';
import Zip from 'adm-zip'
import path from 'path'
async function main(): Promise<void> { async function main(): Promise<void> {
try { try {
@ -121,15 +118,21 @@ class TestReporter {
try { try {
const readStream = input.trxZip.toBuffer(); const readStream = input.trxZip.toBuffer()
const version = fs.existsSync('src/EVA.TestSuite.Core/bin/Release/version.txt') ? fs.readFileSync('src/EVA.TestSuite.Core/bin/Release/version.txt').toString() : null; const version = fs.existsSync('src/EVA.TestSuite.Core/bin/Release/version.txt')
const commitID = fs.existsSync('src/EVA.TestSuite.Core/bin/Release/commit.txt') ? fs.readFileSync('src/EVA.TestSuite.Core/bin/Release/commit.txt').toString() : null; ? fs.readFileSync('src/EVA.TestSuite.Core/bin/Release/version.txt').toString()
: null
const commitID = fs.existsSync('src/EVA.TestSuite.Core/bin/Release/commit.txt')
? fs.readFileSync('src/EVA.TestSuite.Core/bin/Release/commit.txt').toString()
: null
core.info(`Using EVA version ${version}, commit ${commitID}, current directory: ${cwd()}`) core.info(`Using EVA version ${version}, commit ${commitID}, current directory: ${cwd()}`)
const post = bent(this.resultsEndpoint, 'POST', {}, 200) const post = bent(this.resultsEndpoint, 'POST', {}, 200)
await post( await post(
`TestResults?Secret=${this.resultsEndpointSecret}${version ? '&EVAVersion=' + version : ''}${commitID ? '&EVACommitID=' + commitID : ''}`, `TestResults?Secret=${this.resultsEndpointSecret}${version ? '&EVAVersion=' + version : ''}${
commitID ? '&EVACommitID=' + commitID : ''
}`,
readStream readStream
) )
core.info(`Uploaded TRX files`) core.info(`Uploaded TRX files`)

View file

@ -1,6 +1,6 @@
import {ParseOptions, TestParser} from '../../test-parser' import {ParseOptions, TestParser} from '../../test-parser.js'
import {getBasePath, normalizeFilePath} from '../../utils/path-utils' import {getBasePath, normalizeFilePath} from '../../utils/path-utils.js'
import { import {
ReportEvent, ReportEvent,
@ -17,7 +17,7 @@ import {
isDoneEvent, isDoneEvent,
isMessageEvent, isMessageEvent,
MessageEvent MessageEvent
} from './dart-json-types' } from './dart-json-types.js'
import { import {
TestExecutionResult, TestExecutionResult,
@ -26,7 +26,7 @@ import {
TestGroupResult, TestGroupResult,
TestCaseResult, TestCaseResult,
TestCaseError TestCaseError
} from '../../test-results' } from '../../test-results.js'
class TestRun { class TestRun {
constructor( constructor(

View file

@ -1,10 +1,10 @@
import {parseStringPromise} from 'xml2js' import {parseStringPromise} from 'xml2js'
import {ErrorInfo, Outcome, TrxReport, UnitTest, UnitTestResult} from './dotnet-trx-types' import {ErrorInfo, Outcome, TrxReport, UnitTest, UnitTestResult} from './dotnet-trx-types.js'
import {ParseOptions, TestParser} from '../../test-parser' import {ParseOptions, TestParser} from '../../test-parser.js'
import {getBasePath, normalizeFilePath} from '../../utils/path-utils' import {getBasePath, normalizeFilePath} from '../../utils/path-utils.js'
import {parseIsoDate, parseNetDuration} from '../../utils/parse-utils' import {parseIsoDate, parseNetDuration} from '../../utils/parse-utils.js'
import { import {
TestExecutionResult, TestExecutionResult,
@ -13,7 +13,7 @@ import {
TestGroupResult, TestGroupResult,
TestCaseResult, TestCaseResult,
TestCaseError TestCaseError
} from '../../test-results' } from '../../test-results.js'
class TestClass { class TestClass {
constructor(readonly name: string) {} constructor(readonly name: string) {}

View file

@ -1,10 +1,10 @@
import * as path from 'path' import * as path from 'path'
import {ParseOptions, TestParser} from '../../test-parser' import {ParseOptions, TestParser} from '../../test-parser.js'
import {parseStringPromise} from 'xml2js' import {parseStringPromise} from 'xml2js'
import {JunitReport, SingleSuiteReport, TestCase, TestSuite} from './java-junit-types' import {parseStackTraceElement} from './java-stack-trace-element-parser.js'
import {parseStackTraceElement} from './java-stack-trace-element-parser' import {JunitReport, SingleSuiteReport, TestCase, TestSuite} from './java-junit-types.js'
import {normalizeFilePath} from '../../utils/path-utils' import {normalizeFilePath} from '../../utils/path-utils.js'
import { import {
TestExecutionResult, TestExecutionResult,
@ -13,7 +13,7 @@ import {
TestGroupResult, TestGroupResult,
TestCaseResult, TestCaseResult,
TestCaseError TestCaseError
} from '../../test-results' } from '../../test-results.js'
export class JavaJunitParser implements TestParser { export class JavaJunitParser implements TestParser {
readonly trackedFiles: {[fileName: string]: string[]} readonly trackedFiles: {[fileName: string]: string[]}

View file

@ -1,9 +1,9 @@
import {ParseOptions, TestParser} from '../../test-parser' import {ParseOptions, TestParser} from '../../test-parser.js'
import {parseStringPromise} from 'xml2js' import {parseStringPromise} from 'xml2js'
import {JunitReport, TestCase, TestSuite} from './jest-junit-types' import {JunitReport, TestCase, TestSuite} from './jest-junit-types.js'
import {getExceptionSource} from '../../utils/node-utils' import {getExceptionSource} from '../../utils/node-utils.js'
import {getBasePath, normalizeFilePath} from '../../utils/path-utils' import {getBasePath, normalizeFilePath} from '../../utils/path-utils.js'
import { import {
TestExecutionResult, TestExecutionResult,
@ -12,7 +12,7 @@ import {
TestGroupResult, TestGroupResult,
TestCaseResult, TestCaseResult,
TestCaseError TestCaseError
} from '../../test-results' } from '../../test-results.js'
export class JestJunitParser implements TestParser { export class JestJunitParser implements TestParser {
assumedWorkDir: string | undefined assumedWorkDir: string | undefined

View file

@ -1,4 +1,4 @@
import {ParseOptions, TestParser} from '../../test-parser' import {ParseOptions, TestParser} from '../../test-parser.js'
import { import {
TestCaseError, TestCaseError,
TestCaseResult, TestCaseResult,
@ -6,10 +6,10 @@ import {
TestGroupResult, TestGroupResult,
TestRunResult, TestRunResult,
TestSuiteResult TestSuiteResult
} from '../../test-results' } from '../../test-results.js'
import {getExceptionSource} from '../../utils/node-utils' import {getExceptionSource} from '../../utils/node-utils.js'
import {getBasePath, normalizeFilePath} from '../../utils/path-utils' import {getBasePath, normalizeFilePath} from '../../utils/path-utils.js'
import {MochaJson, MochaJsonTest} from './mocha-json-types' import {MochaJson, MochaJsonTest} from './mocha-json-types.js'
export class MochaJsonParser implements TestParser { export class MochaJsonParser implements TestParser {
assumedWorkDir: string | undefined assumedWorkDir: string | undefined

View file

@ -1,5 +1,5 @@
import {ParseOptions} from '../../test-parser' import {ParseOptions} from '../../test-parser.js'
import {JavaJunitParser} from '../java-junit/java-junit-parser' import {JavaJunitParser} from '../java-junit/java-junit-parser.js'
export class SwiftXunitParser extends JavaJunitParser { export class SwiftXunitParser extends JavaJunitParser {
constructor(readonly options: ParseOptions) { constructor(readonly options: ParseOptions) {

View file

@ -1,6 +1,6 @@
import {ellipsis, fixEol} from '../utils/markdown-utils' import {ellipsis, fixEol} from '../utils/markdown-utils.js'
import {TestRunResult} from '../test-results' import {TestRunResult} from '../test-results.js'
import {getFirstNonEmptyLine} from '../utils/parse-utils' import {getFirstNonEmptyLine} from '../utils/parse-utils.js'
type Annotation = { type Annotation = {
path: string path: string

View file

@ -1,9 +1,9 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import {TestExecutionResult, TestRunResult, TestSuiteResult} from '../test-results' import {DEFAULT_LOCALE} from '../utils/node-utils.js'
import {Align, formatTime, Icon, link, table} from '../utils/markdown-utils' import {TestExecutionResult, TestRunResult, TestSuiteResult} from '../test-results.js'
import {DEFAULT_LOCALE} from '../utils/node-utils' import {Align, formatTime, Icon, link, table} from '../utils/markdown-utils.js'
import {getFirstNonEmptyLine} from '../utils/parse-utils' import {getFirstNonEmptyLine} from '../utils/parse-utils.js'
import {slug} from '../utils/slugger' import {slug} from '../utils/slugger.js'
const MAX_REPORT_LENGTH = 65535 const MAX_REPORT_LENGTH = 65535

View file

@ -1,4 +1,4 @@
import {TestRunResult} from './test-results' import {TestRunResult} from './test-results.js'
export interface ParseOptions { export interface ParseOptions {
parseErrors: boolean parseErrors: boolean

View file

@ -1,7 +1,7 @@
import {createWriteStream} from 'fs' import {createWriteStream} from 'fs'
import * as core from '@actions/core' import * as core from '@actions/core'
import * as github from '@actions/github' import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils' import {GitHub} from '@actions/github/lib/utils.js'
import * as stream from 'stream' import * as stream from 'stream'
import {promisify} from 'util' import {promisify} from 'util'
import got from 'got' import got from 'got'

View file

@ -1,4 +1,4 @@
import {normalizeFilePath} from './path-utils' import {normalizeFilePath} from './path-utils.js'
export const DEFAULT_LOCALE = 'en-US' export const DEFAULT_LOCALE = 'en-US'

View file

@ -6,7 +6,8 @@
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */ "strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"moduleResolution": "node16"
}, },
"exclude": ["node_modules", "**/*.test.ts"] "exclude": ["node_modules", "**/*.test.ts"]
} }