Skip to content

Commit c76ae72

Browse files
committed
ci: New CI/CD process
1 parent e9f11d3 commit c76ae72

File tree

19 files changed

+568
-187
lines changed

19 files changed

+568
-187
lines changed

.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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: ⚙️ Build
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
18+
uses: nrwl/nx-set-shas@v4
19+
with:
20+
main-branch-name: "master"
21+
22+
- name: Setup Node.js
23+
uses: ./.github/actions
24+
25+
- name: Build Libraries
26+
run: npx nx affected --target=build --parallel=3 --exclude='*,!tag:type:publish'

.github/workflows/ci.yml

Lines changed: 0 additions & 95 deletions
This file was deleted.

.github/workflows/e2e-test.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: ⚙️ E2E Test
2+
on:
3+
workflow_call:
4+
env:
5+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
6+
jobs:
7+
e2e-test:
8+
runs-on: ubuntu-latest
9+
services:
10+
postgres:
11+
image: postgres
12+
env:
13+
POSTGRES_PASSWORD: postgres
14+
POSTGRES_DB: json-api-db
15+
options: >-
16+
--health-cmd pg_isready
17+
--health-interval 10s
18+
--health-timeout 5s
19+
--health-retries 5
20+
ports:
21+
- 5432:5432
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
- name: Setup Node.js
26+
uses: ./.github/actions
27+
- run: npm run typeorm migration:run
28+
- run: npm run seed:run
29+
- run: npx nx run json-api-server-e2e:e2e --parallel=1
30+
- run: npx nx run json-api-server-e2e:e2e-micro --parallel=1

.github/workflows/pr.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 📝 PR Checks
2+
3+
on:
4+
[pull_request]
5+
6+
jobs:
7+
test:
8+
uses: ./.github/workflows/test.yml
9+
secrets:
10+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
11+
12+
e2e-test:
13+
needs: [test]
14+
uses: ./.github/workflows/e2e-test.yaml
15+
secrets:
16+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
17+
18+
build:
19+
needs: [test, e2e-test]
20+
uses: ./.github/workflows/build.yml
21+
secrets:
22+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: ⚙️ Test
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
NX_CLOUD_ACCESS_TOKEN:
7+
required: true
8+
env:
9+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup Node.js
21+
uses: ./.github/actions
22+
23+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
24+
uses: nrwl/nx-set-shas@v4
25+
with:
26+
main-branch-name: "master"
27+
28+
- name: Test
29+
run: npx nx affected --target=test --parallel=3 --passWithNoTests --exclude='*,!tag:type:publish'

libs/json-api/json-api-nestjs-microorm/src/lib/orm-methods/get-all/get-all.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ describe('get-all', () => {
860860
},
861861
})
862862
.getResult();
863-
const count = await quweryBuilder.clone().count();
863+
const count = await quweryBuilder.clone().count('id', true);
864864
const query = getDefaultQuery<Users>();
865865
query.page = {
866866
size: 5,

libs/json-api/json-api-nestjs-microorm/src/lib/orm-methods/post-relationship/post-relationship.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,11 @@ describe('post-relationshipa', () => {
8181
jest.restoreAllMocks();
8282
});
8383

84-
afterAll(() => {
85-
mikroORMUsers.close(true);
86-
});
84+
afterAll(() => mikroORMUsers.close(true));
8785

8886
it('should be ok', async () => {
89-
const roles1 = faker.helpers.arrayElement(roles);
90-
const roles2 = faker.helpers.arrayElement(roles);
91-
const roles3 = faker.helpers.arrayElement(roles);
87+
const [roles1, roles2, roles3] = faker.helpers.arrayElements(roles, 3);
88+
9289
const userGroup1 = faker.helpers.arrayElement(userGroup);
9390
const saveIdUserGroup = userGroup1.id;
9491

@@ -139,12 +136,15 @@ describe('post-relationshipa', () => {
139136
})
140137
.getSingleResult();
141138

139+
const newRolesId = [roles1.id, roles2.id, roles3.id].filter(
140+
(i) => !saveRolesIds.includes(i)
141+
);
142142
expect(checkData?.roles.map((i) => i.id)).toEqual(
143143
expect.arrayContaining([roles1.id, roles2.id, roles3.id])
144144
);
145145

146146
expect(checkData?.roles.map((i) => i.id)).toHaveLength(
147-
[roles1.id, roles2.id, roles3.id].length + saveRolesIds.length
147+
newRolesId.length + saveRolesIds.length
148148
);
149149
expect(checkData?.userGroup?.id).toBe(saveIdUserGroup);
150150
});

libs/json-api/json-api-nestjs-microorm/tsconfig.spec.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"@klerick/json-api-nestjs": [
1616
"libs/json-api/json-api-nestjs/src/index.ts"
1717
]
18-
}
18+
},
19+
"allowJs": true
1920
},
2021
"include": [
2122
"jest.config.ts",

libs/json-api/json-api-nestjs-sdk/tsconfig.spec.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"@klerick/json-api-nestjs-shared": [
1010
"libs/json-api/json-api-nestjs-shared/src/index.ts"
1111
]
12-
}
12+
},
13+
"allowJs": true
1314
},
1415
"include": [
1516
"jest.config.ts",

libs/json-api/json-api-nestjs-shared/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
}
1313
},
14-
"tags": [],
14+
"tags": ["type:lib", "lib:json-api-nestjs", "lib:json-api-nestjs-shared", "type:publish"],
1515
"targets": {
1616
"build-cjs": {
1717
"executor": "@nx/js:tsc",

libs/json-api/json-api-nestjs-typeorm/tsconfig.spec.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"@klerick/json-api-nestjs": [
1313
"libs/json-api/json-api-nestjs/src/index.ts"
1414
]
15-
}
15+
},
16+
"allowJs": true
1617
},
1718
"include": [
1819
"jest.config.ts",

libs/json-api/json-api-nestjs/tsconfig.spec.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"@klerick/json-api-nestjs-shared": [
1010
"libs/json-api/json-api-nestjs-shared/src/index.ts"
1111
]
12-
}
12+
},
13+
"allowJs": true
1314
},
1415
"include": [
1516
"jest.config.ts",

libs/json-rpc/nestjs-json-rpc-sdk/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@
105105
}
106106
}
107107
},
108-
"tags": []
108+
"tags": ["type:lib", "lib:nestjs-json-rpc", "lib:nestjs-json-rpc-sdk", "type:publish"]
109109
}

libs/json-rpc/nestjs-json-rpc/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@
5050
}
5151
}
5252
},
53-
"tags": []
53+
"tags": ["type:lib", "lib:nestjs-json-rpc", "lib:nestjs-json-rpc", "type:publish"]
5454
}

0 commit comments

Comments
 (0)