Skip to content

Commit ec69edd

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

File tree

18 files changed

+545
-186
lines changed

18 files changed

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

.github/workflows/pr.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: 📝 PR Checks
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
test:
7+
uses: ./.github/workflows/test.yml
8+
e2e-test:
9+
uses: ./.github/workflows/e2e-test.yaml
10+
build:
11+
needs: [test, e2e-test]
12+
uses: ./.github/workflows/build.yml

.github/workflows/test.yml

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

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@ describe('post-relationshipa', () => {
3333
let comments: Collection<Comments>;
3434
let userObject: Users;
3535
let newUser: Users;
36-
beforeAll(async () => {
36+
37+
beforeEach(async () => {
3738
dbName = dbRandomName();
3839
const moduleUsers = await getModuleForPgLite(Users, dbName);
3940
microOrmServiceUser = moduleUsers.get<MicroOrmService<Users>>(ORM_SERVICE);
4041
mikroORMUsers = moduleUsers.get(MikroORM);
4142
em = moduleUsers.get(CURRENT_ENTITY_MANAGER_TOKEN);
4243
await pullData(em, 10);
43-
});
44-
45-
beforeEach(async () => {
4644
userObject = (await microOrmServiceUser.microOrmUtilService
4745
.queryBuilder()
4846
.limit(1)
@@ -77,14 +75,11 @@ describe('post-relationshipa', () => {
7775
});
7876

7977
afterEach(() => {
78+
mikroORMUsers.close(true);
8079
jest.clearAllMocks();
8180
jest.restoreAllMocks();
8281
});
8382

84-
afterAll(() => {
85-
mikroORMUsers.close(true);
86-
});
87-
8883
it('should be ok', async () => {
8984
const roles1 = faker.helpers.arrayElement(roles);
9085
const roles2 = faker.helpers.arrayElement(roles);

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)