Skip to content

Commit

Permalink
fix(practs): upgrade to latest best
Browse files Browse the repository at this point in the history
  • Loading branch information
uladkasach committed May 26, 2024
1 parent 4b31074 commit a57a7a3
Show file tree
Hide file tree
Showing 31 changed files with 1,806 additions and 2,541 deletions.
1 change: 1 addition & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ ignores:
- '@types/yesql'
- 'yesql'
- sql-schema-control # used in a shelljs to provision the schema generated by dao, for use in testing
- ts-node
3 changes: 2 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': 'warn', // 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
40 changes: 40 additions & 0 deletions .github/workflows/.publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: .publish-npm

on:
workflow_call:
secrets:
npm-auth-token:
required: true
description: required credentials to authenticate with the aws account under which to publish

jobs:
publish:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v3

- name: set node-version
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org/'
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: build
run: npm run build

- name: publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-auth-token }}
238 changes: 238 additions & 0 deletions .github/workflows/.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
name: .test

on:
workflow_call:
inputs:
aws-region:
type: string
description: the aws region within which we should run the tests
required: false
aws-account-id:
type: string
description: the id of the account the credentials are expected to access
required: false
secrets:
aws-access-key-id:
required: false
description: required credentials to authenticate with aws the aws account against which to run the tests
aws-secret-access-key:
required: false
description: required credentials to authenticate with aws the aws account against which to run the tests

jobs:
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 }}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

- name: configure aws credentials
if: "${{ inputs.aws-account-id != '' }}"
uses: aws-actions/configure-aws-credentials@v1
id: credentials
with:
aws-access-key-id: ${{ secrets.aws-access-key-id }}
aws-secret-access-key: ${{ secrets.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}

- name: confirm aws credentials
if: "${{ inputs.aws-account-id != '' }}"
run: |
[[ ${{steps.credentials.outputs.aws-account-id}} != ${{ inputs.aws-account-id }} ]] \
&& echo 'wrong aws account' && exit 1 \
|| echo 'correct aws account';
- name: provision:integration-test-db
run: npm run provision:integration-test-db --if-present

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

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

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

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

- name: configure aws credentials
if: "${{ inputs.aws-account-id != '' }}"
uses: aws-actions/configure-aws-credentials@v1
id: credentials
with:
aws-access-key-id: ${{ secrets.aws-access-key-id }}
aws-secret-access-key: ${{ secrets.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}

- name: confirm aws credentials
if: "${{ inputs.aws-account-id != '' }}"
run: |
[[ ${{steps.credentials.outputs.aws-account-id}} != ${{ inputs.aws-account-id }} ]] \
&& echo 'wrong aws account' && exit 1 \
|| echo 'correct aws account';
- name: provision:integration-test-db
run: npm run provision:integration-test-db --if-present

- name: test:acceptance:locally
run: npm run test:acceptance:locally
42 changes: 0 additions & 42 deletions .github/workflows/publish-on-tag.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: publish

on:
push:
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

publish:
uses: ./.github/workflows/.publish-npm.yml
needs: [test]
secrets:
npm-auth-token: ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pr-release-on-main
name: release

on:
push:
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
Loading

0 comments on commit a57a7a3

Please sign in to comment.