From ef68aaf29d64eb547fc13229173508ec1d8ff887 Mon Sep 17 00:00:00 2001 From: Cihan Eran Date: Tue, 24 Sep 2024 22:41:33 +0000 Subject: [PATCH 1/7] feat: add custom repo commit history --- source/plugins/isocalendar/index.mjs | 179 +++++++++++++++++++++++---- 1 file changed, 152 insertions(+), 27 deletions(-) diff --git a/source/plugins/isocalendar/index.mjs b/source/plugins/isocalendar/index.mjs index 1b6b1711521..21b781b621b 100644 --- a/source/plugins/isocalendar/index.mjs +++ b/source/plugins/isocalendar/index.mjs @@ -1,13 +1,59 @@ +async function loadNonGitHubContributionsFromSourceFile(options) { + const { login: username } = options + + //load contributions from github public file + + let contributions = [] + try { + const response = await fetch(`https://raw.githubusercontent.com/${username}/${username}/refs/heads/metrics-renders/.contributions/gitlab.json`) + if (response.ok) { + contributions = await response.json() + } + } + catch (error) { + console.error("Failed to fetch contributions from source file", error) + } + + return { + contributions, + //eslint-disable-next-line object-shorthand + getRange: function (from, to) { + //create week chunks + let chunks = [] + for (let start = new Date(from); start < to;) { + const end = new Date(start) + end.setUTCDate(end.getUTCDate() + 7) + + chunks.push( + { + contributionDays: [ + ...this.contributions.filter(entry => { + const date = new Date(entry.date) + + return start <= date && date < end + }) + ] + } + ) + + start = end + } + + return chunks + }, + } +} + //Setup -export default async function({login, data, graphql, q, imports, queries, account}, {enabled = false, extras = false} = {}) { +export default async function ({ login, data, graphql, q, imports, queries, account }, { enabled = false, extras = false } = {}) { //Plugin execution try { //Check if plugin is enabled and requirements are met - if ((!q.isocalendar) || (!imports.metadata.plugins.isocalendar.enabled(enabled, {extras}))) + if ((!q.isocalendar) || (!imports.metadata.plugins.isocalendar.enabled(enabled, { extras }))) return null //Load inputs - let {duration} = imports.metadata.plugins.isocalendar.inputs({data, account, q}) + let { duration } = imports.metadata.plugins.isocalendar.inputs({ data, account, q }) //Compute start day const now = new Date() @@ -18,8 +64,9 @@ export default async function({login, data, graphql, q, imports, queries, accoun start.setUTCHours(-180 * 24) //Ensure start day is a sunday, and that time is set to 00:00:00.000 - if (start.getUTCDay()) + if (start.getUTCDay()) { start.setUTCHours(-start.getUTCDay() * 24) + } start.setUTCMilliseconds(0) start.setUTCSeconds(0) start.setUTCMinutes(0) @@ -27,9 +74,17 @@ export default async function({login, data, graphql, q, imports, queries, accoun //Compute contribution calendar, highest contributions in a day, streaks and average commits per day console.debug(`metrics/compute/${login}/plugins > isocalendar > computing stats`) - const calendar = {weeks: []} - const {streak, max, average} = await statistics({login, graphql, queries, start, end: now, calendar}) - const reference = Math.max(...calendar.weeks.flatMap(({contributionDays}) => contributionDays.map(({contributionCount}) => contributionCount))) + const calendar = { weeks: [] } + + const { streak, max, average } = await statistics({ login, graphql, queries, start, end: now, calendar }) + const reference = Math.max( + ...calendar.weeks.flatMap( + ({ contributionDays }) => { + const val = contributionDays.map(day => Object.keys(day).map(key => day[key].contributionCount)) + + return val.flat() + }) + ) //Compute SVG console.debug(`metrics/compute/${login}/plugins > isocalendar > computing svg render`) @@ -37,29 +92,63 @@ export default async function({login, data, graphql, q, imports, queries, accoun let i = 0, j = 0 let svg = ` - ${ - [1, 2].map(k => ` + ${[1, 2].map(k => ` ${[..."RGB"].map(channel => ``).join("")} `) .join("") - } + } ` //Iterate through weeks for (const week of calendar.weeks) { svg += `` j = 0 + //Iterate through days for (const day of week.contributionDays) { - const ratio = (day.contributionCount / reference) || 0 - svg += ` - - - - - ` + const count = Object.keys(day).reduce((acc, key) => acc + day[key].contributionCount, 0) + const ratio = (count / reference) || 0 + + svg += `` + + const topColor = Object.keys(day).reduce((acc, key, idx) => { + const { color, contributionCount } = day[key] + if (count === 0 && idx === 0) { + return color + } + if (count !== 0 && contributionCount === 0) { + return acc + } + if (acc === "") { + return color + } + + return acc + }, "") + svg += `` + + let offset = 0 + Object.keys(day).forEach((key, idx) => { + const { color, contributionCount } = day[key] + + //Find ratio of key + const r = contributionCount / reference || 0 + const shiftBy = r * size + + console.log("key::", key, contributionCount, reference, r, ratio) + + svg += ` + + + ` + + offset += shiftBy + }) + + svg += "" + j++ } svg += "" @@ -68,7 +157,7 @@ export default async function({login, data, graphql, q, imports, queries, accoun svg += "" //Results - return {streak, max, average, svg, duration} + return { streak, max, average, svg, duration } } //Handle errors catch (error) { @@ -77,8 +166,11 @@ export default async function({login, data, graphql, q, imports, queries, accoun } /**Compute max and current streaks */ -async function statistics({login, graphql, queries, start, end, calendar}) { - let average = 0, max = 0, streak = {max: 0, current: 0}, values = [] +async function statistics({ login, graphql, queries, start, end, calendar }) { + let average = 0, max = 0, streak = { max: 0, current: 0 }, values = [] + + const extracontribs = await loadNonGitHubContributionsFromSourceFile({ login }) + //Load contribution calendar for (let from = new Date(start); from < end;) { //Set date range @@ -94,21 +186,54 @@ async function statistics({login, graphql, queries, start, end, calendar}) { dto.setUTCMilliseconds(999) //Fetch data from api console.debug(`metrics/compute/${login}/plugins > isocalendar > loading calendar from "${from.toISOString()}" to "${dto.toISOString()}"`) - const {user: {calendar: {contributionCalendar: {weeks}}}} = await graphql(queries.isocalendar.calendar({login, from: from.toISOString(), to: dto.toISOString()})) - calendar.weeks.push(...weeks) + const { user: { calendar: { contributionCalendar: { weeks } } } } = await graphql(queries.isocalendar.calendar({ login, from: from.toISOString(), to: dto.toISOString() })) + + const extra = extracontribs.getRange(from, to) + + //Merge contributions + const entries = weeks.reduce((weekAcc, week, i) => { + const extraWeek = extra[i] + if (extraWeek) { + weekAcc.push({ + contributionDays: [ + ...week.contributionDays.reduce((dayAcc, day, i) => { + const extraDay = extraWeek.contributionDays[i] + if (extraDay) { + dayAcc.push({ github: day, gitlab: extraDay }) + } + else { + dayAcc.push({ github: day }) + } + + return dayAcc + }, []) + ] + }) + } + else { + weekAcc.push({ contributionDays: week.contributionDays.map(day => ({ github: day })) }) + } + + return weekAcc + }, []) + + calendar.weeks.push(...entries) + //Set next date range start from = new Date(to) } //Compute streaks for (const week of calendar.weeks) { for (const day of week.contributionDays) { - values.push(day.contributionCount) - max = Math.max(max, day.contributionCount) - streak.current = day.contributionCount ? streak.current + 1 : 0 - streak.max = Math.max(streak.max, streak.current) + Object.keys(day).forEach(key => { + values.push(day[key].contributionCount) + max = Math.max(max, day[key].contributionCount) + streak.current = day[key].contributionCount ? streak.current + 1 : 0 + streak.max = Math.max(streak.max, streak.current) + }) } } //Compute average average = (values.reduce((a, b) => a + b, 0) / values.length).toFixed(2).replace(/[.]0+$/, "") - return {streak, max, average} + return { streak, max, average } } From 258fd818217896f9b3724932f4d38d7d86979742 Mon Sep 17 00:00:00 2001 From: Cihan Eran Date: Sat, 11 Jan 2025 08:45:17 +0300 Subject: [PATCH 2/7] feat: update dockerfile --- Dockerfile | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3ff5209a48a..7c77ff3a341 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,28 +6,28 @@ COPY . /metrics WORKDIR /metrics # Setup -RUN chmod +x /metrics/source/app/action/index.mjs \ - # Install latest chrome dev package, fonts to support major charsets and skip chromium download on puppeteer install - # Based on https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker - && apt-get update \ - && apt-get install -y wget gnupg ca-certificates libgconf-2-4 \ - && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ - && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ - && apt-get update \ - && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libx11-xcb1 libxtst6 lsb-release --no-install-recommends \ - # Install deno for miscellaneous scripts - && apt-get install -y curl unzip \ - && curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL=/usr/local sh \ - # Install ruby to support github licensed gem - && apt-get install -y ruby-full git g++ cmake pkg-config libssl-dev \ - && gem install licensed \ - # Install python for node-gyp - && apt-get install -y python3 \ - # Clean apt/lists - && rm -rf /var/lib/apt/lists/* \ - # Install node modules and rebuild indexes - && npm ci \ - && npm run build +RUN chmod +x /metrics/source/app/action/index.mjs +# Install latest chrome dev package, fonts to support major charsets and skip chromium download on puppeteer install +# Based on https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker +RUN apt-get update +RUN apt-get install -y wget gnupg ca-certificates libgconf-2-4 +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - +RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' +RUN apt-get update +RUN apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libx11-xcb1 libxtst6 lsb-release --no-install-recommends +# Install deno for miscellaneous scripts +RUN apt-get install -y curl unzip +RUN curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL=/usr/local sh +# Install ruby to support github licensed gem +RUN apt-get install -y ruby-full git g++ cmake pkg-config libssl-dev +RUN gem install licensed +# Install python for node-gyp +RUN apt-get install -y python3 +# Clean apt/lists +RUN rm -rf /var/lib/apt/lists/* +# Install node modules and rebuild indexes +RUN npm ci +RUN npm run build # Environment variables ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true From 1745e61c4c8e7f76dc6dcb6a7e17770642679a11 Mon Sep 17 00:00:00 2001 From: Cihan Eran Date: Sat, 11 Jan 2025 08:54:33 +0300 Subject: [PATCH 3/7] feat: update Dockerfile --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 7c77ff3a341..f9b1775babc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ RUN chmod +x /metrics/source/app/action/index.mjs # Install latest chrome dev package, fonts to support major charsets and skip chromium download on puppeteer install # Based on https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker RUN apt-get update +RUN apt-get install -y build-essential RUN apt-get install -y wget gnupg ca-certificates libgconf-2-4 RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' @@ -20,6 +21,7 @@ RUN apt-get install -y curl unzip RUN curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL=/usr/local sh # Install ruby to support github licensed gem RUN apt-get install -y ruby-full git g++ cmake pkg-config libssl-dev +RUN apt-get install -y ruby-dev RUN gem install licensed # Install python for node-gyp RUN apt-get install -y python3 From 2328378124e30a634a6f78d37cc5fe4b6003a0d9 Mon Sep 17 00:00:00 2001 From: Cihan Eran Date: Sat, 11 Jan 2025 09:01:04 +0300 Subject: [PATCH 4/7] feat: update Dockerfile --- Dockerfile | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index f9b1775babc..4d9cd970970 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,30 +6,28 @@ COPY . /metrics WORKDIR /metrics # Setup -RUN chmod +x /metrics/source/app/action/index.mjs +RUN chmod +x /metrics/source/app/action/index.mjs # Install latest chrome dev package, fonts to support major charsets and skip chromium download on puppeteer install # Based on https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker -RUN apt-get update -RUN apt-get install -y build-essential -RUN apt-get install -y wget gnupg ca-certificates libgconf-2-4 -RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - -RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' -RUN apt-get update -RUN apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libx11-xcb1 libxtst6 lsb-release --no-install-recommends +RUN apt-get -q update \ + && apt-get -q install -y build-essential wget gnupg ca-certificates libgconf-2-4 \ + && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ + && apt-get -q update \ + && apt-get -q install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libx11-xcb1 libxtst6 lsb-release --no-install-recommends # Install deno for miscellaneous scripts -RUN apt-get install -y curl unzip -RUN curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL=/usr/local sh +RUN apt-get install -y curl unzip \ + && curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL=/usr/local sh # Install ruby to support github licensed gem -RUN apt-get install -y ruby-full git g++ cmake pkg-config libssl-dev -RUN apt-get install -y ruby-dev -RUN gem install licensed +RUN apt-get -q install -y ruby-full git g++ cmake pkg-config libssl-dev \ + && apt-get -q install -y ruby-dev \ + && gem install licensed # Install python for node-gyp -RUN apt-get install -y python3 +RUN apt-get -q install -y python3 # Clean apt/lists RUN rm -rf /var/lib/apt/lists/* # Install node modules and rebuild indexes -RUN npm ci -RUN npm run build +RUN npm ci && npm run build # Environment variables ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true From 050e9602d88fff9022b315291daaadf23c912212 Mon Sep 17 00:00:00 2001 From: Cihan Eran Date: Fri, 24 Jan 2025 22:20:12 +0300 Subject: [PATCH 5/7] feat: update isocalendar script --- source/plugins/isocalendar/index.mjs | 180 ++++++++++++++------------- 1 file changed, 95 insertions(+), 85 deletions(-) diff --git a/source/plugins/isocalendar/index.mjs b/source/plugins/isocalendar/index.mjs index 21b781b621b..e1e163f6ed0 100644 --- a/source/plugins/isocalendar/index.mjs +++ b/source/plugins/isocalendar/index.mjs @@ -44,6 +44,23 @@ async function loadNonGitHubContributionsFromSourceFile(options) { } } +function findTopColorForDay(day, count) { + return Object.keys(day).reduce((acc, key, idx) => { + const { color, contributionCount } = day[key] + if (count === 0 && idx === 0) { + return color + } + if (count !== 0 && contributionCount === 0) { + return acc + } + if (acc === "") { + return color + } + + return acc + }, "") +} + //Setup export default async function ({ login, data, graphql, q, imports, queries, account }, { enabled = false, extras = false } = {}) { //Plugin execution @@ -88,8 +105,9 @@ export default async function ({ login, data, graphql, q, imports, queries, acco //Compute SVG console.debug(`metrics/compute/${login}/plugins > isocalendar > computing svg render`) - const size = 6 - let i = 0, j = 0 + const size = 6; + let i = 0; + let j = 0; let svg = ` ${[1, 2].map(k => ` @@ -97,64 +115,47 @@ export default async function ({ login, data, graphql, q, imports, queries, acco ${[..."RGB"].map(channel => ``).join("")} - `) - .join("") - } - ` + `).join("")} + `; + //Iterate through weeks for (const week of calendar.weeks) { - svg += `` - j = 0 + svg += ``; + j = 0; //Iterate through days for (const day of week.contributionDays) { - const count = Object.keys(day).reduce((acc, key) => acc + day[key].contributionCount, 0) - const ratio = (count / reference) || 0 - - svg += `` + const count = Object.keys(day).reduce((acc, key) => acc + day[key].contributionCount, 0); + const ratio = (count / reference) || 0; - const topColor = Object.keys(day).reduce((acc, key, idx) => { - const { color, contributionCount } = day[key] - if (count === 0 && idx === 0) { - return color - } - if (count !== 0 && contributionCount === 0) { - return acc - } - if (acc === "") { - return color - } + svg += ``; - return acc - }, "") - svg += `` + const topColor = findTopColorForDay(day, count); + svg += ``; - let offset = 0 + let offset = 0; Object.keys(day).forEach((key, idx) => { - const { color, contributionCount } = day[key] + const { color, contributionCount } = day[key]; //Find ratio of key - const r = contributionCount / reference || 0 - const shiftBy = r * size - - console.log("key::", key, contributionCount, reference, r, ratio) + const r = contributionCount / reference || 0; + const shiftBy = r * size; svg += ` - ` + `; - offset += shiftBy - }) - - svg += "" + offset += shiftBy; + }); - j++ + svg += ""; + j++; } - svg += "" - i++ + svg += ""; + i++; } - svg += "" + svg += ""; //Results return { streak, max, average, svg, duration } @@ -165,75 +166,84 @@ export default async function ({ login, data, graphql, q, imports, queries, acco } } -/**Compute max and current streaks */ +/** + * Compute max and current streaks + * */ async function statistics({ login, graphql, queries, start, end, calendar }) { let average = 0, max = 0, streak = { max: 0, current: 0 }, values = [] - const extracontribs = await loadNonGitHubContributionsFromSourceFile({ login }) + const extracontribs = await loadNonGitHubContributionsFromSourceFile({ login }); //Load contribution calendar for (let from = new Date(start); from < end;) { //Set date range - let to = new Date(from) - to.setUTCHours(+4 * 7 * 24) - if (to > end) - to = end + let to = new Date(from); + to.setUTCHours(+4 * 7 * 24); + if (to > end) { + to = end; + } + //Ensure that date ranges are not overlapping by setting it to previous day at 23:59:59.999 - const dto = new Date(to) - dto.setUTCHours(-1) - dto.setUTCMinutes(59) - dto.setUTCSeconds(59) - dto.setUTCMilliseconds(999) + const dto = new Date(to); + dto.setUTCHours(-1); + dto.setUTCMinutes(59); + dto.setUTCSeconds(59); + dto.setUTCMilliseconds(999); + //Fetch data from api - console.debug(`metrics/compute/${login}/plugins > isocalendar > loading calendar from "${from.toISOString()}" to "${dto.toISOString()}"`) - const { user: { calendar: { contributionCalendar: { weeks } } } } = await graphql(queries.isocalendar.calendar({ login, from: from.toISOString(), to: dto.toISOString() })) + console.debug(`metrics/compute/${login}/plugins > isocalendar > loading calendar from "${from.toISOString()}" to "${dto.toISOString()}"`); + const { user: { calendar: { contributionCalendar: { weeks } } } } = await graphql(queries.isocalendar.calendar({ login, from: from.toISOString(), to: dto.toISOString() })); - const extra = extracontribs.getRange(from, to) + const extra = extracontribs.getRange(from, to); //Merge contributions const entries = weeks.reduce((weekAcc, week, i) => { - const extraWeek = extra[i] - if (extraWeek) { - weekAcc.push({ - contributionDays: [ - ...week.contributionDays.reduce((dayAcc, day, i) => { - const extraDay = extraWeek.contributionDays[i] - if (extraDay) { - dayAcc.push({ github: day, gitlab: extraDay }) - } - else { - dayAcc.push({ github: day }) - } - - return dayAcc - }, []) - ] - }) - } - else { - weekAcc.push({ contributionDays: week.contributionDays.map(day => ({ github: day })) }) + const extraWeek = extra[i]; + if (!extraWeek) { + weekAcc.push({ contributionDays: week.contributionDays.map(day => ({ github: day })) }); + return weekAcc; } - return weekAcc + weekAcc.push({ + contributionDays: [ + ...week.contributionDays.reduce((dayAcc, day, i) => { + const extraDay = extraWeek.contributionDays[i]; + + if (extraDay) { + dayAcc.push({ github: day, gitlab: extraDay }); + } + else { + dayAcc.push({ github: day }); + } + + return dayAcc; + }, []) + ] + }); + + return weekAcc; }, []) - calendar.weeks.push(...entries) + calendar.weeks.push(...entries); //Set next date range start - from = new Date(to) + from = new Date(to); } + //Compute streaks for (const week of calendar.weeks) { for (const day of week.contributionDays) { Object.keys(day).forEach(key => { - values.push(day[key].contributionCount) - max = Math.max(max, day[key].contributionCount) - streak.current = day[key].contributionCount ? streak.current + 1 : 0 - streak.max = Math.max(streak.max, streak.current) - }) + values.push(day[key].contributionCount); + max = Math.max(max, day[key].contributionCount); + streak.current = day[key].contributionCount ? streak.current + 1 : 0; + streak.max = Math.max(streak.max, streak.current); + }); } } + //Compute average - average = (values.reduce((a, b) => a + b, 0) / values.length).toFixed(2).replace(/[.]0+$/, "") - return { streak, max, average } + average = (values.reduce((a, b) => a + b, 0) / values.length).toFixed(2).replace(/[.]0+$/, ""); + + return { streak, max, average }; } From 17279bf00442bf2a99b2f6a127b92c71ed9d4cba Mon Sep 17 00:00:00 2001 From: Cihan Eran Date: Fri, 24 Jan 2025 22:29:51 +0300 Subject: [PATCH 6/7] feat: add devel build image --- .github/workflows/devel-image.yml | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/devel-image.yml diff --git a/.github/workflows/devel-image.yml b/.github/workflows/devel-image.yml new file mode 100644 index 00000000000..6490213b8a1 --- /dev/null +++ b/.github/workflows/devel-image.yml @@ -0,0 +1,79 @@ +# Create a Docker image for development and publish it to GitHub registry. + +on: + pull_request: + branches: + - master + +jobs: + # Format code + format: + name: Format code + runs-on: ubuntu-latest + # needs: [ build-test-analyze ] + # if: always() && (needs.build-test-analyze.result == 'success' || needs.build-test-analyze.result == 'skipped') + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Checkout master + run: git checkout master + - name: Format code + run: | + npm install -g dprint + mkdir -v -p /home/runner/.cache/dprint/cache + npx dprint fmt --config .github/config/dprint.json + - name: Publish formatted code + run: | + set +e + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git add --all + git commit -m "chore: code formatting" + git push + set -e + + update-indexes: + name: Publish rebuilt metrics indexes + runs-on: ubuntu-latest + needs: [ format ] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: 20 + - name: Pull changes + run: | + git checkout master + git pull + - name: Setup metrics + run: npm ci + - name: Publish rebuild metrics indexes + run: npm run build -- publish + + docker-devel: + name: Publish devel to GitHub registry + runs-on: ubuntu-latest + needs: [ update-indexes ] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Login to GitHub registry + run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Build docker image + run: docker build -t ghcr.io/erancihan/lowlighter-github-metrics:devel . + + - name: Publish to GitHub registry + run: docker push ghcr.io/erancihan/lowlighter-github-metrics:devel + + - name: Tag docker image (beta) and publish to GitHub registry + run: | + docker tag ghcr.io/erancihan/lowlighter-github-metrics:devel + docker push ghcr.io/erancihan/lowlighter-github-metrics:devel-beta From beafb4a57556f28c52b2b38a388410a1c77519c7 Mon Sep 17 00:00:00 2001 From: Cihan Eran Date: Fri, 24 Jan 2025 22:39:24 +0300 Subject: [PATCH 7/7] feat: tidy up workflow update indentation --- .github/workflows/devel-image.yml | 12 +++--------- source/plugins/isocalendar/index.mjs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/devel-image.yml b/.github/workflows/devel-image.yml index 6490213b8a1..6818a7c0e90 100644 --- a/.github/workflows/devel-image.yml +++ b/.github/workflows/devel-image.yml @@ -1,4 +1,5 @@ # Create a Docker image for development and publish it to GitHub registry. +name: Create Development Image on: pull_request: @@ -10,8 +11,6 @@ jobs: format: name: Format code runs-on: ubuntu-latest - # needs: [ build-test-analyze ] - # if: always() && (needs.build-test-analyze.result == 'success' || needs.build-test-analyze.result == 'skipped') steps: - name: Checkout repository uses: actions/checkout@v3 @@ -68,12 +67,7 @@ jobs: run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Build docker image - run: docker build -t ghcr.io/erancihan/lowlighter-github-metrics:devel . + run: docker build -t ghcr.io/${{ github.actor }}/lowlighter-github-metrics:devel . - name: Publish to GitHub registry - run: docker push ghcr.io/erancihan/lowlighter-github-metrics:devel - - - name: Tag docker image (beta) and publish to GitHub registry - run: | - docker tag ghcr.io/erancihan/lowlighter-github-metrics:devel - docker push ghcr.io/erancihan/lowlighter-github-metrics:devel-beta + run: docker push ghcr.io/${{ github.actor }}/lowlighter-github-metrics:devel diff --git a/source/plugins/isocalendar/index.mjs b/source/plugins/isocalendar/index.mjs index e1e163f6ed0..11bf5bc5ae5 100644 --- a/source/plugins/isocalendar/index.mjs +++ b/source/plugins/isocalendar/index.mjs @@ -109,14 +109,14 @@ export default async function ({ login, data, graphql, q, imports, queries, acco let i = 0; let j = 0; let svg = ` - - ${[1, 2].map(k => ` - - - ${[..."RGB"].map(channel => ``).join("")} - - `).join("")} - `; + + ${[1, 2].map(k => ` + + + ${[..."RGB"].map(channel => ``).join("")} + + `).join("")} + `; //Iterate through weeks for (const week of calendar.weeks) {