Skip to content

Commit

Permalink
Streamline github actions (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillCWX authored Apr 18, 2024
1 parent 30bbdb2 commit 92b01a4
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 27 deletions.
45 changes: 34 additions & 11 deletions .github/workflows/Backend_CI.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}}
5 changes: 1 addition & 4 deletions .github/workflows/CD_to_AKS.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Build and deploy an app to AKS

on:
pull_request:
types: [closed]
branches:
- master
workflow_call:
workflow_dispatch:

env:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/Overall_CI.yml
Original file line number Diff line number Diff line change
@@ -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
53 changes: 41 additions & 12 deletions .github/workflows/frontend_CI.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
cmd: test
dir: frontend

0 comments on commit 92b01a4

Please sign in to comment.