diff --git a/.github/workflows/Backend_CI.yml b/.github/workflows/Backend_CI.yml index cbb255ff..294d7cbd 100644 --- a/.github/workflows/Backend_CI.yml +++ b/.github/workflows/Backend_CI.yml @@ -1,12 +1,10 @@ name: Backend Services CI # targeting pull requests to master branch on: - pull_request: - branches: [master] - push: - branches: [master] + workflow_call: jobs: - tests: + Backend_build: + name: Backend build permissions: checks: write pull-requests: write @@ -38,18 +36,43 @@ jobs: cmd: install dir: backend/${{matrix.service}} - - name: Run Test Suites + - name: Run Yarn Build env: NODE_ENV: test uses: borales/actions-yarn@v4 with: - cmd: test + cmd: build dir: backend/${{matrix.service}} + Backend_tests: + name: Backend tests + needs: Backend_build + permissions: + checks: write + pull-requests: write + contents: write + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [ubuntu-latest] + node-version: [20.x] + service: [assignment-service, grading-service, user-service] - - name: Run Yarn Build - env: - NODE_ENV: test + steps: + - name: Checkout Current Branch + uses: actions/checkout@v4 + + - name: Use Node.js ${{matrix.node-version}} + uses: actions/setup-node@v3 + with: + node-version: ${{matrix.node-version}} + + - name: Clean up + run: | + rm -rf backend/${{matrix.service}}/node_modules + rm -rf backend/${{matrix.service}}/coverage + + - name: Install Dependencies Using yarn uses: borales/actions-yarn@v4 with: - cmd: build + cmd: install dir: backend/${{matrix.service}} diff --git a/.github/workflows/CD_to_AKS.yml b/.github/workflows/CD_to_AKS.yml index 765462b4..6247f99c 100644 --- a/.github/workflows/CD_to_AKS.yml +++ b/.github/workflows/CD_to_AKS.yml @@ -1,10 +1,7 @@ name: Build and deploy an app to AKS on: - pull_request: - types: [closed] - branches: - - master + workflow_call: workflow_dispatch: env: diff --git a/.github/workflows/Overall_CI.yml b/.github/workflows/Overall_CI.yml new file mode 100644 index 00000000..86807edb --- /dev/null +++ b/.github/workflows/Overall_CI.yml @@ -0,0 +1,18 @@ +name: Overall CI +# targeting pull requests to master branch +on: + workflow_call: + pull_request: + branches: [master] + push: + branches: [master] +jobs: + frontend_ci: + uses: ./.github/workflows/frontend_CI.yml + backend_ci: + uses: ./.github/workflows/Backend_CI.yml + deploy_production: + name: Deploy Production + needs: [frontend_ci, backend_ci] + if: github.repository == 'CS3213-Frontend-Management-System/master' && github.ref_type == 'tag' + uses: ./.github/workflows/CD_to_AKS.yml diff --git a/.github/workflows/frontend_CI.yml b/.github/workflows/frontend_CI.yml index 91849b23..78b11cd0 100644 --- a/.github/workflows/frontend_CI.yml +++ b/.github/workflows/frontend_CI.yml @@ -1,12 +1,8 @@ name: Frontend CI -# targeting pull requests to master branch on: - pull_request: - branches: [master] - push: - branches: [master] + workflow_call: jobs: - tests: + Frontend_build: permissions: checks: write pull-requests: write @@ -35,18 +31,51 @@ jobs: with: cmd: install dir: frontend - - - name: Run Test Suites + - name: Run Next Build env: NODE_ENV: test uses: borales/actions-yarn@v4 with: - cmd: test + cmd: build dir: frontend - - name: Run Next Build + + Frontend_tests: + name: Frontend Tests + needs: Frontend_build + permissions: + checks: write + pull-requests: write + contents: write + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [ubuntu-latest] + node-version: [20.x] + + steps: + - name: Checkout Current Branch + uses: actions/checkout@v4 + + - name: Use Node.js ${{matrix.node-version}} + uses: actions/setup-node@v3 + with: + node-version: ${{matrix.node-version}} + + - name: Clean up + run: | + rm -rf frontend/node_modules + rm -rf frontend/coverage + - name: Install Dependencies Using yarn + uses: borales/actions-yarn@v4 + with: + cmd: install + dir: frontend + + - name: Run Test Suites env: NODE_ENV: test uses: borales/actions-yarn@v4 with: - cmd: build - dir: frontend \ No newline at end of file + cmd: test + dir: frontend + \ No newline at end of file