[MOB-11389] add-tests #7
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| merge_group: | |
| types: | |
| - checks_requested | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Lint files | |
| run: yarn lint | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Run unit tests with coverage | |
| run: yarn test:coverage --maxWorkers=2 | |
| - name: Check coverage thresholds | |
| run: | | |
| COVERAGE_THRESHOLD=80 | |
| COVERAGE=$(cat coverage/coverage-summary.json | jq -r '.total.lines.pct') | |
| if (( $(echo "$COVERAGE < $COVERAGE_THRESHOLD" | bc -l) )); then | |
| echo "Coverage ($COVERAGE%) is below threshold ($COVERAGE_THRESHOLD%)" | |
| exit 1 | |
| fi | |
| echo "Coverage ($COVERAGE%) is above threshold ($COVERAGE_THRESHOLD%)" | |
| - name: Upload coverage to Code Climate | |
| uses: paambaati/codeclimate-action@v9.0.0 | |
| env: | |
| CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_KEY }} | |
| with: | |
| coverageCommand: yarn test:coverage --coverageReporters lcov | |
| coverageLocations: | | |
| ${{github.workspace}}/coverage/lcov.info:lcov | |
| # - name: Upload coverage to Codecov | |
| # uses: codecov/codecov-action@v4 | |
| # with: | |
| # token: ${{ secrets.CODECOV_TOKEN }} | |
| # directory: ./coverage/ | |
| # flags: unittests | |
| # name: codecov-umbrella | |
| # fail_ci_if_error: true | |
| test-comment: | |
| name: Unit tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Run tests | |
| run: | | |
| yarn test:coverage --coverageReporters json-summary | |
| - name: Test coverage comment | |
| id: coverageComment | |
| uses: MishaKav/jest-coverage-comment@main | |
| with: | |
| hide-comment: false | |
| coverage-summary-path: ./coverage/coverage-summary.json | |
| build-library: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Setup | |
| uses: ./.github/actions/setup | |
| - name: Build package | |
| run: yarn prepare |