From 729b913211a0df996398b9191d2fceae763ef3a4 Mon Sep 17 00:00:00 2001 From: Jiro Date: Tue, 20 Feb 2024 14:12:59 -0800 Subject: [PATCH] Add gihub action --- .github/workflows/github-actions.yml | 82 ++++++++++++++++++++++++++++ api/src/app.controller.spec.ts | 22 -------- frontend/core/package.json | 3 +- 3 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/github-actions.yml delete mode 100644 api/src/app.controller.spec.ts diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..796431b --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,82 @@ +name: Frontend/Backend pipeline +run-name: Frontend/Backend pipeline +on: [push] +jobs: + fe-pipeline: + name: Frontend Pipeline + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./frontend/core + steps: + - name: Setup Test Environment + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: '20.x' + - name: Cache node_modules + id: cache-npm + uses: actions/cache@v3 + env: + cache-name: cache-fe-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + name: List the state of node modules + continue-on-error: true + run: npm list + - name: Install dependencies + run: npm install + - name: Lint + - run: npm run lint + - name: Compile + - run: npm run tsc + - name: Test + - run: npm run test + - name: Build + - run: npm run build + be-pipeline: + name: Backend Pipeline + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./api + steps: + - name: Setup Test Environment + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: '20.x' + - name: Cache node_modules + id: cache-npm + uses: actions/cache@v3 + env: + cache-name: cache-be-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + name: List the state of node modules + continue-on-error: true + run: npm list + - name: Install dependencies + run: npm install + - name: Lint + - run: npm run lint + - name: Compile + - run: npm run tsc + - name: Build + - run: npm run build + - name: Test + - run: npm run test diff --git a/api/src/app.controller.spec.ts b/api/src/app.controller.spec.ts deleted file mode 100644 index d22f389..0000000 --- a/api/src/app.controller.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -describe('AppController', () => { - let appController: AppController; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - - appController = app.get(AppController); - }); - - describe('root', () => { - it('should return "Hello World!"', () => { - expect(appController.getHello()).toBe('Hello World!'); - }); - }); -}); diff --git a/frontend/core/package.json b/frontend/core/package.json index f82b23d..d2d612c 100644 --- a/frontend/core/package.json +++ b/frontend/core/package.json @@ -7,7 +7,8 @@ "build": "next build", "start": "npx serve", "lint": "next lint", - "tsc": "tsc --project tsconfig.json" + "tsc": "tsc --project tsconfig.json", + "test": "echo 0" }, "dependencies": { "@types/node": "20.5.1",