@@ -237,6 +237,38 @@ function _install_packaged_cli_linux {
237237 export PATH=$AMPLIFY_DIR :$PATH
238238 cd $CODEBUILD_SRC_DIR
239239}
240+ function _convertCoverage {
241+ echo Convert Coverage
242+
243+ source .circleci/local_publish_helpers.sh && startLocalRegistry " $CODEBUILD_SRC_DIR /.circleci/verdaccio.yaml"
244+ setNpmRegistryUrlToLocal
245+ changeNpmGlobalPath
246+
247+ # needs to pick up the new coverage directory
248+ # for reference, assuming e2e tests are run from the amplify-e2e-tests directory:
249+ # .../$NODE_V8_COVERAGE - generated with setting NODE_V8_COVERAGE env var
250+ # .../coverage/<reporter> - generated with c8 command above
251+ loadCache e2e-test-coverage-raw $E2E_TEST_COVERAGE_DIR
252+ npx c8 report --temp-directory $E2E_TEST_COVERAGE_DIR --all --src ./packages -x " **/node_modules/**" -x " **/__tests__/**" --exclude-after-remap " **/node_modules/**" -x " **/amplify-e2e-*/**" -x " **/.yarn/**" --allow-external --reporter clover
253+ }
254+ # https://docs.codecov.com/docs/codecov-uploader#integrity-checking-the-uploader
255+ function _uploadCoverageLinux {
256+ if [ -z ${CODECOV_TOKEN+x} ]
257+ then
258+ echo " CODECOV_TOKEN not set: No coverage will be uploaded."
259+ else
260+ curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import # One-time step
261+ curl -Os https://uploader.codecov.io/latest/linux/codecov
262+ curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
263+ curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
264+ gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
265+ shasum -a 256 -c codecov.SHA256SUM
266+
267+ chmod +x codecov
268+ ./codecov -t ${CODECOV_TOKEN}
269+ fi
270+ }
271+ # END COVERAGE FUNCTIONS
240272function _runE2ETestsLinux {
241273 echo RUN E2E Tests Linux
242274
@@ -264,9 +296,17 @@ function _runE2ETestsLinux {
264296
265297 _loadTestAccountCredentials
266298
267- retry runE2eTest
299+ # retry runE2eTest
300+ runE2eTest
301+ _unassumeTestAccountCredentials
302+ storeCache $E2E_TEST_COVERAGE_DIR e2e-test-coverage-raw
303+ }
304+ function _unassumeTestAccountCredentials {
305+ echo " Unassume Role"
306+ unset AWS_ACCESS_KEY_ID
307+ unset AWS_SECRET_ACCESS_KEY
308+ unset AWS_SESSION_TOKEN
268309}
269-
270310
271311function _scanArtifacts {
272312 if ! yarn ts-node .circleci/scan_artifacts_codebuild.ts; then
0 commit comments