Version 2.1
- No plugins are enabled by default - Logs from setup can be hidden - Number of repositories to inspect can be configured (default to 100) - Default events for habits plugin is now 100 - Number of events for habits can be overriden in query - Server app improvments - Test improvements - Better test
This commit is contained in:
@@ -20,25 +20,68 @@
|
||||
const graphql = octokit.graphql.defaults({headers:{authorization: `token ${token}`}})
|
||||
const rest = new OctokitRest.Octokit({auth:token})
|
||||
|
||||
//Perform tests
|
||||
await test.build()
|
||||
for (const template of [
|
||||
"classic"
|
||||
]) {
|
||||
for (const q of [
|
||||
{},
|
||||
{followup:1},
|
||||
{languages:1},
|
||||
{followup:1, languages:1},
|
||||
{habits:1, "habits.events":1},
|
||||
{lines:1},
|
||||
{traffic:1},
|
||||
{selfskip:1},
|
||||
{pagespeed:1},
|
||||
{followup:1, languages:1, habits:1, "habits.events":1, lines:1, traffic:1, selfskip:1, pagespeed:1}
|
||||
]) {
|
||||
await test.metrics({graphql, rest, q:{template, repositories:1, ...q}})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Metrics tests */
|
||||
test.metrics = async function ({graphql, rest, q}) {
|
||||
//Preparation
|
||||
console.log(`### Checking metrics with plugins [${Object.keys(q).filter(key => /^\w+$/.test(key)).join(", ")}]`)
|
||||
const plugins = {
|
||||
lines:{enabled:true},
|
||||
traffic:{enabled:true},
|
||||
pagespeed:{enabled:true},
|
||||
habits:{enabled:true},
|
||||
selfskip:{enabled:true},
|
||||
languages:{enabled:true},
|
||||
followup:{enabled:true},
|
||||
}
|
||||
|
||||
//Compute render
|
||||
const conf = await setup()
|
||||
const rendered = await metrics({login:"lowlighter", q:{}}, {graphql, rest, plugins:{}, conf})
|
||||
console.log("#### Checking that SVG can be generated")
|
||||
const conf = await setup({log:false})
|
||||
const rendered = await metrics({login:"lowlighter", q}, {graphql, rest, plugins, conf})
|
||||
|
||||
//Ensure it's a well-formed SVG image
|
||||
console.log("#### Checking that generated SVG can be parsed")
|
||||
const parsed = libxmljs.parseXml(rendered)
|
||||
if (parsed.errors.length)
|
||||
throw new Error(`Malformed SVG : \n${parsed.errors.join("\n")}`)
|
||||
}
|
||||
|
||||
/** Build test */
|
||||
test.build = async function () {
|
||||
//Ensure that action has been rebuild
|
||||
console.log("### Checking that code has been rebuild")
|
||||
const action = `${await fs.promises.readFile(`${__dirname}/dist/index.js`)}`
|
||||
const code = await build()
|
||||
if (action !== code)
|
||||
throw new Error(`GitHub Action has not been rebuild. Run "npm run build" to solve this issue`)
|
||||
}
|
||||
|
||||
//Main
|
||||
if (/metrics.mjs/.test(process.argv[1])) {
|
||||
//Test
|
||||
await test()
|
||||
console.log("Test success !")
|
||||
}
|
||||
|
||||
//Main
|
||||
if (/metrics.mjs/.test(process.argv[1])) {
|
||||
//Test
|
||||
await test()
|
||||
console.log("Test success !")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user