Skip to content

chore(ci): adds unit tests + coverage for deploy-web #1804

chore(ci): adds unit tests + coverage for deploy-web

chore(ci): adds unit tests + coverage for deploy-web #1804

name: Deploy Web CI
on:
pull_request:
branches: ["main"]
push:
branches: ["main"]
jobs:
build-deploy-web:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Check for changes in deploy-web folder
- uses: dorny/paths-filter@v2
id: has_changes
with:
filters: |
deploy-web:
- 'apps/deploy-web/**'
- 'packages/*/**'
- name: Decide whether to validate
id: validation
run: echo "enabled=${{ github.event_name == 'push' || steps.has_changes.outputs.deploy-web == 'true' }}" >> $GITHUB_OUTPUT
- name: Setup Node.js
if: steps.validation.outputs.enabled == 'true'
uses: actions/setup-node@v4
with:
node-version: 20.14.0
- name: Restore root node_modules cache
if: steps.validation.outputs.enabled == 'true'
uses: actions/cache@v4
id: cache
with:
path: |
node_modules
apps/deploy-web/node_modules
packages/*/node_modules
key: deploy-web-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.validation.outputs.enabled == 'true' && steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Run static code analysis
if: steps.validation.outputs.enabled == 'true'
run: npm run lint -w apps/deploy-web
- name: Run tests
if: steps.validation.outputs.enabled == 'true'
run: npm run test:cov --workspace=apps/deploy-web
- name: Upload Test Coverage
if: steps.validation.outputs.enabled == 'true'
uses: codecov/codecov-action@v5
with:
directory: ./apps/deploy-web/coverage
flags: deploy-web
token: ${{ secrets.CODECOV_TOKEN }}
base_sha: ${{ github.event.pull_request.base.sha }}
- name: Build the Docker image
if: steps.validation.outputs.enabled == 'true' && github.event_name == 'pull_request'
run: packages/docker/script/dc.sh build deploy-web --build-arg DEPLOYMENT_ENV=production