Skip to content

Commit

Permalink
Add codecov for unit tests
Browse files Browse the repository at this point in the history
Issue: CLDSRV-594
  • Loading branch information
francoisferrand committed Dec 10, 2024
1 parent a06407d commit 99b36bc
Show file tree
Hide file tree
Showing 5 changed files with 772 additions and 443 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
cache: pip
- name: Install python deps
run: pip install flake8
- name: Lint Javascript
Expand All @@ -104,16 +101,24 @@ jobs:
- name: Unit Coverage
run: |
set -ex
mkdir -p $CIRCLE_TEST_REPORTS/unit
yarn test
yarn run test_legacy_location
yarn run cover test
yarn run cover test_legacy_location
env:
S3_LOCATION_FILE: tests/locationConfig/locationConfigTests.json
CIRCLE_TEST_REPORTS: /tmp
CIRCLE_ARTIFACTS: /tmp
CI_REPORTS: /tmp
- name: Unit Coverage logs
run: find /tmp/unit -exec cat {} \;
- name: Upload test results to Codecov
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: '**/*junit*.xml'
flags: unit
if: ${{ !cancelled() }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/test
flags: unit
if: ${{ !cancelled() }}
- name: preparing junit files for upload
run: |
mkdir -p artifacts/junit
Expand Down
10 changes: 10 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"all": true,
"include": [
"bin/**/*.js",
"lib/**/*.js"
],
"exclude": [
"tests/**/*.js"
]
}
38 changes: 38 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
parsers:
javascript:
enable_partials: yes

comment:
layout: newheader, reach, files, components, diff, flags # show component info in the PR comment
hide_comment_details: true # hide the comment details (e.g. coverage targets) in the PR comment

# Setting coverage targets
coverage:
status:
project:
default:
target: auto
threshold: 1%
removed_code_behavior: adjust_base
paths:
- bin
- lib
patch:
default:
target: 80%

component_management:
default_rules: # default rules that will be inherited by all components
statuses: []

flag_management:
default_rules: # the rules that will be followed for any flag added, generally
carryforward: true
statuses: []

# Do not consider zenko integration builds in coverage comparisons
flags:
zenko-end2end-sharded:
joined: false
zenko-ctst-end2end-sharded:
joined: false
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@
"eslint-plugin-mocha": "^10.1.0",
"express": "^4.17.1",
"ioredis": "4.9.5",
"istanbul": "1.0.0-alpha.2",
"istanbul-api": "1.0.0-alpha.13",
"lolex": "^1.4.0",
"mocha": "^2.3.4",
"mocha-junit-reporter": "^1.23.1",
"mocha-multi-reporters": "^1.1.7",
"node-mocks-http": "1.5.2",
"nyc": "^15.1.0",
"sinon": "^13.0.1",
"tv4": "^1.2.7"
},
Expand Down Expand Up @@ -116,7 +115,7 @@
"test_utapi_v2": "mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/utapi",
"test_quota": "mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/quota",
"multiple_backend_test": "CI=true S3BACKEND=mem S3DATA=multiple mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json -t 20000 --recursive tests/multipleBackend",
"unit_coverage": "CI=true mkdir -p coverage/unit/ && S3BACKEND=mem istanbul cover --dir coverage/unit _mocha -- --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/unit",
"unit_coverage_legacy_location": "CI=true mkdir -p coverage/unitlegacylocation/ && S3_LOCATION_FILE=tests/locationConfig/locationConfigLegacy.json S3BACKEND=mem istanbul cover --dir coverage/unitlegacylocation _mocha -- --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --reporter mocha-junit-reporter --recursive tests/unit"
"cover": "nyc --clean --silent yarn run",
"postcover": "nyc report --report-dir ./coverage/test --reporter=lcov"
}
}
Loading

0 comments on commit 99b36bc

Please sign in to comment.