chore(ci): adds unit tests + coverage for deploy-web #2054
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate and Build Provider Proxy CI | |
on: | |
pull_request: | |
branches: ["main"] | |
push: | |
branches: ["main"] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-provider-proxy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Check for changes | |
- uses: dorny/paths-filter@v2 | |
if: github.event_name == 'pull_request' | |
id: has_changes | |
with: | |
filters: | | |
provider-proxy: | |
- 'apps/provider-proxy/**' | |
- 'packages/net/**' | |
- name: Decide whether to validate | |
id: validation | |
run: echo "enabled=${{ github.event_name == 'push' || steps.has_changes.outputs.provider-proxy == '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/provider-proxy/node_modules | |
packages/*/node_modules | |
key: provider-proxy-${{ 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/provider-proxy | |
- name: Run tests | |
if: steps.validation.outputs.enabled == 'true' | |
run: npm run test:cov --workspace=apps/provider-proxy | |
- name: Build the Docker image | |
if: steps.validation.outputs.enabled == 'true' && github.event_name == 'pull_request' | |
run: packages/docker/script/dc.sh build provider-proxy | |
- name: Upload Test Coverage | |
if: steps.validation.outputs.enabled == 'true' | |
uses: codecov/codecov-action@v5 | |
with: | |
directory: ./apps/provider-proxy/coverage | |
flags: provider-proxy | |
token: ${{ secrets.CODECOV_TOKEN }} | |
base_sha: ${{ github.event.pull_request.base.sha }} |