Skip to content

Added swagger docs. Refactored code and tests. #211

Added swagger docs. Refactored code and tests.

Added swagger docs. Refactored code and tests. #211

Workflow file for this run

name: Tests with Coverage Check
on:
push:
branches:
# - '*'
- 'main'
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Run Jest Tests
run: yarn test --collectCoverage=false
# coverage:
# runs-on: ubuntu-latest
# needs: test
# steps:
# # - name: For act to work (local testing)
# # run: npm -g install yarn
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0 # Fetch all history for accurate comparison
# - name: Setup Node
# uses: actions/setup-node@v3
# with:
# node-version: '18'
# cache: 'yarn'
# - name: Install Dependencies
# run: yarn install --frozen-lockfile
# - name: Checkout Main Branch
# uses: actions/checkout@v3
# with:
# ref: main
# path: main
# - name: Temp - Install Jest
# run: yarn add jest
# - name: Run Jest Coverage for Main
# working-directory: main
# run: yarn test --coverage
# - name: Run Jest Coverage for Current Branch
# run: yarn test --coverage
# - name: Get Coverage Difference
# id: coverage-difference
# run: |
# if [[ -f ./coverage/lcov.info ]] && [[ -f ./main/coverage/lcov.info ]]; then
# echo "Current Coverage:"
# currentCoverage=$(cat ./coverage/lcov.info | yarn jest-coverage-badges -r lcov | grep -oP '(?<=coverage: )\d+')
# echo "$currentCoverage"
# echo "Main Coverage:"
# mainCoverage=$(cat ./main/coverage/lcov.info | yarn jest-coverage-badges -r lcov | grep -oP '(?<=coverage: )\d+')
# echo "$mainCoverage"
# diff=$(echo "$mainCoverage" "$currentCoverage" | awk '{print ($2-$1)}')
# echo "::set-output name=diff::$diff"
# else
# echo "One or both coverage reports are missing. Skipping comparison."
# echo "::set-output name=diff::0" # Treat missing reports as no change
# fi
# - name: Fail if Coverage Decreased
# if: steps.coverage-difference.outputs.diff < 0
# run: |
# echo "🛑 Coverage decreased compared to main!"
# exit 1
# - name: Upload Coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# - name: Coverage Summary
# run: |
# echo "✅ Jest coverage passed with:"
# echo "$(cat ./coverage/lcov.info | yarn jest-coverage-badges -r lcov)"
# echo "View detailed coverage report on Codecov."