๐ค Refactor: ์ฝ๋์๋ํฐ ์ฝ๋ ๊ด์ฌ์ฌ ๋ถ๋ฆฌ ๋ฐ ๋ถ๋ฆฌ๋ ๋ธ๋ฆฟ์ง ๋ ์ด์ด ์ ์ฉํ ์ธ์ ์ปค์คํ ํ ๊ตฌํ #723
This file contains hidden or 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
| name: local์์ CI๊ฐ ์คํ ์ค ์ผ๋ | |
| # dev, main ๋ธ๋ฐ์น์ push, pull_request ํ ๋๋ ์ด ๊ณผ์ ์ด ์๋ต๋ฉ๋๋ค. | |
| on: | |
| push: | |
| branches-ignore: | |
| - main | |
| - dev | |
| pull_request: | |
| branches-ignore: | |
| - main | |
| - dev | |
| # ๊ฐ์ ๋ธ๋ฐ์น์์๋ ๊ธฐ์กด์ ๊ฒ์ ๋ฐ๋ก push ํ๋ฉด ์ ์ ๊ฒ์ ๋ฉ์ถฅ๋๋ค. | |
| concurrency: | |
| group: ${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ๋ฐฑ์๋๋ ๋จ์ํ ์คํธ + ํตํฉํ ์คํธ ์งํ ํ -> docker build -> docker ๋ฐฑ์๋ ํตํฉํ ์คํธ๋ฅผ ์งํํฉ๋๋ค. | |
| main-backend-test: | |
| name: jest๋ฅผ ํ์ฉํ main_backend ํ ์คํธ | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| # ํ์ฌ ๋ธ๋ฐ์น๋ฅผ ์ด ํ๋ก์ธ์ค์ ์ ์ฉํฉ๋๋ค. | |
| - name: Checkout backend | |
| uses: actions/checkout@v5 | |
| # pnpm์ ์ฌ์ฉํ ์ ์๋๋กpnpm์ ์ค์ ํ๋ค. | |
| - name: pnpm ์ฌ์ฉ์ ์ํ ์ธํ | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| # nodejs๋ฅผ ์ค์ ํฉ๋๋ค. | |
| # pnpm-lock.yaml์ด ์ด ์ ์ญ cache๋ฅผ ์ฐธ๊ณ ํ๋๋ก ํ๋ค. | |
| - name: nodejs ์ค์ | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| cache: "pnpm" | |
| cache-dependency-path: ./rep/main_backend/pnpm-lock.yaml | |
| # pnpm์ ์ด์ฉํด์ ์ค์นํฉ๋๋ค. ( pnpm-lock.yaml์ ์ฌ์ฉ ) | |
| - name: backend package ์ค์น | |
| working-directory: ./rep/main_backend | |
| run: pnpm install --frozen-lockfile | |
| # ๋ฐฑ์๋ ๊ด๋ จ ํ๊ฒฝ๋ณ์ ์ถ๊ฐ | |
| - name: backend ํ๊ฒฝ๋ณ์ ํ์ผ ์ถ๊ฐ | |
| working-directory: ./rep/main_backend | |
| run: echo "${{ secrets.NODE_MAIN_BACKEND_LOCAL_ENV }}" > .env | |
| # backend ๋จ์ ํ ์คํธ ์คํ | |
| - name: backend ๋จ์ํ ์คํธ ์คํ | |
| working-directory: ./rep/main_backend | |
| run: pnpm test:unit | |
| # backend ํตํฉ ํ ์คํธ ์คํ - ์ถํ ์ถ๊ฐ | |
| # tool backend test ( main_backend์ ๊ฑฐ์ ๋์ผํ ๋ก์ง ์ ๋๋ค. ) | |
| tool-backend-test: | |
| name: jest๋ฅผ ํ์ฉํ tool_backend ํ ์คํธ | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout backend | |
| uses: actions/checkout@v5 | |
| - name: pnpm ์ฌ์ฉ์ ์ํ ์ธํ | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: nodejs ์ค์ | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| cache: "pnpm" | |
| cache-dependency-path: ./rep/tool_backend/pnpm-lock.yaml | |
| - name: backend package ์ค์น | |
| working-directory: ./rep/tool_backend | |
| run: pnpm install --frozen-lockfile | |
| # ๋ฐฑ์๋ ๊ด๋ จ ํ๊ฒฝ๋ณ์ ์ถ๊ฐ | |
| - name: backend ํ๊ฒฝ๋ณ์ ํ์ผ ์ถ๊ฐ | |
| working-directory: ./rep/tool_backend | |
| run: echo "${{ secrets.NODE_TOOL_BACKEND_LOCAL_ENV }}" > .env | |
| # backend ๋จ์ ํ ์คํธ ์คํ | |
| - name: backend ๋จ์ํ ์คํธ ์คํ | |
| working-directory: ./rep/tool_backend | |
| run: pnpm test:unit | |
| # ํ๋ก ํธ์๋ ํ ์คํธ ์งํ -> ์ถํ ์ถ๊ฐ | |
| # ๋น๋ ํ -> ๋น๋ ๋ ์ปจํ ์ด๋ ํ ์คํธ | |
| docker-build-and-integration-test: | |
| name: Docker image ๋น๋ ํ ํตํฉํ ์คํธ | |
| runs-on: ubuntu-22.04 | |
| needs: | |
| - main-backend-test | |
| - tool-backend-test | |
| # ๋์ค์ ํ๋ก ํธ๋ ์ถ๊ฐ - ํ ์คํธ | |
| steps: | |
| - name: Checkout docker | |
| uses: actions/checkout@v5 | |
| - name: docker ํ๊ฒฝ ๋ณ์ ์ค์ (backend) | |
| run: | | |
| echo "${{ secrets.NODE_MAIN_BACKEND_LOCAL_ENV }}" > .env.main.backend | |
| echo "${{ secrets.NODE_TOOL_BACKEND_LOCAL_ENV }}" > .env.tool.backend | |
| echo "${{ secrets.NODE_FRONTEND_LOCAL_ENV }}" > ./frontend/.env.frontend | |
| # frontend๋ ํ์ํ๋ฉด ์ถ๊ฐ | |
| # docker-compose๋ฅผ ํ์ฉํด์ ํ๋ฒ์ buildํ๊ณ run | |
| - name: docker compose build and run | |
| run: | | |
| docker compose -f docker-compose.local.yml up -d | |
| # ํตํฉ ํ ์คํธ ์งํ | |
| - name: ํตํฉํ ์คํธ script ๊ถํ ๋ถ์ฌ | |
| working-directory: ./test/intergration-build-test | |
| run: | | |
| # ๋์ค์ ํตํฉํ ์คํธ ์ถ๊ฐ๋๋ฉด ์ฌ๊ธฐ์ ์ถ๊ฐํ๋ฉด ๋๋ค. | |
| chmod +x backend-intergration-test.sh | |
| chmod +x frontend-intergration-test.sh | |
| # ๋ฐฑ์๋ ํตํฉ ํ ์คํธ ์งํ | |
| - name: backend ํตํฉ ํ ์คํธ ์งํ | |
| working-directory: ./test/intergration-build-test | |
| run: ./backend-intergration-test.sh ${{ vars.MAIN_BACKEND_LOCAL_URL }} ${{ vars.TOOL_BACKEND_LOCAL_URL }} | |
| # ํ๋ก ํธ์๋ ํตํฉ ํ ์คํธ ์งํ | |
| - name: frontend ํตํฉ ํ ์คํธ ์งํ | |
| working-directory: ./test/intergration-build-test | |
| run: ./frontend-intergration-test.sh ${{ vars.FRONTEND_LOCAL_URL }} | |
| # ๋ง์ฝ ์๋ฌ๊ฐ ๋ฐ์ํ๋ฉด ์ฌ๊ธฐ์ ๋๋ฒ๊น ํด์ผ ํ๋ค. | |
| - name: docker ์๋ฌ ๋ก๊น | |
| if: failure() | |
| run: | | |
| docker ps -a | |
| echo "==== tool-backend logs ====" | |
| docker logs --tail=200 tool-backend-app || true | |
| echo "==== main-backend logs ====" | |
| docker logs --tail=200 main-backend-app || true | |
| echo "==== frontend logs ====" | |
| docker logs --tail=200 frontend || true |