Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: build setup for npm and DockerHub #4

Merged
merged 9 commits into from
Oct 18, 2024
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
83 changes: 79 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,89 @@ jobs:
run: |
yarn check-types

- name: Build
run: |
yarn build

- name: Unit tests
run: |
yarn test

- name: E2E tests
run: |
yarn test:e2e

release-please:
runs-on: ubuntu-latest
needs: [build]
outputs:
releases_created: ${{ steps.release-please.outputs.releases_created }}
paths_released: ${{ steps.release-please.outputs.paths_released }}
steps:
- uses: googleapis/release-please-action@v4
id: release-please
with:
path: ./packages
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
token: ${{ secrets.GITHUB_TOKEN }}

- name: Print release outputs for debugging
continue-on-error: true
run: |
echo "Release outputs:"
echo ${{ toJson(steps.release-please.outputs) }}

# Initiate release process if release was created
release-client:
if: contains(needs.release-please.outputs.paths_released, 'packages/client')
runs-on: ubuntu-latest
needs: [release-please]
steps:
- name: Checkout message-pickup-repository
uses: actions/checkout@v4
- name: Setup node v20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org/'
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts

- name: Release to NPM
run: npm publish package/client
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

release-server:
if: contains(needs.release-please.outputs.paths_released, 'packages/server')
runs-on: ubuntu-latest
needs: [release-please]
env:
DH_USERNAME: ${{secrets.DOCKER_HUB_LOGIN}}
DH_TOKEN: ${{secrets.DOCKER_HUB_PWD}}
IMAGE_NAME: 'message-pickup-repository'
IMAGE_TAG: ${{ github.ref == 'refs/heads/main' && 'dev' || github.ref }}
steps:
- name: Checkout message-pickup-repository
uses: actions/checkout@v4
- name: Setup node v20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org/'
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts

- name: Log in to Docker Hub
run: |
echo "$DH_TOKEN" | docker login -u "$DH_USERNAME" --password-stdin

- name: Build Docker image
run: |
cp yarn.lock packages/server
cd packages/server
docker build -f Dockerfile -t $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG .

- name: Push to DockerHub
run: docker push $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# compiled output
/dist
/node_modules
build
dist
node_modules

# Logs
logs
Expand Down Expand Up @@ -38,4 +39,5 @@ lerna-debug.log*
/databases

#files
package-lock.json
package-lock.json
packages/server/yarn.lock
4 changes: 4 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"packages/client": "0.0.1",
"packages/server": "0.0.1"
}
32 changes: 0 additions & 32 deletions nest-cli.json

This file was deleted.

70 changes: 12 additions & 58 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,19 @@
"author": "",
"private": true,
"license": "Apache-2.0",
"workspaces": [
"packages/*"
],
"scripts": {
"build": "nest build",
"check-types": "eslint \"{src,packages,libs,test}/**/*.ts\"",
"format": "prettier --write \"packages/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/packages/server/main",
"lint": "eslint \"{src,packages,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./packages/server/test/jest-e2e.json"
},
"dependencies": {
"@credo-ts/core": "^0.5.10",
"@nestjs-modules/ioredis": "^2.0.2",
"@nestjs/axios": "^3.0.3",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.2.3",
"@nestjs/core": "^10.0.0",
"@nestjs/mapped-types": "*",
"@nestjs/mongoose": "^10.0.10",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/platform-ws": "^10.4.1",
"@nestjs/swagger": "^7.4.0",
"@nestjs/websockets": "^10.4.1",
"axios": "^1.7.5",
"class-validator": "^0.14.1",
"ioredis": "^5.4.1",
"mongodb": "^6.8.0",
"mongodb-memory-server": "^10.0.0",
"mongoose": "^8.6.0",
"redis": "^4.7.0",
"reflect-metadata": "^0.1.13",
"rpc-websockets": "^7.11.2",
"rxjs": "^7.8.1",
"ws": "^8.18.0"
"check-types": "yarn check-types:build",
"check-types:build": "yarn workspaces run tsc --noEmit -p tsconfig.build.json",
"prettier": "prettier '**/*.+(js|json|ts|tsx|md|yml|yaml)'",
"format": "yarn prettier --write",
"check-format": "yarn prettier --list-different",
"test": "yarn workspaces run test --passWithNoTests",
"test:e2e": "jest --config ./packages/server/test/jest-e2e.json",
"lint": "eslint --ignore-path .gitignore --ignore-pattern '**/esm/' .",
"validate": "yarn lint && yarn check-types && yarn check-format"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
Expand All @@ -68,25 +42,5 @@
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": ".",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "./coverage",
"testEnvironment": "node",
"roots": [
"<rootDir>/packages/"
]
}
}
3 changes: 0 additions & 3 deletions packages/client/.gitignore

This file was deleted.

21 changes: 21 additions & 0 deletions packages/client/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Config } from '@jest/types'

const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'node',
coveragePathIgnorePatterns: ['/build/', '/node_modules/', '/__tests__/', 'tests'],
coverageDirectory: '<rootDir>/coverage/',
testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
isolatedModules: true,
},
],
'^.+\\.jsx?$': require.resolve('babel-jest'),
},
moduleNameMapper: { '^uuid$': 'uuid' },
}

export default config
20 changes: 14 additions & 6 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"name": "@2060.io/message-pickup-repository-client",
"version": "1.0.0",
"description": "message pickup repository client",
"main": "build/index.js",
"version": "0.0.1",
"description": "Message Pickup Repository client module",
"main": "build/index",
"types": "build/index",
"license": "Apache-2.0",
"files": [
"build"
],
"scripts": {
"build": "tsc",
"start": "node build/index.js",
"start:dev": "nest start --watch",
"build": "yarn run clean && yarn run compile",
"clean": "rimraf -rf ./build",
"compile": "tsc -p tsconfig.build.json",
"prepublishOnly": "yarn run build",
"test": "jest"
},
"dependencies": {
Expand All @@ -24,6 +29,9 @@
"webpack": "^5.0.0",
"webpack-cli": "^4.0.0"
},
"peerDependencies": {
"@credo-ts/core": "^0.5.10"
},
"publishConfig": {
"access": "public"
}
Expand Down
34 changes: 0 additions & 34 deletions packages/client/src/index.d.ts

This file was deleted.

10 changes: 10 additions & 0 deletions packages/client/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.build.json",

"compilerOptions": {
"outDir": "./build",
"types": ["node"]
},

"include": ["src/**/*"]
}
16 changes: 3 additions & 13 deletions packages/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./build",
"rootDir": "./src",
"declaration": true,
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "build", "src/index.d.ts"]
"types": ["jest"]
}
}
Loading
Loading