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

Feat/6 git actions #8

Merged
merged 32 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
04e4f24
feat: add RedisClient
junha-ahn Oct 16, 2023
b50f8f5
feat: add ticket routes
junha-ahn Oct 17, 2023
7c6adfe
chore: add prettierrc settings
junha-ahn Oct 17, 2023
76cad98
test: add healthCheck integartion Test
junha-ahn Oct 17, 2023
50d8679
test: add test for queue-ticket
junha-ahn Oct 17, 2023
4a8a654
feat: add check ticket API
junha-ahn Oct 18, 2023
ca8277c
fix: chnage function name
junha-ahn Oct 18, 2023
d1153ae
test: add Running Queue test
junha-ahn Oct 18, 2023
bbd8638
test: move test files
junha-ahn Oct 18, 2023
bf5177c
feat: add totalqueueid list
junha-ahn Oct 19, 2023
6da1a86
test: fix test for look easy
junha-ahn Oct 20, 2023
850539d
feat: add job js
junha-ahn Oct 18, 2023
e44f078
fix: sperate redis/express loaders
junha-ahn Oct 19, 2023
af3c86d
feat: add getTotalEvent
junha-ahn Oct 19, 2023
2f7693a
feat: add moveEventToRunning
junha-ahn Oct 19, 2023
b2088c1
feat: add removeExpiredTicket
junha-ahn Oct 19, 2023
aa5a9ee
feat: add removeExpiredQueue
junha-ahn Oct 19, 2023
23a3a7e
fix: rename eventqueue => eventlist
junha-ahn Oct 19, 2023
1b9bcc8
feat: enable job
junha-ahn Oct 19, 2023
fde7cb7
fix: variable names
junha-ahn Oct 19, 2023
35e6d5d
test: fix test for looking easy
junha-ahn Oct 20, 2023
eda6168
chore: add test.yml
junha-ahn Oct 20, 2023
85bb77a
chore: add forceExit script
junha-ahn Oct 20, 2023
ba3af67
chore: fix disconnect after all test
junha-ahn Oct 20, 2023
746bd03
test: fix for quit
junha-ahn Oct 20, 2023
8feb730
test: fix for quit
junha-ahn Oct 20, 2023
6276718
test: fix for quit
junha-ahn Oct 20, 2023
0d8434e
test: fix for quit
junha-ahn Oct 20, 2023
1e8a7a7
chore: add push image to ecr
junha-ahn Oct 20, 2023
ec0abf1
chore: upgrade node version
junha-ahn Oct 20, 2023
ecec72f
chore: Merge remote-tracking branch 'origin/main' into feat/6-git-act…
junha-ahn Oct 24, 2023
9854ec1
chore: fix ecr push only on main branch
junha-ahn Oct 24, 2023
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
40 changes: 40 additions & 0 deletions .github/workflows/aws-ecr-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: push to ECR

on:
push:
branches:
- main

env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: ticketing-queuing-ecr

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:v$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:v$IMAGE_TAG"
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on: push

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: check dependency cache
uses: actions/cache@v3
id: npm-cache
with:
path: ${{ github.workspace }}/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: install dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm install

- name: Run Test
run: npm run test
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18
FROM node:20

WORKDIR /usr/src/app

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start:api": "node src/api.js",
"start:job": "node src/job.js",
"test": "jest"
"test": "jest --forceExit"
},
"keywords": [],
"author": "",
Expand Down
26 changes: 14 additions & 12 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ function startServer() {
expressLoader(app)
Logger.info('Express loaded')

app.listen(config.port, (err) => {
if (err) {
Logger.error(err)
process.exit(1)
}
Logger.info(`
----------------------------------------------
🛡️ Server listening on port: ${config.port} 🛡️
NODE_ENV: ${config.NODE_ENV}
----------------------------------------------
`)
})
if (config.NODE_ENV !== 'test') {
app.listen(config.port, (err) => {
if (err) {
Logger.error(err)
process.exit(1)
}
Logger.info(`
----------------------------------------------
🛡️ Server listening on port: ${config.port} 🛡️
NODE_ENV: ${config.NODE_ENV}
----------------------------------------------
`)
})
}

module.exports = app
}
Expand Down
1 change: 1 addition & 0 deletions src/services/ticketStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ module.exports = class TicketStore {
userId,
}
}

async shiftFromWaiting(eventId, moveCount) {
const results = await this._shift(this.getWaitingKeyByEventId(eventId), moveCount)
return results.map((e) => ({
Expand Down
1 change: 1 addition & 0 deletions test/integrationTest/api/ticket.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ chai.use(chaiHttp)
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

describe('Ticket', () => {
let container = null
let server = null
let redis = null
let ticketStoreService = null
Expand Down
1 change: 1 addition & 0 deletions test/integrationTest/job/jobService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('Ticket', () => {
let redis = null
let ticketStoreService = null
let jobService = null
let container = null

const testEventId = 1

Expand Down
Loading