-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 213049f
Showing
17 changed files
with
1,229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- dev | ||
schedule: | ||
- cron: "0 2 * * 1" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: "update contribution" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: dev | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20" | ||
- run: npm ci | ||
|
||
- name: Set up repository | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "actions@github.com" | ||
git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | ||
git fetch origin | ||
if [ -z "$GITHUB_HEAD_REF" ]; then | ||
# If not a PR, undo detached head | ||
git checkout "${GITHUB_REF:11}" | ||
fi | ||
- name: "Generate SVG" | ||
run: node fetcher | ||
env: | ||
TOKEN: ${{ secrets.FETCH_GITHUB_TOKEN }} | ||
|
||
- name: "Push changes to GitHub" | ||
run: | | ||
git add ./fetcher/lang.svg | ||
git commit --amend -m "update" | ||
git push --force -u origin HEAD:main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/.vscode |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Hi there 👋 | ||
|
||
## About me | ||
|
||
- I am an Automotive Software Development Engineer in China 🇨🇳. | ||
- I use C++ and TypeScript as my major development languages. | ||
- I am interested in runtime, compiler and language tooling related development. | ||
- [Assemblyscript](https://github.com/AssemblyScript/assemblyscript) | ||
- [LLVM](https://github.com/llvm/llvm-project) | ||
|
||
## My Technical Stack | ||
|
||
<img src="./cpp_Logo.png" height = "25"/> <img src="./Typescript.png" height = "25"/> <img src="./assemblyscript.svg" height = "25"/> <img src="./WebAssembly.png" height = "25"/> <img src="./LLVM_logo.png" height = "25"/> <img src="./Autosar_Logo.svg" height = "25"/> <img src="./bazel.svg" height = "25"/> | ||
|
||
## My Github | ||
|
||
![Top Langs](./fetcher/lang.svg) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import languages from "linguist-languages"; | ||
|
||
export function top(info, num) { | ||
let sum = 0; | ||
let data = []; | ||
for (const lang in info) { | ||
const line = info[lang]; | ||
sum += line; | ||
} | ||
|
||
console.log("statistic result :\n", info); | ||
|
||
for (const lang in info) { | ||
const line = info[lang]; | ||
data.push({ lang, rate: (line / sum) * 100, color: languages[lang].color }); | ||
} | ||
data.sort((a, b) => b.rate - a.rate); | ||
|
||
console.log("statistic result :\n", data); | ||
|
||
return data.slice(0, num); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import { writeFileSync } from "fs"; | ||
|
||
function drawItem(topItem, index) { | ||
return ` | ||
<g transform="translate(0, ${0 + index * 40})"> | ||
<g class="stagger" style="animation-delay: ${450 + 150 * index}ms"> | ||
<text data-testid="lang-name" x="2" y="15" class="lang-name">${topItem.lang}</text> | ||
<text x="215" y="34" class="lang-name">${topItem.rate.toFixed(2)}%</text> | ||
<svg width="205" x="0" y="25"> | ||
<rect rx="5" ry="5" x="0" y="0" width="205" height="8" fill="#ddd"></rect> | ||
<svg data-testid="lang-progress" width="${topItem.rate.toFixed(2)}%"> | ||
<rect height="8" fill="${topItem.color}" rx="5" ry="5" x="0" y="0" class="lang-progress" | ||
style="animation-delay: ${750 + 150 * index}ms;" /> | ||
</svg> | ||
</svg> | ||
</g> | ||
</g> | ||
`; | ||
} | ||
|
||
export function draw(topInfo) { | ||
const len = topInfo.length; | ||
const width = len * 40 + 85; | ||
|
||
const svg = ` | ||
<svg width="300" height="${width}" viewBox="0 0 300 ${width}" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" | ||
aria-labelledby="descId"> | ||
<title id="titleId"></title> | ||
<desc id="descId"></desc> | ||
<style> | ||
.header { | ||
font: 600 18px 'Segoe UI', Ubuntu, Sans-Serif; | ||
fill: #fe428e; | ||
animation: fadeInAnimation 0.8s ease-in-out forwards; | ||
} | ||
@supports(-moz-appearance: auto) { | ||
/* Selector detects Firefox */ | ||
.header { | ||
font-size: 15.5px; | ||
} | ||
} | ||
@keyframes slideInAnimation { | ||
from { | ||
width: 0; | ||
} | ||
to { | ||
width: calc(100%-100px); | ||
} | ||
} | ||
@keyframes growWidthAnimation { | ||
from { | ||
width: 0; | ||
} | ||
to { | ||
width: 100%; | ||
} | ||
} | ||
.stat { | ||
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; | ||
fill: #a9fef7; | ||
} | ||
@supports(-moz-appearance: auto) { | ||
/* Selector detects Firefox */ | ||
.stat { | ||
font-size: 12px; | ||
} | ||
} | ||
.bold { | ||
font-weight: 700 | ||
} | ||
.lang-name { | ||
font: 400 11px "Segoe UI", Ubuntu, Sans-Serif; | ||
fill: #a9fef7; | ||
} | ||
.stagger { | ||
opacity: 0; | ||
animation: fadeInAnimation 0.3s ease-in-out forwards; | ||
} | ||
#rect-mask rect { | ||
animation: slideInAnimation 1s ease-in-out forwards; | ||
} | ||
.lang-progress { | ||
animation: growWidthAnimation 0.6s ease-in-out forwards; | ||
} | ||
/* Animations */ | ||
@keyframes scaleInAnimation { | ||
from { | ||
transform: translate(-5px, 5px) scale(0); | ||
} | ||
to { | ||
transform: translate(-5px, 5px) scale(1); | ||
} | ||
} | ||
@keyframes fadeInAnimation { | ||
from { | ||
opacity: 0; | ||
} | ||
to { | ||
opacity: 1; | ||
} | ||
} | ||
</style> | ||
<rect data-testid="card-bg" x="0.5" y="0.5" rx="4.5" height="99%" stroke="#e4e2e2" width="299" fill="#141321" | ||
stroke-opacity="1" /> | ||
<g data-testid="card-title" transform="translate(25, 35)"> | ||
<g transform="translate(0, 0)"> | ||
<text x="0" y="0" class="header" data-testid="header">Most Used Languages</text> | ||
</g> | ||
</g> | ||
<g data-testid="main-card-body" transform="translate(0, 55)"> | ||
<svg data-testid="lang-items" x="25"> | ||
${topInfo.map((item, index) => drawItem(item, index)).join("\n")} | ||
</svg> | ||
</g> | ||
</svg> | ||
`; | ||
|
||
writeFileSync("fetcher/lang.svg", svg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Octokit } from "@octokit/core"; | ||
import { env } from "process"; | ||
import languages from "linguist-languages"; | ||
import { basename, extname } from "path"; | ||
|
||
const orgs = ["HerrCai0907", "Schleifner", "assemblyscript", "nodejs", "WebAssembly", "MaaAssistantArknights"]; | ||
const repos = ["llvm/llvm-project"]; | ||
const ignoreLanguages = ["WebAssembly"]; | ||
|
||
function prepareQuery() { | ||
const projectRanges = orgs.map((v) => `org:${v}`).join(" ") + " " + repos.map((v) => `repo:${v}`).join(" "); | ||
const startDate = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000); | ||
return encodeURIComponent(`author:HerrCai0907 ${projectRanges} committer-date:>${startDate.toISOString()}`); | ||
} | ||
|
||
const result = {}; | ||
|
||
function statistic(file, lines) { | ||
const ext = extname(file); | ||
(() => { | ||
for (let lang of Object.keys(languages)) { | ||
if (!languages[lang].color) continue; | ||
if (languages[lang].filenames?.includes(basename(file))) { | ||
result[lang] = result[lang] ?? 0; | ||
result[lang] += lines; | ||
console.log(`add '${lang}' ${lines} lines due to '${file}'`); | ||
return; | ||
} | ||
} | ||
for (let lang of Object.keys(languages)) { | ||
if (!languages[lang].color) continue; | ||
if (languages[lang].extensions?.includes(ext)) { | ||
result[lang] = result[lang] ?? 0; | ||
result[lang] += lines; | ||
console.log(`add '${lang}' ${lines} lines due to '${file}'`); | ||
return; | ||
} | ||
} | ||
})(); | ||
} | ||
|
||
export async function fetchFromGithub() { | ||
const octokit = new Octokit({ | ||
auth: env["TOKEN"], | ||
}); | ||
|
||
const request = `GET /search/commits?q=${prepareQuery()}`; | ||
|
||
console.log(`fetch ${request}`); | ||
|
||
for (let pageIndex = 0; ; pageIndex++) { | ||
const { | ||
data: { items }, | ||
} = await octokit.request(request, { | ||
headers: { "X-GitHub-Api-Version": "2022-11-28" }, | ||
per_page: 100, | ||
page: pageIndex, | ||
}); | ||
|
||
if (items.length == 0) { | ||
break; | ||
} | ||
await Promise.all( | ||
items.map(async (item) => { | ||
console.log(`fetch ${item.url}`); | ||
const { data } = await octokit.request(item.url); | ||
data.files.forEach((file) => { | ||
statistic(file.filename, file.changes); | ||
}); | ||
}) | ||
); | ||
} | ||
for (let lang of ignoreLanguages) { | ||
delete result[lang]; | ||
} | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { fetchFromGithub } from "./fetcher.js"; | ||
import { top } from "./analysis.js"; | ||
import { draw } from "./draw.js"; | ||
|
||
draw(top(await fetchFromGithub(), 5)); |
Oops, something went wrong.