-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #480 from gemini-testing/users/shadowusr/HERMIONE-…
…1052.basic-typescript-infra Add typescript infrastructure
- Loading branch information
Showing
160 changed files
with
27,579 additions
and
20,282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,12 @@ | ||
{ | ||
"plugins": [ | ||
["transform-runtime", {"polyfill": false}], | ||
["babel-plugin-transform-builtin-extend", {"globals": ["Error", "Array"]}] | ||
["@babel/plugin-transform-runtime"] | ||
], | ||
"env": { | ||
"test": { | ||
"presets": [ | ||
[ | ||
"env", | ||
{"exclude": ["transform-es2015-classes"]} | ||
], | ||
"react", | ||
"stage-0" | ||
], | ||
"plugins": ["dynamic-import-node"] | ||
}, | ||
"production": { | ||
"presets": [ | ||
"env", | ||
"react", | ||
"stage-0" | ||
] | ||
}, | ||
"development": { | ||
"presets": [ | ||
"env", | ||
"react", | ||
"stage-0" | ||
] | ||
} | ||
} | ||
"presets": [ | ||
"@babel/preset-react", | ||
["@babel/preset-env", { "modules": "commonjs"}], | ||
"@babel/preset-typescript" | ||
], | ||
"sourceMaps": true, | ||
"retainLines": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
**/.* | ||
build | ||
node_modules | ||
hot | ||
/lib/static/*.min.js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,30 @@ | ||
module.exports = { | ||
extends: 'gemini-testing', | ||
root: true | ||
extends: ['gemini-testing', 'plugin:@typescript-eslint/recommended', 'plugin:react/recommended'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint', 'react'], | ||
root: true, | ||
rules: { | ||
'@typescript-eslint/no-empty-function': 'off' | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.ts', '*.tsx'], | ||
rules: { | ||
'@typescript-eslint/explicit-function-return-type': 'error' | ||
} | ||
}, | ||
{ | ||
files: ['*.js'], | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 'off' | ||
} | ||
}, | ||
{ | ||
files: ['test/**'], | ||
rules: { | ||
// For convenient casting of test objects | ||
'@typescript-eslint/no-explicit-any': 'off' | ||
} | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
build | ||
hot | ||
sqlite.db | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
recursive: true, | ||
require: ["./test/ts-node", "./test/setup", "./test/assert-ext", "jsdom-global/register"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
.* | ||
test | ||
hot | ||
/lib/static/js/ | ||
/lib/static/report.css | ||
lib/static/js/ | ||
lib/static/report.css | ||
|
||
hermione-report | ||
.hermione.conf.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import crypto from 'crypto'; | ||
import {pick} from 'lodash'; | ||
import url from 'url'; | ||
import axios, {AxiosRequestConfig} from 'axios'; | ||
import {SUCCESS, FAIL, ERROR, SKIPPED, UPDATED, IDLE, RUNNING, QUEUED} from './constants/test-statuses'; | ||
|
||
import {UNCHECKED, INDETERMINATE, CHECKED} from './constants/checked-statuses'; | ||
export const getShortMD5 = (str: string): string => { | ||
return crypto.createHash('md5').update(str, 'ascii').digest('hex').substr(0, 7); | ||
}; | ||
|
||
const statusPriority: string[] = [ | ||
// non-final | ||
RUNNING, QUEUED, | ||
|
||
// final | ||
ERROR, FAIL, UPDATED, SUCCESS, IDLE, SKIPPED | ||
]; | ||
|
||
export const logger = pick(console, ['log', 'warn', 'error']); | ||
|
||
export const isSuccessStatus = (status: string): boolean => status === SUCCESS; | ||
export const isFailStatus = (status: string): boolean => status === FAIL; | ||
export const isIdleStatus = (status: string): boolean => status === IDLE; | ||
export const isRunningStatus = (status: string): boolean => status === RUNNING; | ||
export const isErroredStatus = (status: string): boolean => status === ERROR; | ||
export const isSkippedStatus = (status: string): boolean => status === SKIPPED; | ||
export const isUpdatedStatus = (status: string): boolean => status === UPDATED; | ||
|
||
export const determineStatus = (statuses: string[]): string | null => { | ||
if (!statuses.length) { | ||
return SUCCESS; | ||
} | ||
|
||
const set = new Set(statuses); | ||
for (const status of statusPriority) { | ||
if (set.has(status)) { | ||
return status; | ||
} | ||
} | ||
|
||
console.error('Unknown statuses: ' + JSON.stringify(statuses)); | ||
|
||
return null; | ||
}; | ||
|
||
export const isUrl = (str: string): boolean => { | ||
if (typeof str !== 'string') { | ||
return false; | ||
} | ||
|
||
const parsedUrl = url.parse(str); | ||
|
||
return !!parsedUrl.host && !!parsedUrl.protocol; | ||
}; | ||
|
||
export const buildUrl = (href: string, {host}: {host?: string} = {}): string => { | ||
return host | ||
? url.format(Object.assign(url.parse(href), {host})) | ||
: href; | ||
}; | ||
|
||
export const fetchFile = async <T = unknown>(url: string, options?: AxiosRequestConfig) : Promise<{data: T | null, status: number}> => { | ||
try { | ||
const {data, status} = await axios.get(url, options); | ||
|
||
return {data, status}; | ||
} catch (e: any) { // eslint-disable-line @typescript-eslint/no-explicit-any | ||
logger.warn(`Error while fetching ${url}`, e); | ||
|
||
// 'unknown' for request blocked by CORS policy | ||
const status = e.response ? e.response.status : 'unknown'; | ||
|
||
return {data: null, status}; | ||
} | ||
}; | ||
|
||
const isRelativeUrl = (url: string): boolean => { | ||
try { | ||
// eslint-disable-next-line no-new | ||
new URL(url); | ||
|
||
return false; | ||
} catch (e) { | ||
return true; | ||
} | ||
}; | ||
|
||
export const normalizeUrls = (urls: string[] = [], baseUrl: string): string[] => { | ||
const baseUrlsSearch = new URL(baseUrl).search; | ||
|
||
return urls.map(url => { | ||
try { | ||
const newUrl = new URL(url, baseUrl); | ||
|
||
// URL's parameters can specify directory at file server | ||
if (isRelativeUrl(url) && !newUrl.search) { | ||
newUrl.search = baseUrlsSearch; | ||
} | ||
|
||
return newUrl.href; | ||
} catch (e) { | ||
logger.warn(`Can not normalize url '${url} for base url '${baseUrl}'`, e); | ||
|
||
return url; | ||
} | ||
}); | ||
}; | ||
|
||
// TODO: use enum types instead of numbers below | ||
export const isCheckboxChecked = (status: number): boolean => Number(status) === CHECKED; | ||
export const isCheckboxIndeterminate = (status: number): boolean => Number(status) === INDETERMINATE; | ||
export const isCheckboxUnchecked = (status: number): boolean => Number(status) === UNCHECKED; | ||
export const getToggledCheckboxState = (status: number): number => isCheckboxChecked(status) ? UNCHECKED : CHECKED; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.