Skip to content

Commit

Permalink
fix(practs): upgrade to latest declapract-typescript-ehmpathy best pr…
Browse files Browse the repository at this point in the history
…actices
  • Loading branch information
uladkasach committed Feb 23, 2023
1 parent 45a88fc commit 752750a
Show file tree
Hide file tree
Showing 34 changed files with 28,162 additions and 5,546 deletions.
12 changes: 12 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ignores:
- depcheck
- declapract
- declapract-typescript-ehmpathy
- '@commitlint/config-conventional'
- '@trivago/prettier-plugin-sort-imports'
- '@tsconfig/node-lts-strictest'
- core-js
- ts-jest
- ts-node
- date-fns
- husky
21 changes: 18 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:import/recommended', // specifies good import rules
'airbnb-typescript/base', // uses the airbnb recommended rules
'prettier/@typescript-eslint', // disables ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
Expand All @@ -20,12 +20,27 @@ module.exports = {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/*.test.ts', '**/*.test.integration.ts', '**/*.test.acceptance.ts', 'acceptance/**/*.ts'],
devDependencies: [
'**/*.test.ts',
'**/*.test.integration.ts',
'**/*.test.acceptance.ts',
'acceptance/**/*.ts',
'**/__test_utils__/**/*.ts',
'provision/**/*.ts',
],
},
],
'@typescript-eslint/no-explicit-any': 'off', // sometimes this is a valid definition
'@typescript-eslint/no-unused-vars': ['warn', { varsIgnorePattern: '^_' }],
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'import/no-cycle': 'off',
'max-classes-per-file': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'prefer-destructuring': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': 'off',
'no-return-await': 'off', // this does not help anything and actually leads to bugs if we subsequently wrap the return in a try catch without remembering to _then_ add await
'@typescript-eslint/return-await': 'off',
},
};
17 changes: 17 additions & 0 deletions .github/workflows/pr-release-on-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: pr-release-on-main

on:
push:
branches:
- main

jobs:
release-please:
runs-on: ubuntu-20.04
steps:
- uses: google-github-actions/release-please-action@v3
with:
token: ${{ secrets.RELEASE_PLEASE_GITHUB_TOKEN }}
release-type: node
pull-request-title-pattern: 'chore(release): v${version} 🎉'
changelog-path: changelog.md
39 changes: 39 additions & 0 deletions .github/workflows/publish-on-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: deploy_on_tag

on:
push:
tags:
- v*

jobs:
test_and_deploy:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # we need all commits to test:commits

- name: read nvmrc
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: setup node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
cache: 'npm'

- name: install
run: npm ci

- name: tests
run: npm run test
env:
FORCE_COLOR: true # ensure colors are saved in jest snapshots, to be consistent with local development

- name: publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
229 changes: 229 additions & 0 deletions .github/workflows/test-on-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
name: test-on-commit

on:
push:
branches: # run for any branch
- '**'
tags-ignore: # but not for releases, as deploy_on_tag will trigger for it
- '**'

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

jobs:
install:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2

- name: read nvmrc
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: setup node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
cache: 'npm'

- name: install
run: npm ci

- name: cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ github.sha }}

# run tests in parallel
test-commits:
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # we need all commits to test:commits

- name: read nvmrc
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: setup node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
cache: 'npm'

- name: grab node_modules from cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ github.sha }}

- name: test:commits
run: npm run test:commits

test-types:
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
uses: actions/checkout@v2

- name: read nvmrc
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: setup node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
cache: 'npm'

- name: grab node_modules from cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ github.sha }}

- name: test:types
run: npm run test:types

test-format:
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
uses: actions/checkout@v2

- name: read nvmrc
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: setup node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
cache: 'npm'

- name: grab node_modules from cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ github.sha }}

- name: test:format
run: npm run test:format

test-lint:
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
uses: actions/checkout@v2

- name: read nvmrc
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: setup node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
cache: 'npm'

- name: grab node_modules from cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ github.sha }}

- name: test:lint
run: npm run test:lint

test-unit:
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
uses: actions/checkout@v2

- name: read nvmrc
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: setup node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
cache: 'npm'

- name: grab node_modules from cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ github.sha }}

- name: test:unit
run: npm run test:unit
env:
FORCE_COLOR: true # ensure colors are saved in jest snapshots, to be consistent with local development

test-integration:
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
uses: actions/checkout@v2

- name: read nvmrc
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: setup node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
cache: 'npm'

- name: grab node_modules from cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ github.sha }}

- name: test:integration
run: npm run test:integration
env:
FORCE_COLOR: true # ensure colors are saved in jest snapshots, to be consistent with local development

test-acceptance-locally:
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
uses: actions/checkout@v2

- name: read nvmrc
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: setup node
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}
cache: 'npm'

- name: grab node_modules from cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ github.sha }}

- name: test:acceptance:locally
run: npm run test:acceptance:locally
env:
FORCE_COLOR: true # ensure colors are saved in jest snapshots, to be consistent with local development
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.artifact
.env
.serverless
.terraform
.terraform.lock
coverage
dist
node_modules
coverage
.serverless
.env
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-install commitlint --edit "$1"
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md
4 changes: 4 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: { 'header-max-length': [1, 'always', 140] },
};
6 changes: 6 additions & 0 deletions declapract.use.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# declapract.use.yml
declarations: npm:declapract-typescript-ehmpathy
useCase: npm-package # specify which use case your repo is following, see `declapract-typescript-ehmpathy:src/useCases.yml` for options
variables: # specify the values of the variables to use against checks
organizationName: 'whodis'
projectName: 'simple-hmackey-auth'
17 changes: 17 additions & 0 deletions jest.acceptance.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Config } from 'jest';

// https://jestjs.io/docs/configuration
const config: Config = {
verbose: true,
testEnvironment: 'node',
moduleFileExtensions: ['js', 'ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest', // https://kulshekhar.github.io/ts-jest/docs/getting-started/presets
},
testMatch: ['**/*.acceptance.test.ts'],
setupFiles: ['core-js'],
setupFilesAfterEnv: ['./jest.acceptance.env.ts'],
};

// eslint-disable-next-line import/no-default-export
export default config;
1 change: 1 addition & 0 deletions jest.integration.env.js → jest.acceptance.env.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// eslint-disable-next-line no-undef
jest.setTimeout(90000); // we're calling downstream apis
1 change: 0 additions & 1 deletion jest.config.js

This file was deleted.

Loading

0 comments on commit 752750a

Please sign in to comment.