Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial setup #1

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
coverage/
dist/
79 changes: 79 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module",
"project": "./tsconfig.lint.json"
},
"ignorePatterns": ["node_modules"],
"plugins": ["@typescript-eslint", "vitest", "import"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:vitest/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
],
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "none",
"requireLast": false
},
"singleline": {
"delimiter": "comma",
"requireLast": false
}
}
],
"import/no-default-export": "error",
"import/order": [
"warn",
{
"alphabetize": { "order": "asc" },
"newlines-between": "always"
}
],
"object-shorthand": ["error", "always"],
"max-lines": ["error", { "max": 600 }],
"max-params": ["error", { "max": 4 }],
"max-statements": ["error", { "max": 15 }],
"complexity": ["error", { "max": 20 }]
},
"overrides": [
{
"files": ["*.test.ts", "*.spec.ts"],
"rules": {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-explicit-any": "off",
"max-statements": ["off"]
}
}
]
}
34 changes: 34 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'monthly'
open-pull-requests-limit: 10
labels:
- 'skip-release'

- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
open-pull-requests-limit: 10
groups:
lint:
patterns:
- '@typescript-eslint/*'
- 'eslint'
- 'eslint-*'
- 'prettier'
- 'jest-fail-on-console'
testing:
patterns:
- 'vitest'
- '@vitest/*'
- 'mockttp'
typescript:
patterns:
- '@types/*'
- 'ts-node'
- 'ts-node-dev'
- 'typescript'
9 changes: 9 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Changes

Please describe

## Checklist

- [ ] Apply one of following labels; `major`, `minor`, `patch` or `skip-release`
- [ ] I've updated the documentation, or no changes were necessary
- [ ] I've updated the tests, or no changes were necessary
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ci

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
npm install

- name: Build TS
run: |
npm run build

- name: Run Tests
run: |
npm run test
25 changes: 25 additions & 0 deletions .github/workflows/ensure-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Workflow to ensure pull request has proper labels
name: Ensure labels

on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review
- labeled
- unlabeled

jobs:
ensure_labels:
name: Ensure PR has proper labeling
runs-on: ubuntu-latest
steps:
- name: Check on of required labels are set
uses: docker://agilepathway/pull-request-label-checker:v1.1.2
with:
one_of: major,minor,patch,skip-release # Must have exactly-one of these labels
repo_token: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: linting

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
name: linting

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

- name: Setup Node.js
uses: actions/setup-node@v4
with:
always-auth: false
node-version: 20.x

- name: Run npm install
run: npm install

- name: Run lint
run: npm run lint
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Workflow for releasing package to npm registry
name: Release to NPM
on:
pull_request:
types:
- closed # Only run after PRs have been merged or closed
branches:
- main # Only run for PRs targeted against main branch

jobs:
release:
# Only run for pull requests that has been merged (not closed) and that doesn't have `skip-release` label
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'skip-release') == false
name: release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0 # fetch all commits so auto-changelog is correctly generating
token: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
scope: '@lokalise'
always-auth: true
registry-url: 'https://registry.npmjs.org'

- name: Install Dependencies
run: npm install

- name: Build Package
run: npm run build

- name: Setup git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "AUTO RELEASE"

# Apply proper semver according to github labels

- name: Major label detected
if: contains(github.event.pull_request.labels.*.name, 'major')
run: npm version major

- name: Minor label detected
if: contains(github.event.pull_request.labels.*.name, 'minor')
run: npm version minor

- name: Patch label detected
if: contains(github.event.pull_request.labels.*.name, 'patch')
run: npm version patch

- name: Git push
run: git push origin main && git push --tags

- name: Release Package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish
Loading
Loading