Skip to content

Commit

Permalink
Merge pull request #2 from Avivbens/add-ci-cd
Browse files Browse the repository at this point in the history
feat: apply ci cd, fix lint and format. compile with common js
  • Loading branch information
Avivbens authored Jan 14, 2024
2 parents f66e2aa + 9706124 commit c313ce6
Show file tree
Hide file tree
Showing 19 changed files with 19,956 additions and 4,625 deletions.
11 changes: 11 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# don't ever lint node_modules
node_modules
# don't lint build output (make sure it's set to your correct build folder name)
dist
# don't lint nyc coverage output
coverage
# don't lint the packages
packages
# don't line the docs
docs
.eslintrc.js
38 changes: 38 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin', 'jest', 'prettier'],
extends: ['plugin:@typescript-eslint/recommended', 'eslint:recommended', 'plugin:prettier/recommended', 'prettier'],
root: true,
env: {
node: true,
jest: true,
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'no-unused-vars': 'off',
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
},
overrides: [
{
files: ['*.spec.js'],
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
'jest/prefer-expect-assertions': 0,
},
},
],
}
65 changes: 65 additions & 0 deletions .github/workflows/health-check/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: '☑️ Checks Pipeline'
description: 'Checks the codebase health'

inputs:
run-tests-command:
description: 'Run tests command, default is `npm test`'
default: 'npm test'
required: false

run-tests:
description: 'Run tests'
default: 'true'
required: false

run-lint-command:
description: 'Run linter command, default is `npm run lint`'
default: 'npm run lint'
required: false

run-lint:
description: 'Run lint'
default: 'true'
required: false

run-build-command:
description: 'Run build command, default is `npm run build`'
default: 'npm run build'
required: false

run-build:
description: 'Run build'
default: 'true'
required: false

runs:
using: composite
steps:
- name: 🖥️ Setup Node
uses: actions/setup-node@v3
with:
node-version: 16

- name: 🔗 Install Dependencies
shell: bash
run: |
npm ci --no-fund --no-audit --ignore-scripts --force
- name: 🧪 Test
if: ${{ inputs.run-tests == 'true' }}
shell: bash
run: |
${{ inputs.run-tests-command }}
- name: 🔨 Build
if: ${{ inputs.run-build == 'true' }}
shell: bash
run: |
${{ inputs.run-build-command }}
- name: ✅ Lint
if: ${{ inputs.run-lint == 'true' }}
shell: bash
run: |
${{ inputs.run-lint-command }}
22 changes: 22 additions & 0 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: PR Health Checks 🐛
on:
pull_request:
branches:
- master

jobs:
PR-checks:
# https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/using-self-hosted-runners-in-a-workflow
runs-on: ubuntu-latest
name: PR Health Checks 🐛
steps:
- name: 📀 Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: 🧪 Check out repository code
uses: ./.github/workflows/health-check
with:
run-tests: 'false'
82 changes: 82 additions & 0 deletions .github/workflows/release-master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: '📦 Create New Release'

on:
push:
branches:
- master

permissions: write-all

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

jobs:
checks:
name: ✅ Check for Release
runs-on: ubuntu-latest
timeout-minutes: 15

env:
HUSKY: 0

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: 🧪 Check out repository code
uses: ./.github/workflows/health-check

release:
name: 📦 Release Version
runs-on: ubuntu-latest
timeout-minutes: 60
needs:
- checks

env:
HUSKY: 0

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Git Config
run: |
git config --global user.name "github-bot"
git config --global user.email "github-bot@gmail.com"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Dependencies
run: |
npm ci --no-fund --no-audit --ignore-scripts --force
- name: Build
run: npm run build

- name: Setup NPM
run: |
npm config -L user set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
- name: Release
env:
# This is required to make semantic-release work with GitHub Actions
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# You can use this instead if no branch protection is enabled
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: github-bot
GIT_AUTHOR_EMAIL: github-bot@gmail.com
GIT_COMMITTER_NAME: github-bot
GIT_COMMITTER_EMAIL: github-bot@gmail.com
run: |
npx semantic-release
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
SECURITY.md
5 changes: 4 additions & 1 deletion .prettierrc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"singleQuote": true,
"trailingComma": "all",
"semi": false,
"printWidth": 120
"printWidth": 120,
"importOrder": ["^@.*/(.*)$", "^[./]"],
"importOrderSeparation": false,
"importOrderSortSpecifiers": true
}
41 changes: 41 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://json.schemastore.org/semantic-release.json",
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"master",
"next",
"next-major",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
],
"tagFormat": "v${version}",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Aviv Ben Shahar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] }
Loading

0 comments on commit c313ce6

Please sign in to comment.