Skip to content

Commit

Permalink
Merge branch 'main' into task/BRE-141
Browse files Browse the repository at this point in the history
  • Loading branch information
urbinaalex17 authored Aug 30, 2024
2 parents c83ee5c + d01522b commit 94382b3
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 18 deletions.
68 changes: 52 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
---
name: Run tests
name: Testing

on:
workflow_dispatch:
push:
branches:
- "main"
pull_request: {}

defaults:
run:
shell: bash
pull_request:

jobs:
test:
check-test-secrets:
name: Check for test secrets
runs-on: ubuntu-22.04
outputs:
available: ${{ steps.check-test-secrets.outputs.available }}
permissions:
contents: read

steps:
- name: Check
id: check-test-secrets
run: |
if [ "${{ secrets.CODECOV_TOKEN }}" != '' ]; then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
testing:
name: Run tests
if: ${{ startsWith(github.head_ref, 'version_bump_') == false }}
runs-on: ubuntu-22.04
needs: check-test-secrets
permissions:
checks: write
contents: read
pull-requests: write

steps:
- name: Checkout repo
- name: Check out repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Get Node Version
- name: Get Node version
id: retrieve-node-version
run: |
NODE_NVMRC=$(cat .nvmrc)
Expand All @@ -34,11 +54,6 @@ jobs:
cache-dependency-path: '**/package-lock.json'
node-version: ${{ steps.retrieve-node-version.outputs.node_version }}

- name: Print environment
run: |
node --version
npm --version
- name: Install Node dependencies
run: npm ci

Expand All @@ -49,4 +64,25 @@ jobs:
run: npm run test:types --coverage

- name: Run tests
run: npm run test
run: npm run test --coverage

- name: Report test results
uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1
if: ${{ needs.check-test-secrets.outputs.available == 'true' && !cancelled() }}
with:
name: Test Results
path: "junit.xml"
reporter: jest-junit
fail-on-error: true

- name: Upload coverage to codecov.io
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
if: ${{ needs.check-test-secrets.outputs.available == 'true' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Upload results to codecov.io
uses: codecov/test-results-action@1b5b448b98e58ba90d1a1a1d9fcb72ca2263be46 # v1.0.0
if: ${{ needs.check-test-secrets.outputs.available == 'true' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ module.exports = {
// ...angularPreset,
preset: "jest-preset-angular",

reporters: ["default", "jest-junit"],

collectCoverage: true,
// Ensure we collect coverage from files without tests
collectCoverageFrom: ["src/**/*.ts"],
coverageReporters: ["html", "lcov"],
coverageDirectory: "coverage",

testEnvironment: "jsdom",
testMatch: ["**/+(*.)+(spec).+(ts)"],

Expand Down
28 changes: 26 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"html-webpack-plugin": "5.6.0",
"husky": "9.0.10",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"jest-preset-angular": "13.1.1",
"lint-staged": "15.2.0",
"mini-css-extract-plugin": "2.7.7",
Expand Down

0 comments on commit 94382b3

Please sign in to comment.