From 7bd306715e461a2b98124e54791eebc833db3627 Mon Sep 17 00:00:00 2001 From: go-coverage-action Date: Fri, 17 May 2024 17:13:36 +0000 Subject: [PATCH] chore: add cover for 16ee4493c983d2436f1822e21aa3a55f4df29aa5 --- go-test-app-01/index.css | 116 +++++++-- go-test-app-01/index.js | 227 +++++++++++------- ...3c983d2436f1822e21aa3a55f4df29aa5-inc.html | 108 +++++++++ ...93c983d2436f1822e21aa3a55f4df29aa5-inc.out | 1 + ...93c983d2436f1822e21aa3a55f4df29aa5-inc.txt | 1 + ...e4493c983d2436f1822e21aa3a55f4df29aa5.html | 137 +++++++++++ ...ee4493c983d2436f1822e21aa3a55f4df29aa5.out | 11 + ...ee4493c983d2436f1822e21aa3a55f4df29aa5.txt | 4 + 8 files changed, 492 insertions(+), 113 deletions(-) create mode 100644 go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.html create mode 100644 go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.out create mode 100644 go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.txt create mode 100644 go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.html create mode 100644 go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.out create mode 100644 go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.txt diff --git a/go-test-app-01/index.css b/go-test-app-01/index.css index 881a209..ec43b69 100644 --- a/go-test-app-01/index.css +++ b/go-test-app-01/index.css @@ -25,13 +25,15 @@ } * { - font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace !important; + font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, + "Liberation Mono", monospace !important; font-size: 12px; margin: 0; padding: 0; } -html, body { +html, +body { min-height: 100vh; overflow: hidden; } @@ -39,7 +41,7 @@ html, body { body { background: var(--background) !important; overflow-y: scroll; - opacity: 0; + transition: all 0.1s ease-in-out; } #topbar { @@ -60,7 +62,8 @@ body { align-items: center; } -#nav, #legend span { +#nav, +#legend span { margin-left: 15px; color: var(--topbar-color) !important; } @@ -71,7 +74,7 @@ body { } #nav::after { - content: '▼'; + content: "▼"; position: absolute; right: 1.2em; top: 50%; @@ -97,6 +100,46 @@ select { border-radius: 2px; } +input[type="checkbox"] { + height: 0; + width: 0; + visibility: hidden; + margin-left: auto; +} + +label { + cursor: pointer; + height: 20px; + width: 50px; + border-radius: 15px; + background: #afb8c133; + display: block; + position: relative; + margin-right: 15px; +} + +label:after { + content: ""; + position: absolute; + top: 0; + left: 0; + height: 100%; + aspect-ratio: 1 / 1; + background: #fff; + border-radius: 50%; + transform: scale(0.9); + transition: 0.3s; +} + +input:checked + label { + background: #00000033; +} + +input:checked + label:after { + left: 100%; + transform: scale(0.9) translateX(-110%); +} + #content { position: relative; padding: 15px 0; @@ -108,7 +151,8 @@ pre { background: transparent !important; } -pre .code, pre .coverage { +pre .code, +pre .coverage { display: flex; flex-direction: row; gap: 10px; @@ -138,26 +182,56 @@ pre .editor { background: transparent !important; } -.cov0 { +.cov0 { color: rgba(0, 0, 0, 0) !important; - background-color: color-mix(in srgb, var(--uncovered) 10%, transparent) !important; + background-color: color-mix( + in srgb, + var(--uncovered) 10%, + transparent + ) !important; } .cov0 .ln { color: var(--uncovered) !important; - background-color: color-mix(in srgb, var(--uncovered) 10%, transparent) !important; -} - -.cov1, .cov2, .cov3, -.cov4, .cov5, .cov6, -.cov7, .cov8, .cov9, .cov10 { + background-color: color-mix( + in srgb, + var(--uncovered) 10%, + transparent + ) !important; +} + +.cov1, +.cov2, +.cov3, +.cov4, +.cov5, +.cov6, +.cov7, +.cov8, +.cov9, +.cov10 { color: rgba(0, 0, 0, 0) !important; - background-color: color-mix(in srgb, var(--covered) 10%, transparent) !important; -} - -.cov1 .ln, .cov2 .ln, .cov3 .ln, -.cov4 .ln, .cov5 .ln, .cov6 .ln, -.cov7 .ln, .cov8 .ln, .cov9 .ln, .cov10 .ln { + background-color: color-mix( + in srgb, + var(--covered) 10%, + transparent + ) !important; +} + +.cov1 .ln, +.cov2 .ln, +.cov3 .ln, +.cov4 .ln, +.cov5 .ln, +.cov6 .ln, +.cov7 .ln, +.cov8 .ln, +.cov9 .ln, +.cov10 .ln { color: green !important; - background-color: color-mix(in srgb, var(--covered) 10%, transparent) !important; + background-color: color-mix( + in srgb, + var(--covered) 10%, + transparent + ) !important; } diff --git a/go-test-app-01/index.js b/go-test-app-01/index.js index 950ad54..d4e9226 100644 --- a/go-test-app-01/index.js +++ b/go-test-app-01/index.js @@ -1,135 +1,178 @@ -load([ - ["https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css"], - ["https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css", 'disabled'], - ["https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"], - ["https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/go.min.js"], - ["../index.css"], +// hide the page until fully setup +document.documentElement.style.setProperty('opacity', '0') + +let loading = load([ + "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css", + "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css", + "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js", + "../index.css", ]); -document.addEventListener("DOMContentLoaded", main); -document.documentElement.style.setProperty("opacity", "0"); +// remove all default inline styles +document.querySelectorAll('style').forEach((el) => el.remove()) +// wait for the page to fully load +document.addEventListener('DOMContentLoaded', main) -function main () { - document.querySelectorAll('style').forEach((el) => el.remove()); - +function main() { + // wait for highlight.js to load if (!window.hljs) { - console.log("Waiting for highlight.js to load..."); - setTimeout(main, 100); - return; + console.log('loading: waiting for highlight.js to load...') + setTimeout(main, 100) + return } - document.documentElement.style.setProperty("opacity", "1"); - document.body.style.setProperty("transition", "all 0.1s ease-in-out"); - document.body.style.setProperty("opacity", "1"); + // wait for all assets to load + if (!loading.isDone()) { + console.log('loading: waiting for assets to load...') + setTimeout(main, 100) + return + } - document.querySelector("#legend").addEventListener("click", (event) => { - let lightStyle = document.querySelector('link[href*="github.min.css"]'); - let darkStyle = document.querySelector('link[href*="github-dark.min.css"]'); + configureTheme() + configureCodeBlocks() + highlight('.code .editor') + addLineNumbers() - document.documentElement.classList.toggle("dark"); + // setup complete, restore the page visibility + document.documentElement.style.setProperty('opacity', '1') +} - if (document.documentElement.classList.contains("dark")) { - lightStyle.setAttribute("disabled", "disabled"); - darkStyle.removeAttribute("disabled"); - } else { - lightStyle.removeAttribute("disabled"); - darkStyle.setAttribute("disabled", "disabled"); - } - }); +function configureTheme() { + let isDark = localStorage.getItem('dark') === 'true' + + document.querySelector('#topbar').innerHTML += ` + + + ` + + if (isDark) { + toggleDarkMode() + } + + document.querySelector('#switch').addEventListener('click', toggleDarkMode) +} + +function toggleDarkMode() { + let lightStyle = document.querySelector('link[href*="github.min.css"]') + let darkStyle = document.querySelector('link[href*="github-dark.min.css"]') - let pres = Array.from(document.querySelectorAll("#content pre")); - let clones = []; + document.documentElement.classList.toggle('dark') + + if (document.documentElement.classList.contains('dark')) { + localStorage.setItem('dark', 'true') + lightStyle.setAttribute('disabled', 'disabled') + darkStyle.removeAttribute('disabled') + } else { + localStorage.setItem('dark', 'false') + lightStyle.removeAttribute('disabled') + darkStyle.setAttribute('disabled', 'disabled') + } +} + +function configureCodeBlocks() { + let pres = Array.from(document.querySelectorAll('#content pre')) pres.forEach((pre) => { - let gutter = document.createElement("div"); - gutter.classList.add("gutter"); - - let editor = document.createElement("div"); - editor.classList.add("editor"); - editor.innerHTML = pre.innerHTML; - - let code = document.createElement("div"); - code.classList.add("code"); - code.style.setProperty("top", "0"); - code.style.setProperty("left", "0"); - code.style.setProperty("position", "absolute"); - code.appendChild(gutter); - code.appendChild(editor); - - let coverage = code.cloneNode(true); - coverage.classList = "coverage"; - - pre.innerHTML = ""; - pre.appendChild(coverage); - pre.appendChild(code); - }); - - highlight(); - addLineNumbers(); + let gutter = document.createElement('div') + gutter.classList.add('gutter') + + let editor = document.createElement('div') + editor.classList.add('editor') + editor.innerHTML = pre.innerHTML + + let code = document.createElement('div') + code.classList.add('code') + code.style.setProperty('top', '0') + code.style.setProperty('left', '0') + code.style.setProperty('position', 'absolute') + code.appendChild(gutter) + code.appendChild(editor) + + let coverage = code.cloneNode(true) + coverage.classList = 'coverage' + + pre.innerHTML = '' + pre.appendChild(coverage) + pre.appendChild(code) + }) } -function highlight() { - hljs.configure({ cssSelector: ".code .editor" }); - hljs.highlightAll(); +function highlight(cssSelector) { + hljs.configure({ cssSelector, ignoreUnescapedHTML: true }) + hljs.highlightAll() } function addLineNumbers() { - let containers = Array.from(document.querySelectorAll("#content pre > div")); + let containers = Array.from(document.querySelectorAll('#content pre > div')) containers.forEach((container) => { - let gutter = container.querySelector(".gutter"); - let editor = container.querySelector(".editor"); - let code = editor.innerHTML.replaceAll(" ", " "); - let lines = code.split("\n"); - let linesCount = lines.length; - let gutterHtml = ""; + let gutter = container.querySelector('.gutter') + let editor = container.querySelector('.editor') + let code = editor.innerHTML.replaceAll(' ', ' ') + let lines = code.split('\n') + let linesCount = lines.length + let gutterHtml = '' editor.innerHTML = lines .map((line) => `${line}`) - .join("\n"); + .join('\n') - let lineStarts = Array.from(editor.querySelectorAll(".line-start")); + let lineStarts = Array.from(editor.querySelectorAll('.line-start')) for (let i = 0; i < linesCount; i++) { let backgroundColor = window.getComputedStyle( lineStarts[i].parentElement, - ).backgroundColor; - let textColor = backgroundColor.replace(" / 0.1", " / 1"); + ).backgroundColor + let textColor = backgroundColor.replace(' / 0.1', ' / 1') - if (textColor === "rgba(0, 0, 0, 0)") { - gutterHtml += `
${i + 1}
`; + if (textColor === 'rgba(0, 0, 0, 0)') { + gutterHtml += `
${i + 1}
` } else { - gutterHtml += `
${i + 1}
`; + gutterHtml += `
${i + 1}
` } - } - gutter.innerHTML = gutterHtml; - }); + gutter.innerHTML = gutterHtml + }) } -function loadScript(src) { - let script = document.createElement("script"); - script.src = src; - script.async = false; - document.head.appendChild(script); +function loadScript(src, state) { + let script = document.createElement('script') + script.src = src + script.async = true + script.onload = () => { + console.info(`loaded: ${src}`) + state.loaded++ + } + document.head.appendChild(script) } -function loadStyle(src, disabled) { - let style = document.createElement("link"); - style.rel = "stylesheet"; - style.href = src; - style.disabled = disabled === "disabled"; - document.head.appendChild(style); +function loadStyle(src, state) { + let style = document.createElement('link') + style.rel = 'stylesheet' + style.href = src + style.async = true + style.onload = () => { + console.info(`loaded: ${src}`) + state.loaded++ + } + document.head.appendChild(style) } function load(urls) { - for (let [url, disabled] of urls) { - if (url.endsWith(".js")) { - loadScript(url); - } else if (url.endsWith(".css")) { - loadStyle(url, disabled); + let state = { + loaded: 0, + isDone: () => state.loaded === urls.length + } + + for (let url of urls) { + if (url.endsWith('.js')) { + loadScript(url, state) + } else if (url.endsWith('.css')) { + loadStyle(url, state) } } + + return state } diff --git a/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.html b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.html new file mode 100644 index 0000000..96fc007 --- /dev/null +++ b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.html @@ -0,0 +1,108 @@ + + + + + + Go Coverage Report + + + +
+ +
+ not tracked + + no coverage + low coverage + * + * + * + * + * + * + * + * + high coverage + +
+
+
+ +
+ + + diff --git a/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.out b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.out new file mode 100644 index 0000000..5f02b11 --- /dev/null +++ b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.out @@ -0,0 +1 @@ +mode: set diff --git a/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.txt b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.txt new file mode 100644 index 0000000..004bfa1 --- /dev/null +++ b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5-inc.txt @@ -0,0 +1 @@ +total: (statements) 0.0% diff --git a/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.html b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.html new file mode 100644 index 0000000..abdb232 --- /dev/null +++ b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.html @@ -0,0 +1,137 @@ + + + + + + cointoss: Go Coverage Report + + + +
+ +
+ not tracked + + not covered + covered + +
+
+
+ + + +
+ + + diff --git a/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.out b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.out new file mode 100644 index 0000000..0a1ec91 --- /dev/null +++ b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.out @@ -0,0 +1,11 @@ +mode: set +cointoss/main.go:10.13,11.27 1 1 +cointoss/main.go:11.27,13.3 1 1 +cointoss/main.go:13.8,15.3 1 0 +cointoss/main.go:17.2,17.32 1 1 +cointoss/main.go:20.24,21.23 1 1 +cointoss/main.go:21.23,23.3 1 1 +cointoss/main.go:23.8,25.3 1 0 +cointoss/main.go:28.19,29.21 1 1 +cointoss/main.go:29.21,31.3 1 1 +cointoss/main.go:31.8,33.3 1 0 diff --git a/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.txt b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.txt new file mode 100644 index 0000000..7713fd1 --- /dev/null +++ b/go-test-app-01/revisions/16ee4493c983d2436f1822e21aa3a55f4df29aa5.txt @@ -0,0 +1,4 @@ +cointoss/main.go:10: main 75.0% +cointoss/main.go:20: tossCoin 66.7% +cointoss/main.go:28: maybe 66.7% +total: (statements) 70.0%