Skip to content

Commit 8ea5fdf

Browse files
authored
Review pipeline
1 parent 8b71a10 commit 8ea5fdf

File tree

5 files changed

+506
-414
lines changed

5 files changed

+506
-414
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ name: Tiny URL CI Pipeline
33
on:
44
push:
55
branches:
6-
- main
7-
- 'feature/**' # Trigger workflow for feature branches
8-
- 'feat/**' # Trigger workflow for feature branches
9-
- 'doc/**' # Trigger workflow for feature branches
10-
- 'chore/**' # Trigger workflow for feature branches
11-
- 'fix/**' # Trigger workflow for feature branches
6+
- '**'
127
pull_request:
138
branches:
149
- main
@@ -18,6 +13,9 @@ jobs:
1813
api:
1914
name: API Build & Test
2015
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: api
2119

2220
steps:
2321
- name: Checkout Repository
@@ -28,7 +26,7 @@ jobs:
2826
with:
2927
node-version: 18
3028
cache: yarn
31-
cache-dependency-path: api/yarn-lock.json # Specify the path to your yarn.lock
29+
cache-dependency-path: api/yarn.lock # Specify the path to your yarn.lock
3230

3331
- name: Install Dependencies (API)
3432
working-directory: api
@@ -37,14 +35,24 @@ jobs:
3735
#- name: Lint API
3836
# run: npm run lint
3937

38+
- name: Create .env file
39+
run: |
40+
echo "MACHINE_ID=1" > .env
41+
working-directory: api # Ensure it is created inside `api/`
42+
4043
- name: Run Tests (API)
4144
run: yarn test
4245

46+
- name: Build API
47+
run: yarn build
48+
4349
# Webapp (Next.js) Build & Test
4450
webapp:
4551
name: Webapp Build & Test
4652
runs-on: ubuntu-latest
4753
defaults:
54+
run:
55+
working-directory: webapp
4856

4957
steps:
5058
- name: Checkout Repository
@@ -55,7 +63,7 @@ jobs:
5563
with:
5664
node-version: 18
5765
cache: yarn
58-
cache-dependency-path: webapp/yarn-lock.json
66+
cache-dependency-path: webapp/yarn.lock # Specify the path to your yarn.lock
5967

6068
- name: Install Dependencies (Webapp)
6169
run: yarn install --frozen-lockfile
@@ -64,15 +72,15 @@ jobs:
6472
run: yarn lint
6573

6674
#- name: Run Tests (Webapp)
67-
# run: npm test
75+
# run: npm test
6876

6977
- name: Build Webapp
7078
run: yarn build
7179

7280
# Merge Blocker: Ensure Both Builds Pass
7381
merge_guard:
7482
name: Ensure All Jobs Passed
75-
needs: [api, webapp]
83+
needs: [ api, webapp ]
7684
runs-on: ubuntu-latest
7785
steps:
7886
- name: Check for Failures

api/package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,35 @@
2020
"test:e2e": "jest --config ./test/jest-e2e.json"
2121
},
2222
"dependencies": {
23-
"@nestjs/common": "^10.0.0",
24-
"@nestjs/config": "^4.0.0",
25-
"@nestjs/core": "^10.0.0",
26-
"@nestjs/platform-express": "^10.0.0",
27-
"reflect-metadata": "^0.2.0",
28-
"rxjs": "^7.8.1"
23+
"@nestjs/common": "10.0.0",
24+
"@nestjs/config": "4.0.0",
25+
"@nestjs/core": "10.0.0",
26+
"@nestjs/platform-express": "10.0.0",
27+
"reflect-metadata": "0.2.0",
28+
"rxjs": "7.8.1"
2929
},
3030
"devDependencies": {
3131
"@nestjs/cli": "^10.0.0",
32-
"@nestjs/schematics": "^10.0.0",
33-
"@nestjs/testing": "^10.0.0",
34-
"@types/express": "^5.0.0",
35-
"@types/jest": "^29.5.2",
36-
"@types/node": "^20.3.1",
37-
"@types/supertest": "^6.0.0",
38-
"@typescript-eslint/eslint-plugin": "^8.0.0",
39-
"@typescript-eslint/parser": "^8.0.0",
40-
"eslint": "^8.0.0",
41-
"eslint-config-prettier": "^9.0.0",
42-
"eslint-plugin-prettier": "^5.0.0",
43-
"jest": "^29.5.0",
44-
"prettier": "^3.0.0",
45-
"source-map-support": "^0.5.21",
46-
"supertest": "^7.0.0",
47-
"ts-jest": "^29.1.0",
48-
"ts-loader": "^9.4.3",
49-
"ts-node": "^10.9.1",
50-
"tsconfig-paths": "^4.2.0",
51-
"typescript": "^5.1.3"
32+
"@nestjs/schematics": "10.0.0",
33+
"@nestjs/testing": "10.0.0",
34+
"@types/express": "5.0.0",
35+
"@types/jest": "29.5.2",
36+
"@types/node": "20.3.1",
37+
"@types/supertest": "6.0.0",
38+
"@typescript-eslint/eslint-plugin": "8.0.0",
39+
"@typescript-eslint/parser": "8.0.0",
40+
"eslint": "8.0.0",
41+
"eslint-config-prettier": "9.0.0",
42+
"eslint-plugin-prettier": "5.0.0",
43+
"jest": "29.5.0",
44+
"prettier": "3.0.0",
45+
"source-map-support": "0.5.21",
46+
"supertest": "7.0.0",
47+
"ts-jest": "29.1.0",
48+
"ts-loader": "9.4.3",
49+
"ts-node": "10.9.1",
50+
"tsconfig-paths": "4.2.0",
51+
"typescript": "5.1.3"
5252
},
5353
"jest": {
5454
"moduleFileExtensions": [

api/src/shorten-url/shorten-url.id-generator.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export class ShortenUrlIdGeneratorService {
2828
private lastTimestamp: number;
2929

3030
constructor(private readonly configService: ConfigService) {
31+
// check if the machine id is not null
32+
if (!this.configService.get<number>('MACHINE_ID'))
33+
throw new Error('MACHINE_ID is not defined in the environment variables');
34+
3135
this.machineId = Number(this.configService.get<number>('MACHINE_ID'));
3236
if (
3337
this.machineId < 0 ||

0 commit comments

Comments
 (0)