Skip to content

Commit

Permalink
Merge pull request #104 from AII-the-time/feat/docker-cicd-for-arm
Browse files Browse the repository at this point in the history
Feat:docker ci/cd for arm
  • Loading branch information
raipen authored Apr 4, 2024
2 parents 0ff8979 + 2d5e756 commit bc7a335
Show file tree
Hide file tree
Showing 6 changed files with 453 additions and 4 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ jobs:
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest-arm64

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest-amd64

deploy:
needs: build
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ jobs:
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest-dev
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest-dev-arm64

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest-dev-amd64
108 changes: 108 additions & 0 deletions test/integration/5. etc/createWithoutParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { FastifyInstance } from 'fastify';
import { ErrorInterface } from '@DTO/index.dto';
import testValues from '../testValues';
import * as Menu from '@DTO/menu.dto';
import * as Order from '@DTO/order.dto';
import { expect, test } from '@jest/globals';

export default (app: FastifyInstance) => () => {
let tempOrderId: number;
test('order without mileage', async () => {
const response = await app.inject({
method: 'POST',
url: `/api/order`,
headers: testValues.storeHeader,
payload: {
menus: [
{
id: testValues.americanoId,
count: 1,
options: [1],
},
],
totalPrice: (2500).toString(),
},
});
expect(response.statusCode).toBe(200);
const body = JSON.parse(response.body) as Order.newOrderInterface['Reply']['200'];
expect(body.orderId).toBeDefined();
tempOrderId = body.orderId;
});

test('pay without mileage', async () => {
const response = await app.inject({
method: 'POST',
url: `/api/order/pay`,
headers: testValues.storeHeader,
payload: {
orderId: tempOrderId,
paymentMethod: 'CARD',
} as Order.payInterface['Body'],
});
expect(response.statusCode).toBe(200);
});

let tempMenuId: number;
test('register menu without option, recipe', async () => {
const response = await app.inject({
method: 'POST',
url: `/api/menu`,
headers: testValues.storeHeader,
payload: {
name: 'new menu',
price: "1000",
categoryId: testValues.coffeeCategoryId,
} as Menu.createMenuInterface['Body'],
});
expect(response.statusCode).toBe(201);
const body = JSON.parse(response.body) as Menu.createMenuInterface['Reply']['201'];
expect(body.menuId).toBeDefined();
tempMenuId = body.menuId;
});

test('update menu without option, recipe', async () => {
const response = await app.inject({
method: 'PUT',
url: `/api/menu`,
headers: testValues.storeHeader,
payload: {
id: tempMenuId,
name: 'new menu',
price: "1000",
categoryId: testValues.coffeeCategoryId,
} as Menu.updateMenuInterface['Body']
});
expect(response.statusCode).toBe(201);
const body = JSON.parse(response.body) as Menu.updateMenuInterface['Reply']['201'];
expect(body.menuId).not.toBe(tempMenuId);
});

test('update menu with recipe with unit', async () => {
const response = await app.inject({
method: 'PUT',
url: `/api/menu`,
headers: testValues.storeHeader,
payload: {
id: tempMenuId,
name: 'new menu',
price: "1000",
categoryId: testValues.coffeeCategoryId,
recipe: [
{
id: testValues.coffeeBeanId,
unit: 'g',
isMixed: false,
},
{
id: testValues.preservedLemonId,
unit: 'g',
isMixed: true,
}
],
} as Menu.updateMenuInterface['Body']
});
expect(response.statusCode).toBe(201);
const body = JSON.parse(response.body) as Menu.updateMenuInterface['Reply']['201'];
expect(body.menuId).not.toBe(tempMenuId);
});
};
17 changes: 17 additions & 0 deletions test/integration/5. etc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FastifyInstance } from 'fastify';
import { afterAll, describe} from '@jest/globals';
import createWithoutParams from './createWithoutParams';
import report from './report';
import stockHistory from './stockHistory';

const tests:[string, (app: FastifyInstance) => () => void][] = [
['create without params', createWithoutParams],
['report', report],
['stock history', stockHistory],
];

export default (app: FastifyInstance) => () => {
tests.forEach(([name, test]) => {
describe(name, test(app));
});
};
54 changes: 54 additions & 0 deletions test/integration/5. etc/report.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { FastifyInstance } from 'fastify';
import { ErrorInterface } from '@DTO/index.dto';
import * as Report from '@DTO/report.dto';
import testValues from '../testValues';
import { PrismaClient } from '@prisma/client';
import { expect, test, beforeAll } from '@jest/globals';

const prisma = new PrismaClient();

export default (app: FastifyInstance) => () => {
test('get report', async () => {
const response = await app.inject({
method: 'GET',
url: `/api/report`,
headers: testValues.testStoreHeader,
});
expect(response.statusCode).toBe(200);
const body = JSON.parse(response.body) as Report.reportInterface['Reply']['200'];
const recentSalesReport = body.responseData.viewContents[0].content as unknown as Report.graphInterface;
expect(recentSalesReport.graphTitle).toBe('최근 30일 매출');
expect(recentSalesReport.graphColor).toBe('#2B1E12');
expect(recentSalesReport.graphItems.length).toBeGreaterThan(0);

const salesReportByTime = body.responseData.viewContents[1].content as unknown as Report.graphInterface;
expect(salesReportByTime.graphTitle).toBe('최근 30일 시간대별 매출');
expect(salesReportByTime.graphColor).toBe('#2B1E12');
expect(salesReportByTime.graphItems.length).toBeGreaterThan(0);

const returnRateReport = body.responseData.viewContents[2].content as unknown as Report.pieChartInterface;
expect(returnRateReport.pieChartTitle).toBe('재방문율');
expect(returnRateReport.totalCount).toBe(250);
expect(returnRateReport.pieChartItems.length).toBe(6);

const reservedSalesReport = body.responseData.viewContents[3].content as unknown as Report.pieChartInterface;
expect(reservedSalesReport.pieChartTitle).toBe('예약 매출');
expect(reservedSalesReport.pieChartItems.length).toBe(2);
});

test('get report', async () => {
const response = await app.inject({
method: 'GET',
url: `/api/report`,
headers: testValues.storeHeader,
});
expect(response.statusCode).toBe(200);
const body = JSON.parse(response.body) as Report.reportInterface['Reply']['200'];
expect(body.responseData.viewContents.length).toBe(1);
const textReport = body.responseData.viewContents[0].content as unknown as Report.textInterface;
expect(body.responseData.viewContents[0].viewType).toBe('TEXT');
expect(textReport).toHaveProperty('textItems');
expect(textReport.textItems.length).toBe(1);
expect(textReport.textItems[0].text).toBe('최소 3일 이상의 주문 데이터가 필요합니다.');
});
};
Loading

0 comments on commit bc7a335

Please sign in to comment.