Skip to content

Commit

Permalink
fix(practs): bump practs to latest best
Browse files Browse the repository at this point in the history
  • Loading branch information
uladkasach committed Sep 1, 2024
1 parent 5467f2a commit f03ced8
Show file tree
Hide file tree
Showing 27 changed files with 5,091 additions and 3,356 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = {
sourceType: 'module', // Allows for the use of imports
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off', // this can be figured out implicitly, and that is better
'@typescript-eslint/explicit-module-boundary-types': 'error', // makes code-reviews easier + code quality better by explicitly defining outputs of exported functions+classes
'@typescript-eslint/explicit-function-return-type': 'off', // prefer '@typescript-eslint/explicit-module-boundary-types' since it only requires the check on exported functions+classes
'sort-imports': 'off',
'import/prefer-default-export': 'off', // default export = bad
'import/no-default-export': 'error', // require named exports - they make it easier to refactor, enforce consistency, and increase constraints
Expand Down Expand Up @@ -42,5 +43,6 @@ module.exports = {
'@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',
'@typescript-eslint/no-unsafe-declaration-merging': 'off', // dobjs are built off of this
},
};
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# exclude package-lock from git diff; https://stackoverflow.com/a/72834452/3068233
package-lock.json -diff
46 changes: 46 additions & 0 deletions .github/workflows/.install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: .install

on:
workflow_call:
outputs:
node-modules-cache-key:
description: a max(stable) cache key to the node modules of this commit's dependencies
value: ${{ jobs.npm.outputs.node-modules-cache-key }}

jobs:
npm:
runs-on: ubuntu-20.04
outputs:
node-modules-cache-key: ${{ steps.cache.outputs.cache-primary-key }}
steps:
- name: checkout
uses: actions/checkout@v3

- name: set node-version
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: node-modules deps hash
id: deps-hash
run: |
PACKAGE_DEPS_HASH=$(jq '.packages' package-lock.json | jq 'del(."".version)' | md5sum | awk '{print $1}');
echo "PACKAGE_DEPS_HASH=$PACKAGE_DEPS_HASH"
echo "package-deps-hash=$PACKAGE_DEPS_HASH" >> "$GITHUB_OUTPUT"
- name: node-modules cache get
uses: actions/cache/restore@v4
id: cache
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ steps.deps-hash.outputs.package-deps-hash }}

- name: node-modules cache miss install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts --prefer-offline --no-audit

- name: node-modules cache set
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ./node_modules
key: ${{ steps.cache.outputs.cache-primary-key }}
11 changes: 7 additions & 4 deletions .github/workflows/.publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ on:
description: required credentials to authenticate with the aws account under which to publish

jobs:
install:
uses: ./.github/workflows/.install.yml

publish:
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -19,14 +23,13 @@ jobs:
with:
registry-url: 'https://registry.npmjs.org/'
node-version-file: '.nvmrc'
cache: 'npm'

- name: node-modules cache get
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
id: cache
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ needs.install.outputs.node-modules-cache-key }}

- name: node-modules cache miss install
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -36,6 +39,6 @@ jobs:
run: npm run build

- name: publish
run: npm publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-auth-token }}
83 changes: 25 additions & 58 deletions .github/workflows/.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,13 @@ on:
description: required credentials to authenticate with aws the aws account against which to run the tests

jobs:
# install the dependencies
install:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3

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

- name: node-modules cache get
uses: actions/cache/restore@v3
id: cache
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

- name: node-modules cache miss install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts --prefer-offline --no-audit

- name: node-modules cache set
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ./node_modules
key: ${{ steps.cache.outputs.cache-primary-key }}
uses: ./.github/workflows/.install.yml

# run tests in parallel
test-commits:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
Expand All @@ -64,19 +38,18 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: get node-modules from cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ needs.install.outputs.node-modules-cache-key }}

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

test-types:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
Expand All @@ -86,19 +59,18 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: get node-modules from cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ needs.install.outputs.node-modules-cache-key }}

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

test-format:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
Expand All @@ -108,19 +80,18 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: get node-modules from cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ needs.install.outputs.node-modules-cache-key }}

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

test-lint:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
Expand All @@ -130,19 +101,18 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: get node-modules from cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ needs.install.outputs.node-modules-cache-key }}

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

test-unit:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
Expand All @@ -152,19 +122,18 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: get node-modules from cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ needs.install.outputs.node-modules-cache-key }}

- name: test:unit
run: npm run test:unit
run: THOROUGH=true npm run test:unit

test-integration:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
Expand All @@ -174,13 +143,12 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: get node-modules from cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ needs.install.outputs.node-modules-cache-key }}

- name: configure aws credentials
if: "${{ inputs.aws-account-id != '' }}"
Expand All @@ -202,10 +170,10 @@ jobs:
run: npm run provision:integration-test-db --if-present

- name: test:integration
run: npm run test:integration
run: THOROUGH=true npm run test:integration

test-acceptance-locally:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
Expand All @@ -215,13 +183,12 @@ jobs:
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: get node-modules from cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ needs.install.outputs.node-modules-cache-key }}

- name: configure aws credentials
if: "${{ inputs.aws-account-id != '' }}"
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/publish-on-tag.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }} # per [workflow] x [branch, tag]
cancel-in-progress: true # cancel workflows for non-latest commits

jobs:
test:
uses: ./.github/workflows/.test.yml
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: review

on:
pull_request:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
pullreq-title:
runs-on: ubuntu-latest
steps:
- name: test:pullreq:title
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# https://github.com/commitizen/conventional-commit-types
types: |
fix
feat
chore
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
tags-ignore:
- v* # exclude tags, since deploy workflow triggers on tags, and calls the test workflow inside of it already

concurrency:
group: ${{ github.workflow }}-${{ github.ref }} # per [workflow] x [branch, tag]
cancel-in-progress: true # cancel workflows for non-latest commits

jobs:
suite:
uses: ./.github/workflows/.test.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.serverless
.terraform
.terraform.lock
.yalc
coverage
dist
node_modules
1 change: 1 addition & 0 deletions .husky/check.commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
Loading

0 comments on commit f03ced8

Please sign in to comment.