ci: fix coverage charts version ordering

This commit is contained in:
NGPixel 2022-03-31 18:16:29 -04:00
parent 40c33b1281
commit 8bd48514b0
No known key found for this signature in database
GPG key ID: 8FDA2F1757F60D63
5 changed files with 31 additions and 50952 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -5,6 +5,7 @@ const find = require('lodash/find')
const round = require('lodash/round')
const fs = require('fs/promises')
const { DateTime } = require('luxon')
const isPlainObject = require('lodash/isPlainObject')
const dec = new TextDecoder()
@ -123,17 +124,41 @@ async function main () {
const { ChartJSNodeCanvas } = require('chartjs-node-canvas')
const chartJSNodeCanvas = new ChartJSNodeCanvas({ type: 'svg', width: 850, height: 300, backgroundColour: '#FFFFFF' })
// -> Reorder versions
const versions = []
for (const [key, value] of Object.entries(covData)) {
if (isPlainObject(value)) {
const vRel = find(releases, r => r.tag_name === key || r.tag_name === `v${key}`)
if (!vRel) {
continue
}
versions.push({
tag: key,
time: vRel.created_at,
stats: {
code: round(value.code * 100, 2),
template: round(value.template * 100, 2),
url: round(value.url * 100, 2)
}
})
}
}
const roVersions = orderBy(versions, ['time', 'tag'], ['asc', 'asc'])
// -> Fill axis + data points
const labels = []
const datasetCode = []
const datasetTemplate = []
const datasetUrl = []
for (const [key, value] of Object.entries(covData).sort((a, b) => a[0].localeCompare(b[0]))) {
labels.push(key)
datasetCode.push(round(value.code * 100, 2))
datasetTemplate.push(round(value.template * 100, 2))
datasetUrl.push(round(value.url * 100, 2))
for (const ver of roVersions) {
labels.push(ver.tag)
datasetCode.push(ver.stats.code)
datasetTemplate.push(ver.stats.template)
datasetUrl.push(ver.stats.url)
}
// -> Generate chart SVG
const outputStream = chartJSNodeCanvas.renderToBufferSync({
type: 'line',
options: {
@ -212,6 +237,7 @@ async function main () {
}, 'image/svg+xml')
const svg = Buffer.from(outputStream).toString('base64')
// -> Upload to common repo
console.info(`Uploading chart SVG for ${newRelease.name}...`)
await ghCommon.rest.repos.createOrUpdateFileContents({
owner,

View file

@ -17,7 +17,6 @@
"luxon": "2.3.1"
},
"devDependencies": {
"@vercel/ncc": "0.33.3",
"eslint": "7.32.0",
"eslint-config-standard": "16.0.3",
"eslint-plugin-import": "2.25.4",
@ -321,15 +320,6 @@
"integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=",
"dev": true
},
"node_modules/@vercel/ncc": {
"version": "0.33.3",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.33.3.tgz",
"integrity": "sha512-JGZ11QV+/ZcfudW2Cz2JVp54/pJNXbsuWRgSh2ZmmZdQBKXqBtIGrwI1Wyx8nlbzAiEFe7FHi4K1zX4//jxTnQ==",
"dev": true,
"bin": {
"ncc": "dist/ncc/cli.js"
}
},
"node_modules/abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@ -2939,12 +2929,6 @@
"integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=",
"dev": true
},
"@vercel/ncc": {
"version": "0.33.3",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.33.3.tgz",
"integrity": "sha512-JGZ11QV+/ZcfudW2Cz2JVp54/pJNXbsuWRgSh2ZmmZdQBKXqBtIGrwI1Wyx8nlbzAiEFe7FHi4K1zX4//jxTnQ==",
"dev": true
},
"abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",

View file

@ -3,9 +3,6 @@
"version": "1.0.0",
"description": "Parse and generate coverage and changelog files for Datatracker releases",
"main": "index.js",
"scripts": {
"build": "ncc build index.js -o dist"
},
"author": "IETF Trust",
"license": "BSD-3-Clause",
"dependencies": {
@ -17,7 +14,6 @@
"luxon": "2.3.1"
},
"devDependencies": {
"@vercel/ncc": "0.33.3",
"eslint": "7.32.0",
"eslint-config-standard": "16.0.3",
"eslint-plugin-import": "2.25.4",