Skip to content

Update main.yaml

Update main.yaml #4621

Workflow file for this run

name: CI
on:
push:
branches: [main, develop, feature/enhancing-test-and-build-speed]
pull_request:
branches: [main, develop, 'feature/**']
jobs:
tests:
strategy:
matrix:
shardIndex: [1, 2, 3, 4, 5, 6]
shardTotal: [6]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.15.1
cache: 'npm'
- name: Install dependency
run: npm install
- name : Test
run: npx cross-env CI=true vitest --minWorkers 3 --maxWorkers 4 run --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --coverage
- run: ls -la
- run: mkdir -p coverage/lcov
- run: mkdir -p coverage/xml
- run: ls -la coverage
- name: Move coverage report
run: mv ./tests/coverage/lcov.info coverage/lcov/${{matrix.shardIndex}}.info
- name: Move coverage report
run: mv ./test-report.xml coverage/xml/${{matrix.shardIndex}}.xml
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: coverage-artifacts
path: coverage/
# - name: Upload blob report to GitHub Actions Artifacts
# if: ${{ !cancelled() }}
# uses: actions/upload-artifact@v4
# with:
# name: blob-report-${{ matrix.shardIndex }}
# path: .vitest-reports/*
# include-hidden-files: true
# retention-days: 1
merge-reports:
if: ${{ !cancelled() }}
needs: [tests]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download coverage artifacts
uses: actions/download-artifact@v3
with:
name: coverage-artifacts
path: coverage
- name: Verify coverage directory contents
run: ls -la coverage/xml
- name: Verify coverage directory contents
run: ls -la coverage/lcov
- name: Run script to merge all the xml files
run: |
echo '<testExecutions version="1">' > test-report.xml
grep -v testExecutions coverage/xml/*.xml >> test-report.xml
echo '</testExecutions>' >> test-report.xml
cat test-report.xml
- name: Run script to merge all the lcov files
run: npx lcov-result-merger coverage/lcov/*.info ./tests/coverage/lcov.info
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
if: success() || failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Test_Docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Dockerfile.stage
uses: docker/build-push-action@v6
with:
push: false
file: ./docker/Dockerfile.stage
cache-from: type=gha
cache-to: type=gha, mode=max
tags: ci-dockerfile:stage
build-args: |
NGINX_VERSION=1.19.6
PROXY_API_URL=${secrets.API_URL}
password=${secrets.SERVER_PASS}