From d28497b70b4c5c66ff59e95f1c657c118d27f0c0 Mon Sep 17 00:00:00 2001 From: Serena Li Date: Tue, 27 Jun 2023 19:35:36 -0400 Subject: [PATCH] attempt to add ci for frontend lint and tests --- .github/workflows/ci.yml | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dfd95fb5d..8b1a6ab3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,38 @@ env: CACHE_NUMBER: 1 jobs: + unit-test-frontend: + # Defines the type of runner the job runs on + runs-on: ubuntu-latest + steps: + - name: Checkout to the repository + uses: actions/checkout@v3 + - name: Set up NodeJS environment + uses: actions/setup-node@v3 + with: + node-version: '14' + # Consider this as an add on to optimize the execution of actions + - name: Cache node modules + id: cache-npm + uses: actions/cache@v3 + env: + cache-name: cache-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 }}- + - name: Install package dependencies + run: cd frontend2 && npm install + - name: Check linting and formatting + # Custom script for checking the linting and formatting being in place + run: cd frontend2 && npm run lint + # Run test cases and this could ensure minimum coverage as well if set + - name: Execute test cases + run: cd frontend2 && npm run test lint: name: Linter (pre-commit) runs-on: ubuntu-latest @@ -40,7 +72,7 @@ jobs: run: | pre-commit install pre-commit run -a - unit-test: + unit-test-backend: name: Unit tests (django) runs-on: ubuntu-latest permissions: