-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
49 lines (42 loc) · 1.48 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
import * as core from '@actions/core';
import * as github from '@actions/github';
import * as glob from '@actions/glob';
import * as util from 'util';
import * as child_process from 'child_process';
import Test from './test';
const execw = util.promisify(child_process.exec);
const execr = async function(args) {
return (await execw(args)).stdout.trim();
};
(async () => {
core.startGroup('Collect Environment Data');
const vlibjudger = await execr(`${__dirname}/libjudger.so --version`);
const vcompiler = (await execr('g++ --version')).split('\n')[0];
const context = github.context;
const targetPattern = core.getInput('target');
const env = {
timestamp: +new Date(),
judger: context.action,
sha: context.sha,
libjudger_version: vlibjudger,
gcc_version: vcompiler,
repository: context.repo,
target_pattern: targetPattern,
};
console.log(env);
core.endGroup();
const globber = await glob.create(targetPattern);
let [passed, total] = [0, 0];
for await (const file of globber.globGenerator()) {
const tester = new Test(file);
const report = await tester.test();
total++;
if (report.result == 0) passed++;
}
if (passed === total) {
core.info(`\x1b[1;92m✓ All tests completed with ${passed} of ${total} tests passed.`);
} else {
core.setFailed(`✘ All tests completed with ${passed} of ${total} tests passed.`);
}
})();