@@ -730,6 +730,47 @@ functions:
730730 params:
731731 file: "src/xunit.xml"
732732
733+ "upload coverage report":
734+ - command: shell.exec
735+ params:
736+ working_dir: "src"
737+ script: |
738+ ${PREPARE_SHELL}
739+ npx nyc report --reporter=json
740+ - command: s3.put
741+ params:
742+ aws_key: ${aws_key}
743+ aws_secret: ${aws_secret}
744+ local_file: src/coverage/coverage-final.json
745+ optional: true
746+ # Upload the coverage report for all tasks in a single build to the same directory.
747+ # TODO NODE-3897 - change upload directory to mongo-node-driver-next
748+ # This change will require changing the `download and merge coverage` func as well
749+ remote_file: mongo-node-driver/${revision}/${version_id}/coverage.${build_variant}.${task_name}.json
750+ bucket: mciuploads
751+ permissions: public-read
752+ content_type: application/json
753+ display_name: "Raw Coverage Report"
754+
755+ "download and merge coverage":
756+ - command: shell.exec
757+ params:
758+ silent: true
759+ working_dir: "src"
760+ script: |
761+ ${PREPARE_SHELL}
762+ export AWS_ACCESS_KEY_ID=${aws_key}
763+ export AWS_SECRET_ACCESS_KEY=${aws_secret}
764+ # Download all the task coverage files.
765+ # TODO NODE-3897 - finish this function. the code below this point is untested because
766+ # aws s3 cp fails due to permissions errors
767+ aws s3 cp --recursive s3://mciuploads/mongo-node-driver/${revision}/${version_id}/ coverage/
768+
769+ npx nyc merge coverage/ merged-coverage/coverage.json
770+ npx nyc report -t merged-coverage --reporter=html --report-dir output
771+
772+ aws s3 cp output/lcov-report s3://mciuploads/mongo-node-driver/${revision}/${version_id}//lcov-report/
773+
733774tasks:
734775 - name: "test-serverless"
735776 tags: ["serverless"]
781822
782823post:
783824 - func: "upload test results"
825+ - func: "upload coverage report"
784826 - func: "cleanup"
785827
786828ignore:
0 commit comments