Skip to content

Commit

Permalink
chore: first implementation (#3)
Browse files Browse the repository at this point in the history
* chore: first impl

* chore: concurrency args

* chore: handle api rate limit errors

* yolo bro
  • Loading branch information
jpb06 authored Mar 15, 2024
1 parent d27d501 commit 45a435a
Show file tree
Hide file tree
Showing 43 changed files with 1,159 additions and 2,628 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# github

GITHUB_TOKEN="my-github-token"
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
**/dist
**/node_modules
**/coverage
vite.config.ts
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
settings: {
'import/resolver': {
node: {
extensions: ['.ts', '.tsx'],
extensions: ['.ts'],
},
typescript: {
alwaysTryTypes: true,
Expand Down Expand Up @@ -85,6 +85,13 @@ module.exports = {
},
},

// Vitest
{
files: ['**/*.test.ts', '**/*.spec.ts'],
plugins: ['eslint-plugin-vitest'],
extends: ['plugin:vitest/recommended'],
},

// Markdown
{
files: ['**/*.md'],
Expand Down
85 changes: 71 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,105 @@ jobs:
name: ⬣ ESLint
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1

- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 📦 Setup pnpm
uses: pnpm/action-setup@v2.4.0
with:
version: latest
- name: 📦 Setup bun
uses: oven-sh/setup-bun@v1

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'pnpm'
# cache: 'bun'
cache-dependency-path: ./package.json

- name: 📥 Install deps
run: pnpm install --frozen-lockfile
run: bun install --frozen-lockfile

- name: 🔬 Lint
run: pnpm lint
run: bun run lint

typecheck:
name: ʦ TypeScript
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1

- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 📦 Setup pnpm
uses: pnpm/action-setup@v2.4.0
with:
version: latest
- name: 📦 Setup bun
uses: oven-sh/setup-bun@v1

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'pnpm'
# cache: 'bun'
cache-dependency-path: ./package.json

- name: 📥 Install deps
run: pnpm install --frozen-lockfile
run: bun install --frozen-lockfile

- name: 🔎 Type check
run: pnpm type-check
run: bun run type-check

test:
name: 🎯 Tests
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1

- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 📦 Setup bun
uses: oven-sh/setup-bun@v1

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
# cache: 'bun'
cache-dependency-path: ./package.json

- name: 📥 Install deps
run: bun install --frozen-lockfile

- name: 🧪 Tests
run: bun run test-ci

- name: 💾 Uploading coverage artifact
uses: actions/upload-artifact@v4
with:
name: lcov
path: ./coverage/lcov.info

sonar:
name: 🛰️ Sonar
runs-on: ubuntu-latest
needs: [lint, typecheck, test]
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1

- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 👀 Get coverage artifact
uses: actions/download-artifact@v4
with:
name: lcov
path: ./coverage

- name: 📡 SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/coverage-badges-generation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: ⚡ Coverage badges generation

on:
push:
branches:
- main

jobs:
coverage-badges-generation:
name: 📣 Coverage badges generation
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1

- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 📦 Setup bun
uses: oven-sh/setup-bun@v1

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'
# cache: 'bun'
cache-dependency-path: ./package.json

- name: 📥 Install deps
run: bun install --frozen-lockfile

- name: 🔍 Tests
run: bun run test-ci

- name: 🥁 Generating coverage badges
uses: jpb06/coverage-badges-action@latest
53 changes: 53 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: ⚡ Publish

on:
workflow_run:
workflows: ['⚡ Coverage badges generation']
types:
- completed

jobs:
publish:
name: 🛩️ Publish
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1

- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 📦 Setup bun
uses: oven-sh/setup-bun@v1

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'
# cache: 'bun'
cache-dependency-path: ./package.json

- name: 📥 Install deps
run: bun install --frozen-lockfile

- name: ✏️ Bump package version
id: bumping-version
uses: jpb06/bump-package@latest
with:
major-keywords: BREAKING CHANGE
minor-keywords: feat,minor
patch-keywords: fix,chore
should-default-to-patch: true
commit-user: jpb06
commit-user-email: jpb.06@outlook.com

- name: ⚙️ Building package
run: bun run build

- name: 🚀 Publish package
if: steps.bumping-version.outputs.bump-performed == 'true'
run: npm publish ./dist --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

/temp
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# effect-github-stats

<!-- readme-package-icons start -->

<p align="left"><a href="https://docs.github.com/en/actions" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/GithubActions-Dark.svg" /></a>&nbsp;<a href="https://www.typescriptlang.org/docs/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/TypeScript.svg" /></a>&nbsp;<a href="https://nodejs.org/en/docs/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/NodeJS-Dark.svg" /></a>&nbsp;<a href="https://bun.sh/docs" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Bun-Dark.svg" /></a>&nbsp;<a href="https://github.com/motdotla/dotenv#readme" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Dotenv-Dark.svg" /></a>&nbsp;<a href="https://eslint.org/docs/latest/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Eslint-Dark.svg" /></a>&nbsp;<a href="https://prettier.io/docs/en/index.html" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Prettier-Dark.svg" /></a>&nbsp;<a href="https://vitest.dev/guide/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Vitest-Dark.svg" /></a>&nbsp;<a href="https://www.effect.website/docs/quickstart" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Effect-Dark.svg" /></a></p>

<!-- readme-package-icons end -->
Binary file added bun.lockb
Binary file not shown.
40 changes: 25 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"repository": "https://github.com/jpb06/github-stats.git",
"main": "index.js",
"name": "github-stats",
"repository": "https://github.com/jpb06/effect-github-stats.git",
"main": "dist/index.js",
"name": "effect-github-stats",
"version": "1.0.0",
"author": "jpb06 <jp.bois.06@outlook.fr>",
"description": "Getting user stats from github",
Expand All @@ -11,32 +11,42 @@
"node": "20.x"
},
"dependencies": {
"@octokit/core": "^5.1.0",
"chalk": "<5",
"effect": "^2.3.1",
"ts-pattern": "^5.0.6"
"@octokit/core": "^6.0.1",
"chalk": "^5",
"dotenv-flow": "^4.1.0",
"effect": "^2.4.6",
"effect-errors": "^1.2.8",
"ts-pattern": "^5.0.8"
},
"devDependencies": {
"@stylistic/eslint-plugin": "^1.6.1",
"@types/eslint": "^8.56.2",
"@types/node": "^20.11.17",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@stylistic/eslint-plugin": "^1.7.0",
"@types/eslint": "^8.56.5",
"@types/node": "^20.11.27",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitest/coverage-v8": "^1.3.1",
"del-cli": "^5.1.0",
"eslint": "^8.56.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vitest": "^0.3.26",
"prettier": "^3.2.5",
"readme-package-icons": "^1.1.10",
"typescript": "^5.3.3"
"readme-package-icons": "^1.1.14",
"typescript": "^5.4.2",
"vitest": "^1.3.1"
},
"scripts": {
"update-deps": "bunx npm-check-updates --root --format group -i",
"build": "del-cli ./dist && tsc --project tsconfig.prod.json",
"lint": "eslint ./src",
"type-check": "tsc --noEmit",
"test": "vitest",
"test-ci": "vitest --coverage --run",
"test-dev": "vitest --coverage",
"test-coverage": "vitest run --coverage",
"sync-icons": "pnpm generateReadmeIcons -h 50"
}
}
Loading

0 comments on commit 45a435a

Please sign in to comment.