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 Jul 27, 2024
1 parent 65dc860 commit f9e8c03
Show file tree
Hide file tree
Showing 12 changed files with 1,766 additions and 1,683 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,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 }}
8 changes: 6 additions & 2 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 @@ -21,11 +25,11 @@ jobs:
node-version-file: '.nvmrc'

- 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 Down
71 changes: 23 additions & 48 deletions .github/workflows/.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +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'

- 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 @@ -65,16 +40,16 @@ jobs:
node-version-file: '.nvmrc'

- 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,16 +61,16 @@ jobs:
node-version-file: '.nvmrc'

- 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 @@ -107,16 +82,16 @@ jobs:
node-version-file: '.nvmrc'

- 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 @@ -128,16 +103,16 @@ jobs:
node-version-file: '.nvmrc'

- 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 @@ -149,16 +124,16 @@ jobs:
node-version-file: '.nvmrc'

- 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: THOROUGH=true npm run test:unit

test-integration:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: [install]
steps:
- name: checkout
Expand All @@ -170,10 +145,10 @@ jobs:
node-version-file: '.nvmrc'

- 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 @@ -198,7 +173,7 @@ jobs:
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 @@ -210,10 +185,10 @@ jobs:
node-version-file: '.nvmrc'

- 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
4 changes: 4 additions & 0 deletions .husky/check.nvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# if exists a .nvmrc, then `nvm use`, to use the specified version
[[ -f ".nvmrc" ]] && nvm use
1 change: 1 addition & 0 deletions .husky/post-rewrite
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"

. "$(dirname -- "$0")/check.nvm.sh"
. "$(dirname -- "$0")/check.lockfile.sh"
3 changes: 3 additions & 0 deletions jest.acceptance.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import type { Config } from 'jest';
// ensure tests run in utc, like they will on cicd and on server; https://stackoverflow.com/a/56277249/15593329
process.env.TZ = 'UTC';

// ensure tests run like on local machines, so snapshots are equal on local && cicd
process.env.FORCE_COLOR = 'true';

// https://jestjs.io/docs/configuration
const config: Config = {
verbose: true,
Expand Down
3 changes: 3 additions & 0 deletions jest.integration.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import type { Config } from 'jest';
// ensure tests run in utc, like they will on cicd and on server; https://stackoverflow.com/a/56277249/15593329
process.env.TZ = 'UTC';

// ensure tests run like on local machines, so snapshots are equal on local && cicd
process.env.FORCE_COLOR = 'true';

// https://jestjs.io/docs/configuration
const config: Config = {
verbose: true,
Expand Down
3 changes: 3 additions & 0 deletions jest.unit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import type { Config } from 'jest';
// ensure tests run in utc, like they will on cicd and on server; https://stackoverflow.com/a/56277249/15593329
process.env.TZ = 'UTC';

// ensure tests run like on local machines, so snapshots are equal on local && cicd
process.env.FORCE_COLOR = 'true';

// https://jestjs.io/docs/configuration
const config: Config = {
verbose: true,
Expand Down
Loading

0 comments on commit f9e8c03

Please sign in to comment.