Skip to content

Commit

Permalink
CI setup (#1)
Browse files Browse the repository at this point in the history
* Add logo

* Add API details

* Add linting

* Add config for debug toggle

* Add formatting

* Add CI workflow

* Fix indent

* Pass prop as with value

* Add release workflow

* Add install

* Formatting

* Add a test

* Add path

* Add declaration build

* Use contains function
  • Loading branch information
simmo committed Mar 20, 2023
1 parent 73d3817 commit 60667e1
Show file tree
Hide file tree
Showing 24 changed files with 698 additions and 33 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
indent_style = tab
insert_final_newline = true

[{*.yml,package.json,package-lock.json}]
indent_style = space
indent_size = 2
46 changes: 38 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"]
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "import"],
"rules": {
"newline-after-var": ["error", "always"],
"sort-imports": [
"error",
{
"allowSeparatedGroups": true,
"ignoreCase": true,
"ignoreDeclarationSort": true
}
],
"import/order": [
"error",
{
"groups": [
"builtin",
"index",
"external",
"internal",
"parent",
"sibling"
],
"pathGroupsExcludedImportTypes": ["builtin"],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
]
}
}
1 change: 1 addition & 0 deletions .github/assets/logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .github/assets/logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: CI

on:
workflow_dispatch:
inputs:
release:
default: prerelease
description: 'Type'
options:
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major
required: true
type: choice
pull_request:
push:
branches: main

jobs:
validate:
name: Validate
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
id: setup
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install
run: npm ci

- name: Lint
run: npm run lint

- name: Format
run: npm run format

- name: Test
run: npm test

build:
name: Build
runs-on: ubuntu-latest
needs: validate
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
id: setup
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install
run: npm ci

- name: Build
run: npm run build

- name: Upload
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
retention-days: 1

release:
name: Release
runs-on: ubuntu-latest
needs: build
timeout-minutes: 5
if: github.ref_name == 'main'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
id: setup
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Configure Git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Configure NPM
run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}

- name: Install
run: npm ci

- name: Download
uses: actions/download-artifact@v3
with:
name: dist

- name: Beta Release
if: (!inputs.release) || contains(fromJSON('["premajor", "preminor", "prepatch", "prerelease"]'), inputs.release)
run: npm run release -- ${{ inputs.release || 'prerelease' }} --ci --preRelease=beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Release
if: inputs.release && contains(fromJSON('["major", "minor", "patch"]'), inputs.release)
run: npm run release -- ${{ inputs.release }} --ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/**/*
26 changes: 17 additions & 9 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"editorconfig": true,
"singleQuote": true,
"trailingComma": "es5",
"semi": true,
"useTabs": true
}
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"singleQuote": true,
"trailingComma": "es5",
"semi": true,
"useTabs": true,
"overrides": [
{
"files": ["*.yml", "package.json", "package-lock.json"],
"options": {
"tabWidth": 2,
"useTabs": false
}
}
]
}
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"streetsidesoftware.code-spell-checker"
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"cSpell.words": ["jinju"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.preferences.importModuleSpecifierEnding": "js"
}
Loading

0 comments on commit 60667e1

Please sign in to comment.