Skip to content

Commit 8a5cca9

Browse files
authored
Merge pull request #101 from klerick/split-json-api-package
Split package in json-api-nestjs
2 parents 550c663 + 5ecb11e commit 8a5cca9

File tree

403 files changed

+16204
-16906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

403 files changed

+16204
-16906
lines changed

.env

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
DB_HOST=localhost
22
DB_LOGGING=1
3+
DB_NAME="json-api-db"
34

45
DB_USERNAME="postgres"
56
DB_PASSWORD="postgres"
6-
#DB_NAME="json-api-db"
7-
DB_NAME="postgres"
87
DB_PORT=5432
98
DB_TYPE=postgres
109

1110
#DB_USERNAME="root"
12-
#DB_PASSWORD="password"
13-
#DB_NAME="example_new"
11+
#DB_PASSWORD="mysql"
1412
#DB_PORT=3306
1513
#DB_TYPE=mysql
1614

1715

18-
ORM_TYPE=microorm
19-
#ORM_TYPE=typeorm
16+
#ORM_TYPE=microorm
17+
ORM_TYPE=typeorm

.eslintrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
]
2020
}
2121
},
22+
{
23+
"files": ["*.test-d.ts"],
24+
"rules": {
25+
"@typescript-eslint/ban-ts-comment": "off"
26+
}
27+
},
2228
{
2329
"files": ["*.ts", "*.tsx"],
2430
"rules": {}

.github/actions/action.yml

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
name: 'My composite action'
2-
description: 'Checks out the repository and install'
1+
name: Main action for Node.js
2+
description: Setup Node.js
3+
4+
inputs:
5+
node-version:
6+
description: Node.js version
7+
required: false
8+
default: 20.x
9+
310
runs:
4-
using: 'composite'
11+
using: composite
512
steps:
6-
- name: Setup Node.js
7-
uses: actions/setup-node@v4
13+
- name: Use Node.js ${{ inputs.node-version }}
14+
uses: actions/setup-node@v3
815
with:
9-
node-version: 20
16+
node-version: ${{ inputs.node-version }}
1017
registry-url: 'https://registry.npmjs.org'
11-
- name: Restore cached npm dependencies
12-
id: cache-dependencies-restore
13-
uses: actions/cache/restore@v4
18+
cache: npm
19+
20+
- name: Get npm cache directory
21+
id: npm-cache-dir
22+
shell: pwsh
23+
run: echo "dir=$(npm config get cache)" >> ${env:GITHUB_OUTPUT}
24+
25+
- name: Cache NPM dependencies
26+
uses: actions/cache@v4
27+
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
1428
with:
15-
path: |
16-
node_modules
17-
~/.cache/Cypress # needed for the Cypress binary
18-
key: ${{ runner.os }}-npm-dependencies-${{ hashFiles('package-lock.json') }}
19-
- name: Npm install
20-
if: steps.cache-dependencies-restore.outputs.cache-hit != 'true'
21-
run: npm ci
29+
path: ${{ steps.npm-cache-dir.outputs.dir }}
30+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
31+
restore-keys: |
32+
${{ runner.os }}-node-
33+
34+
- name: Install Dependencies
2235
shell: bash
23-
- name: Cache npm dependencies
24-
id: cache-dependencies-save
25-
uses: actions/cache/save@v4
26-
with:
27-
path: |
28-
node_modules
29-
~/.cache/Cypress # needed for the Cypress binary
30-
key: ${{ steps.cache-dependencies-restore.outputs.cache-primary-key }}
31-
- name: Derive appropriate SHAs for base and head for `nx affected` commands
32-
uses: nrwl/nx-set-shas@v4
33-
with:
34-
main-branch-name: "master"
36+
run: npm ci

.github/workflows/build.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: ⚙️ Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
mainBranch:
7+
description: Type for main nx affect
8+
required: false
9+
default: "master"
10+
type: string
11+
secrets:
12+
NX_CLOUD_ACCESS_TOKEN:
13+
required: true
14+
env:
15+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
26+
uses: nrwl/nx-set-shas@v4
27+
with:
28+
main-branch-name: "master"
29+
30+
- name: Setup Node.js
31+
uses: ./.github/actions
32+
33+
- name: Determine base for NX affected (if not master)
34+
if: ${{ inputs.mainBranch != 'master' }}
35+
shell: bash
36+
run: |
37+
LAST_TAG=$(git describe --tags --abbrev=0)
38+
LAST_TAG_HASH=$(git rev-parse "$LAST_TAG")
39+
CURRENT_COMMIT=$(git rev-parse HEAD)
40+
echo "Using last tag hash as NX_BASE: $LAST_TAG_HASH"
41+
echo "Using current commit as NX_HEAD: $CURRENT_COMMIT"
42+
echo "NX_BASE=$LAST_TAG_HASH" >> $GITHUB_ENV
43+
echo "NX_HEAD=$CURRENT_COMMIT" >> $GITHUB_ENV
44+
45+
- name: Determine base for NX affected (if master)
46+
if: ${{ inputs.mainBranch == 'master' }}
47+
uses: nrwl/nx-set-shas@v4
48+
with:
49+
main-branch-name: ${{ inputs.mainBranch }}
50+
51+
- name: Build Libraries
52+
run: npx nx affected --target=build --parallel=3 --exclude='*,!tag:type:publish'

.github/workflows/ci.yml renamed to .github/workflows/bump-version-save.yml

Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
1-
name: CI
1+
name: Create Releases
22
on:
3-
pull_request:
4-
branches:
5-
- master
6-
types:
7-
- opened
8-
- synchronize
3+
workflow_dispatch:
4+
inputs:
5+
projects:
6+
description: 'Package Bump'
7+
required: true
8+
default: 'json-api-nestjs,json-api-nestjs-sdk,nestjs-json-rpc,nestjs-json-rpc-sdk'
9+
first-release:
10+
description: 'Is first release?'
11+
required: false
12+
type: boolean
13+
default: false
14+
dry-run:
15+
description: 'Is dry run?'
16+
required: false
17+
type: boolean
18+
default: false
919
jobs:
10-
run-test:
11-
name: Try build and run unit test
20+
build-and-test:
21+
name: "Build and test"
1222
runs-on: ubuntu-latest
23+
permissions:
24+
contents: "read"
25+
actions: "read"
1326
steps:
1427
- uses: actions/checkout@v4
1528
with:
1629
fetch-depth: 0
1730
- name: Npm install
1831
uses: ./.github/actions
19-
- name: Get branch names.
20-
id: branch-names
21-
uses: tj-actions/branch-names@v8
32+
- name: Get git hash
33+
run: |
34+
COMMIT=$(git show-ref --tags --hash | tail -n 1)
35+
echo "NX_BASE=$(echo ${COMMIT})" >> $GITHUB_ENV
36+
- name: Set GIST_SECRET to env
37+
run: |
38+
echo "GIST_SECRET=${{ secrets.GIST_SECRET }}" >> $GITHUB_ENV
39+
echo "GIST_ID=${{ secrets.GIST_ID }}" >> $GITHUB_ENV
2240
- name: Restore cached .nx
2341
id: cache-nx-restore
2442
uses: actions/cache/restore@v4
2543
with:
2644
path: |
2745
.nx
28-
key: ${{ runner.os }}-nx-${{ steps.branch-names.outputs.current_branch }}
29-
- run: git branch --track main origin/master
46+
key: ${{ runner.os }}-nx-master
3047
- name: Test
3148
env:
3249
NX_REJECT_UNKNOWN_LOCAL_CACHE: 0
@@ -35,6 +52,8 @@ jobs:
3552
env:
3653
NX_REJECT_UNKNOWN_LOCAL_CACHE: 0
3754
run: npx nx affected -t build --exclude='json-api-front,json-api-server,json-api-server-e2e,json-shared-type,microorm-database,typeorm-database,@nestjs-json-api/source,type-for-rpc'
55+
- name: Upload test coverage badge
56+
run: npx nx affected -t upload-badge --exclude='json-api-front,json-api-server,shared-utils,json-api-server-e2e,json-shared-type,microorm-database,typeorm-database,@nestjs-json-api/source,type-for-rpc'
3857
- name: Save cached .nx
3958
id: cache-dependencies-save
4059
uses: actions/cache/save@v4
@@ -46,7 +65,7 @@ jobs:
4665
runs-on: ubuntu-latest
4766
name: Try run e2e test
4867
needs:
49-
- run-test
68+
- build-and-test
5069
services:
5170
# Label used to access the service container
5271
postgres:
@@ -71,25 +90,49 @@ jobs:
7190
fetch-depth: 0
7291
- name: Npm install
7392
uses: ./.github/actions
74-
- name: Get branch names.
75-
id: branch-names
76-
uses: tj-actions/branch-names@v8
7793
- name: Restore cached .nx
7894
id: cache-nx-restore
7995
uses: actions/cache/restore@v4
8096
with:
8197
path: |
8298
.nx
83-
key: ${{ runner.os }}-nx-${{ steps.branch-names.outputs.current_branch }}
99+
key: ${{ runner.os }}-nx-master
84100
- run: git branch --track main origin/master
85101
- run: npm run typeorm migration:run
86102
- run: npm run seed:run
87103
- run: npx nx affected -t e2e --parallel=1
88-
- run: npx nx affected -t e2e-micro --parallel=1
89104
- name: Save cached .nx
90105
id: cache-dependencies-save
91106
uses: actions/cache/save@v4
92107
with:
93108
path: |
94109
.nx
95110
key: ${{ steps.cache-nx-restore.outputs.cache-primary-key }}
111+
bump-version:
112+
name: "Bump version"
113+
needs:
114+
- run-e2e-test
115+
runs-on: ubuntu-latest
116+
permissions:
117+
contents: "write"
118+
actions: "read"
119+
id-token: "write"
120+
timeout-minutes: 10
121+
steps:
122+
- name: Checkout repository
123+
uses: actions/checkout@v4
124+
with:
125+
fetch-depth: 0
126+
token: ${{ secrets.PAT }}
127+
- name: Npm install
128+
uses: ./.github/actions
129+
- name: Bump version
130+
run: |
131+
git config --global user.email "actions@github.com"
132+
git config --global user.name "GitHub Actions"
133+
npx nx release --skip-publish --first-release=${{ github.event.inputs.first-release }} --projects=${{ github.event.inputs.projects }} --dry-run=${{ github.event.inputs.dry-run }}
134+
shell: bash
135+
env:
136+
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
137+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
NPM_CONFIG_PROVENANCE: true

0 commit comments

Comments
 (0)