-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add DataSyncModule to app.module.ts * Update package.json and yarn.lock to add @nestjs/schedule dependency * Add @nestjs/schedule and AssetManagementModule to DataSyncModule imports * Add new files and update existing files in asset-management module * Add new files and update existing files in data-sync module * Remove unused files and configurations * Add Docker configuration files * Add CI workflow for building and publishing Docker image * Add pull_request trigger to CI workflow * Update NodeJS version in CI workflow to use actions/setup-node@v4 * Refactor logger instantiation in asset.service.ts and asset-exchange.service.ts * Update CI workflow to remove creation of .env file * Update CI workflow to include Docker image build and push * Update CI workflow to include Docker image save and load * Update CI workflow to include Docker image save and load * Refactor Docker image naming in CI workflow * Add GitHub Actions step to comment on successful pull requests with Docker image artifact link * Update GitHub Actions step to use actions/github-script@v7 in ci.yml * Update permissions in ci.yml
- Loading branch information
1 parent
3565c93
commit 5025b98
Showing
43 changed files
with
1,263 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules | ||
dist | ||
test | ||
.dockerignore | ||
Dockerfile | ||
README.md | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
permissions: | ||
issues: write | ||
pull-requests: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up NodeJS | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Run tests | ||
run: yarn test --colors | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t stockdog:pr-${{ github.event.number }} . | ||
docker save stockdog:pr-${{ github.event.number }} > stockdog-pr-${{ github.event.number }}.image.tar | ||
- name: Save Docker image as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: docker-image | ||
path: stockdog-pr-${{ github.event.number }}.image.tar | ||
|
||
- name: Comment PR | ||
if: success() && github.event_name == 'pull_request' | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const artifactUrl = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; | ||
const message = `:sparkles: **Docker Image Artifact** :sparkles:\n\nYour Docker image artifact can be found at the following location:\n\n:point_right: [Click Here](${artifactUrl}) :point_left:\n\nHappy coding! :rocket:`; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: message, | ||
}); | ||
push: | ||
needs: build | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download Docker image from artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: docker-image | ||
path: stockdog-pr-${{ github.event.number }}.image.tar | ||
|
||
- name: Load Docker image | ||
run: docker load < stockdog-pr-${{ github.event.number }}.image.tar | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
||
- name: Push Docker image | ||
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/stockdog:pr-${{ github.event.number }} | ||
|
||
- name: Update image metadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ secrets.DOCKER_HUB_USERNAME }}/stockdog:pr-${{ github.event.number }} | ||
tags: | | ||
type=sha | ||
labels: | | ||
org.opencontainers.image.title=StockDog App | ||
org.opencontainers.image.description=Stock market analysis app | ||
org.opencontainers.image.url=https://github.com/${{github.repository}} | ||
org.opencontainers.image.revision=${{github.sha}} | ||
org.opencontainers.image.licenses=MIT |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM node:21-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json ./ | ||
|
||
COPY yarn.lock ./ | ||
|
||
RUN yarn install | ||
|
||
COPY . . | ||
|
||
RUN yarn build | ||
|
||
EXPOSE 3000 | ||
|
||
CMD [ "yarn", "start:prod" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
version: '3.8' | ||
services: | ||
db: | ||
image: postgres:13 | ||
environment: | ||
version: '3.8' | ||
|
||
services: | ||
db: | ||
image: postgres:13 | ||
environment: | ||
POSTGRES_USER: ${DB_USERNAME} | ||
POSTGRES_PASSWORD: ${DB_PASSWORD} | ||
POSTGRES_DB: ${DB_NAME} | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- db-data:/var/lib/postgresql/data | ||
|
||
volumes: | ||
db-data: | ||
ports: | ||
- '5432:5432' | ||
volumes: | ||
- db-data:/var/lib/postgresql/data | ||
networks: | ||
- stockdog | ||
|
||
volumes: | ||
db-data: | ||
|
||
networks: | ||
stockdog: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { IsString, IsOptional, IsNotEmpty, IsNumber } from 'class-validator'; | ||
import { AssetExchange } from '../entities'; | ||
|
||
export class AssetDto { | ||
@IsNotEmpty() | ||
@IsString() | ||
isin: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
symbol: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
name: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
assetExchangeCode: string; | ||
|
||
@IsOptional() | ||
@IsNumber() | ||
faceValue: number; | ||
|
||
@IsOptional() | ||
@IsString() | ||
industry: string; | ||
|
||
@IsOptional() | ||
@IsString() | ||
sector: string; | ||
|
||
@IsOptional() | ||
assetExchanges: AssetExchange[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { IsDate, IsNumber, IsOptional } from 'class-validator'; | ||
import { AssetExchange } from '../entities'; | ||
|
||
export class DeliveryDataDTO { | ||
@IsDate() | ||
date: Date; | ||
|
||
@IsNumber() | ||
@IsOptional() | ||
deliveryQuantity: number; | ||
|
||
@IsNumber() | ||
@IsOptional() | ||
deliveryPercentage: number; | ||
|
||
@IsOptional() | ||
assetExchange: AssetExchange | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './asset.dto'; | ||
export * from './trading-data.dto'; | ||
export * from './delivery-data.dto'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { IsNumber, IsDate } from 'class-validator'; | ||
import { AssetExchange } from '../entities'; | ||
|
||
export class TradingDataDTO { | ||
@IsDate() | ||
date: Date; | ||
|
||
@IsNumber() | ||
open: number; | ||
|
||
@IsNumber() | ||
high: number; | ||
|
||
@IsNumber() | ||
low: number; | ||
|
||
@IsNumber() | ||
close: number; | ||
|
||
@IsNumber() | ||
lastPrice: number; | ||
|
||
@IsNumber() | ||
previousClose: number; | ||
|
||
@IsNumber() | ||
volume: number; | ||
|
||
@IsNumber() | ||
turnover: number; | ||
|
||
@IsNumber() | ||
totalTrades: number; | ||
|
||
assetExchange: AssetExchange; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.