Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ jobs:
- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true' || steps.validate-cache.outputs.valid == 'false'
run: npm ci
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Cache tool artifacts (tsc, ESLint, Prettier)
uses: actions/cache@v4
Expand Down Expand Up @@ -162,6 +164,8 @@ jobs:
- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true' || steps.validate-cache.outputs.valid == 'false'
run: npm ci
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Run affected unit tests
run: |
Expand Down Expand Up @@ -257,6 +261,8 @@ jobs:
- name: Install Dependencies
if: env.RUN_TESTS == 'true' && (steps.cache-node-modules.outputs.cache-hit != 'true' || steps.validate-cache.outputs.valid == 'false')
run: npm ci
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Lint .env file
if: env.RUN_TESTS == 'true'
Expand All @@ -268,6 +274,8 @@ jobs:

- name: Initialize database
if: env.RUN_TESTS == 'true'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
touch .env
node dev_env/init-db.mjs
Expand Down
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@wxyc:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
6 changes: 5 additions & 1 deletion Dockerfile.auth
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#Build stage
FROM node:22-alpine AS builder

ARG NPM_TOKEN
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We may want to make use of dockerfile secrets instead of args here: https://docs.docker.com/build/building/secrets/

If nothing else, but to shut up the linter.

WORKDIR /auth-builder

COPY ./.npmrc ./
COPY ./package.json ./package-lock.json ./
COPY ./tsconfig.base.json ./
COPY ./shared ./shared
Expand All @@ -13,14 +15,16 @@ RUN npm ci && npm run build --workspace=@wxyc/database --workspace=shared/** --w
#Production stage
FROM node:22-alpine AS prod

ARG NPM_TOKEN
WORKDIR /auth-service

COPY ./.npmrc ./
COPY ./package* ./
COPY ./apps/auth/package* ./apps/auth/
COPY ./shared/database/package* ./shared/database/
COPY ./shared/authentication/package* ./shared/authentication/

RUN npm install --omit=dev
RUN npm install --omit=dev && rm -f .npmrc

COPY --from=builder ./auth-builder/apps/auth/dist ./apps/auth/dist
COPY --from=builder ./auth-builder/shared/database/dist ./shared/database/dist
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#Build stage
FROM node:22-alpine AS builder

ARG NPM_TOKEN
WORKDIR /builder

COPY ./.npmrc ./
COPY ./package.json ./package-lock.json ./
COPY ./tsconfig.base.json ./
COPY ./shared ./shared
Expand All @@ -13,14 +15,16 @@ RUN npm ci && npm run build --workspace=@wxyc/database --workspace=shared/** --w
#Production stage
FROM node:22-alpine AS prod

ARG NPM_TOKEN
WORKDIR /application

COPY ./.npmrc ./
COPY ./package* ./
COPY ./apps/backend/package* ./apps/backend/
COPY ./shared/database/package* ./shared/database/
COPY ./shared/authentication/package* ./shared/authentication/

RUN npm install --omit=dev
RUN npm install --omit=dev && rm -f .npmrc

COPY --from=builder ./builder/apps/backend/dist ./apps/backend/dist
COPY --from=builder ./builder/shared/database/dist ./shared/database/dist
Expand Down
2 changes: 1 addition & 1 deletion apps/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "node dist/app.js",
"build": "tsup --minify",
"clean": "rm -rf dist",
"docker:build": "docker build -t wxyc_auth_service:ci -f ../../Dockerfile.auth ../../",
"docker:build": "docker build --build-arg NPM_TOKEN=$NPM_TOKEN -t wxyc_auth_service:ci -f ../../Dockerfile.auth ../../",
"dev": "tsup --watch",
"typecheck": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "node dist/app.js",
"build": "tsup --minify",
"clean": "rm -rf dist",
"docker:build": "docker build -t wxyc_backend_service:ci -f ../../Dockerfile.backend ../../",
"docker:build": "docker build --build-arg NPM_TOKEN=$NPM_TOKEN -t wxyc_backend_service:ci -f ../../Dockerfile.backend ../../",
"dev": "tsup --watch",
"typecheck": "tsc --noEmit"
},
Expand Down
4 changes: 2 additions & 2 deletions jest.unit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ const config: Config = {
testMatch: ['<rootDir>/tests/unit/**/*.test.ts'],
setupFilesAfterEnv: ['<rootDir>/tests/setup/unit.setup.ts'],
transform: {
'^.+\\.tsx?$': [
'^.+\\.[jt]sx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tests/tsconfig.json',
},
],
},
transformIgnorePatterns: ['node_modules/(?!(jose|drizzle-orm)/)'],
transformIgnorePatterns: ['node_modules/(?!(jose|drizzle-orm|@wxyc/shared)/)'],
moduleNameMapper: {
// Mock workspace database package
'^@wxyc/database$': '<rootDir>/tests/mocks/database.mock.ts',
Expand Down
Loading
Loading