Skip to content

Commit

Permalink
feature: add some more configurations and dev tools
Browse files Browse the repository at this point in the history
  • Loading branch information
regevbr committed Mar 19, 2020
1 parent e6a116f commit 03d5008
Show file tree
Hide file tree
Showing 10 changed files with 1,532 additions and 40 deletions.
13 changes: 13 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
coverage:
status:
patch:
default:
target: 90%
project:
default:
target: auto
threshold: 2%
comment:
layout: diff, flags, files
require_changes: true

25 changes: 25 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": "0.1",
"language": "en",
"ignorePaths": [
"**/coverage/**",
"**/node_modules/**",
"**/dist/**",
"**/*.{json,snap}",
".cspell.json"
],
"dictionaries": [
"typescript",
"softwareTerms",
"node",
"en_US",
"npm",
"misc",
"filetypes"
],
"overrides": [
{
"filename": "**/*.{ts,js}",
}
]
}
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* text=auto
*.js eol=lf
*.json eol=lf
*.md eol=lf
*.ts eol=lf
*.tsx eol=lf
*.yml eol=lf
181 changes: 181 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- '**'

env:
PRIMARY_NODE_VERSION: 12

jobs:
primary_code_validation_and_tests:
name: Primary code validation and tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: echo github.ref
run: echo ${{ github.ref }}

- name: Use Node.js ${{ env.PRIMARY_NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.PRIMARY_NODE_VERSION }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# This also runs a build as part of the postinstall bootstrap
- name: Install dependencies and build
run: |
yarn --ignore-engines --frozen-lockfile
yarn check-clean-workspace-after-install
# Note that this command *also* type checks tests/tools,
# whereas the build only checks src files
- name: Typecheck all packages
run: yarn typecheck

- name: Check code formatting
run: yarn format-check

- name: Run linting
run: yarn lint

- name: Validate spelling
run: yarn check:spelling

- name: Run unit tests
run: yarn test
env:
CI: true

- name: Publish code coverage report
uses: codecov/codecov-action@v1
with:
yml: ./codecov.yml
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittest
name: codecov

integration_tests:
name: Run integration tests on primary Node.js version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.PRIMARY_NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.PRIMARY_NODE_VERSION }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# This also runs a build as part of the postinstall bootstrap
- name: Install dependencies and build
run: |
yarn --ignore-engines --frozen-lockfile
yarn check-clean-workspace-after-install
- name: Run integrations tests
run: yarn integration-tests
env:
CI: true

unit_tests_on_other_node_versions:
name: Run unit tests on other Node.js versions
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# This also runs a build as part of the postinstall bootstrap
- name: Install dependencies and build
run: |
yarn --ignore-engines --frozen-lockfile
yarn check-clean-workspace-after-install
- name: Run unit tests
run: yarn test
env:
CI: true

publish_canary_version:
name: Publish the latest code as a canary version
runs-on: ubuntu-latest
needs: [primary_code_validation_and_tests, unit_tests_on_other_node_versions, integration_tests]
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
# Fetch all history for all tags and branches in this job because lerna needs it
- run: |
git fetch --prune --unshallow
- name: Use Node.js ${{ env.PRIMARY_NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.PRIMARY_NODE_VERSION }}
registry-url: https://registry.npmjs.org/

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# This also runs a build as part of the postinstall bootstrap
- name: Install dependencies and build
run: |
yarn --ignore-engines --frozen-lockfile
yarn check-clean-workspace-after-install
- name: Publish all packages to npm
run: npx lerna publish --loglevel=verbose --canary --exact --force-publish --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
7 changes: 7 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"hooks": {
"pre-commit": "yarn run pre-commit",
"pre-push": "yarn run pre-push",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ pids
yarn.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

.cspell.json
# Coverage directory used by tools like istanbul
coverage

.gitattributes
# source files
CHANGELOG.md
src
Expand Down
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/dist
**/coverage
**/.nyc_output
.github
.all-contributorsrc
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "all"
}
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
"cover:unit": "yarn jest --coverage 'test/.*\\.spec\\.ts'",
"cover": "yarn jest --coverage 'test/.*\\.spec\\.ts' 'testE2E/.*\\.spec\\.ts'",
"lint": "yarn eslint . --ext .ts",
"lint:fix": "yarn eslint . --fix --ext .ts"
"lint:fix": "yarn eslint . --fix --ext .ts",
"pre-commit": "yarn lint-staged",
"pre-push": "yarn format-check",
"format-check": "prettier --list-different \"./**/*.{ts,js,json,md}\"",
"check:spelling": "cspell --config=.cspell.json \"**/*.{md,ts,js}\""
},
"author": "Regev Brody <regevbr@gmail.com>",
"files": [
Expand All @@ -41,6 +45,8 @@
],
"license": "ISC",
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@types/jest": "^25.1.4",
"@types/moment": "^2.13.0",
"@types/node": "^13.9.1",
Expand All @@ -50,11 +56,14 @@
"@types/yaml": "^1.2.0",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"cspell": "^4.0.55",
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prefer-arrow": "^1.1.7",
"jest": "^25.1.0",
"lint-staged": "^10.0.8",
"npm-check-updates": "^4.0.4",
"prettier": "^1.19.1",
"ts-jest": "^25.2.1",
"ts-node": "^8.7.0",
"typescript": "^3.8.3"
Expand All @@ -70,6 +79,11 @@
"typeorm": "^0.2.24",
"yaml": "^1.8.2"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"jest": {
"preset": "ts-jest",
"globals": {
Expand Down
Loading

0 comments on commit 03d5008

Please sign in to comment.