Skip to content

Commit

Permalink
chore: setup config files
Browse files Browse the repository at this point in the history
  • Loading branch information
imranbarbhuiya committed May 27, 2023
1 parent 5023cff commit 1cd54c0
Show file tree
Hide file tree
Showing 38 changed files with 3,162 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"root": true,
"extends": ["mahir/common", "mahir/node", "mahir/typescript", "mahir/prettier"],
"extends": ["mahir/common", "mahir/node", "mahir/typescript", "mahir/prettier", "mahir/tsdoc"],
"ignorePatterns": ["dist"],
"parserOptions": {
"project": ["./tsconfig.eslint.json", "./packages/*/tsconfig.eslint.json"]
Expand Down
1 change: 1 addition & 0 deletions .github/husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .github/husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
4 changes: 4 additions & 0 deletions .github/husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
7 changes: 7 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package:fanbook.js:
- packages/fanbook.js/*
- packages/fanbook.js/**/*

package:rest:
- packages/rest/*
- packages/rest/**/*
64 changes: 64 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
- name: blocked
color: 'fc1423'
- name: bug:confirmed
color: 'd73a4a'
- name: bug:unverified
color: 'f9d0c4'
- name: chore
color: 'ffffff'
- name: ci
color: '0075ca'
- name: dependencies
color: '276bd1'
- name: discussion
color: 'b6b1f9'
- name: documentation
color: '0075ca'
- name: duplicate
color: 'cfd3d7'
- name: error handling
color: 'ffff00'
- name: feature
color: 'ffff00'
- name: hacktoberfest-accepted
color: 'EE4700'
- name: has PR
color: '4b1f8e'
- name: help wanted
color: '008672'
- name: in progress
color: 'ffccd7'
- name: in review
color: 'aed5fc'
- name: invalid
color: 'e4e669'
- name: need repro
color: 'c66037'
- name: needs rebase & merge
color: '24853c'
- name: performance
color: '80c042'
- name: priority:critical
color: 'b60205'
- name: priority:high
color: 'fc1423'
- name: refactor
color: '1d637f'
- name: regression
color: 'ea8785'
- name: semver:major
color: 'c10f47'
- name: semver:minor
color: 'e4f486'
- name: semver:patch
color: 'e8be8b'
- name: tests
color: 'f06dff'
- name: typings
color: '80c042'
- name: wontfix
color: 'ffffff'
- name: 'package:fanbook.js'
color: '7f00ff'
- name: 'package:rest'
color: '7f00ff'
22 changes: 22 additions & 0 deletions .github/problemMatchers/eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"problemMatcher": [
{
"owner": "eslint-stylish",
"pattern": [
{
"regexp": "^([^\\s].*)$",
"file": 1
},
{
"regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$",
"line": 1,
"column": 2,
"severity": 3,
"message": 4,
"code": 5,
"loop": true
}
]
}
]
}
17 changes: 17 additions & 0 deletions .github/problemMatchers/tsc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "tsc",
"pattern": [
{
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"location": 2,
"severity": 3,
"code": 4,
"message": 5
}
]
}
]
}
26 changes: 26 additions & 0 deletions .github/workflows/auto-deprecate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: NPM Auto Deprecate

on:
schedule:
- cron: '0 0 * * *'

jobs:
auto-deprecate:
name: NPM Auto Deprecate
if: github.repository_owner == 'fanbookjs'
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Use Node.js v18
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 18
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
uses: ./.github/yarnCache
- name: Deprecate versions
run: yarn npm-deprecate
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Code Scanning

on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '30 1 * * 0'

jobs:
CodeQL:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3

- name: Initialize CodeQL
uses: github/codeql-action/init@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # v2

- name: Autobuild
uses: github/codeql-action/autobuild@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # v2
63 changes: 63 additions & 0 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Continuous Delivery

on:
workflow_dispatch:
inputs:
prNumber:
description: The number of the PR that is being deployed
required: true
ref:
description: The branch that is being deployed. Should be a branch on the given repository
required: false
default: main
repository:
description: The {owner}/{repository} that is being deployed.
required: false
default: fanbookjs/fanbook.js
push:
branches:
- main

jobs:
Publish:
name: Publish Canary to npm
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.repository_owner == 'fanbookjs'
steps:
- name: Checkout Project
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
repository: ${{ github.event.inputs.repository || 'fanbookjs/fanbook.js' }}
ref: ${{ github.event.inputs.ref || 'main' }}
- name: Add TypeScript problem matcher
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js v18
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 18
cache: yarn
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
uses: ./.github/yarnCache
- name: Build all packages
run: yarn build
- name: Bump Versions & Publish
run: |
if [[ -z "${NODE_AUTH_TOKEN}" ]]; then
echo "NODE_AUTH_TOKEN is not set, skipping publish"
exit 0
fi
TAG=$([[ ${{ github.event_name }} == 'push' ]] && echo 'canary' || echo 'pr-${{ github.event.inputs.prNumber }}')
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://registry.yarnpkg.com"
for d in packages/*; do
pushd $d
yarn bump --preid "${TAG}.$(git rev-parse --verify --short HEAD)"
yarn npm publish --tag ${TAG}
popd
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
84 changes: 84 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Continuous Integration

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
Linting:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/eslint.json"
- name: Use Node.js v18
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 18
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
uses: ./.github/yarnCache
- name: Run ESLint
run: yarn lint -- --fix=false

Building:
name: Compile source code
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js v18
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 18
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
uses: ./.github/yarnCache
- name: Compile Projects
run: yarn build
- name: Upload fanbook dist folders to artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3
with:
name: dist
path: packages/fanbook.js/dist/
if-no-files-found: error

Testing:
name: Unit Tests
runs-on: ubuntu-latest
needs: Building
steps:
- name: Checkout Project
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Download fanbook.js dist folder from artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
with:
name: dist
path: packages/fanbook.js/dist/
- name: Use Node.js v18
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 18
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
uses: ./.github/yarnCache

- name: Run tests
run: yarn test

- name: Upload Coverage
if: github.repository_owner == 'fanbookjs'
uses: ./scripts/uploadCoverage
27 changes: 27 additions & 0 deletions .github/workflows/deprecate-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: NPM Deprecate PR versions On Merge

on:
pull_request:
types:
- closed

jobs:
deprecate-on-merge:
name: NPM Deprecate PR versions On Merge
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Use Node.js v18
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: 18
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
uses: ./.github/yarnCache
- name: Deprecate versions
run: yarn npm-deprecate --name "*pr-${PR_NUMBER}*" -d -v
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
19 changes: 19 additions & 0 deletions .github/workflows/labelsync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Automatic Label Sync

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
label_sync:
name: Automatic Label Synchronization
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Run Label Sync
uses: crazy-max/ghaction-github-labeler@3de87da19416edc45c90cd89e7a4ea922a3aae5a # tag=v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
Loading

0 comments on commit 1cd54c0

Please sign in to comment.