From 8e46c6dce8f38a1341731d7c30041a73a9f3abf5 Mon Sep 17 00:00:00 2001 From: Hui Zhao Date: Mon, 22 Jan 2024 12:36:57 -0800 Subject: [PATCH] chore: enable codecov --- .../workflows/callable-get-package-list.yml | 6 ++--- .github/workflows/callable-unit-tests.yml | 24 +++++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/callable-get-package-list.yml b/.github/workflows/callable-get-package-list.yml index 5dc99ed11a9..d524cd24a71 100644 --- a/.github/workflows/callable-get-package-list.yml +++ b/.github/workflows/callable-get-package-list.yml @@ -24,14 +24,14 @@ jobs: env: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 - name: Install - if: steps.cache-package-list.outputs.cache-hit != 'true' + # if: steps.cache-package-list.outputs.cache-hit != 'true' run: yarn shell: bash # Need the repo checked out in order to read the file - name: Dump Package List - if: steps.cache-package-list.outputs.cache-hit != 'true' + # if: steps.cache-package-list.outputs.cache-hit != 'true' run: | - echo "packages=$(yarn lerna ls | egrep -v "lerna|Done|yarn" | jq -R -s -c 'split("\n")[:-1]')" > package-list.json + echo "packages=$(yarn lerna ll | egrep -v "lerna|Done|yarn" | jq -R -s -c 'split("\n")[:-1] | map({name: split(" ")[0], path: split(" ")[-1]})')" > package-list.json - name: Get Package List id: get_package_list run: | diff --git a/.github/workflows/callable-unit-tests.yml b/.github/workflows/callable-unit-tests.yml index 27437660e45..44d91b67464 100644 --- a/.github/workflows/callable-unit-tests.yml +++ b/.github/workflows/callable-unit-tests.yml @@ -6,7 +6,7 @@ jobs: get-package-list: uses: ./.github/workflows/callable-get-package-list.yml unit_test: - name: Unit Test - ${{ matrix.package }} + name: Unit Test - ${{ matrix.package.name }} runs-on: ubuntu-latest needs: get-package-list strategy: @@ -23,5 +23,25 @@ jobs: - name: Run tests working-directory: ./amplify-js env: - TEST_PACKAGE: ${{ matrix.package }} + TEST_PACKAGE: ${{ matrix.package.name }} run: npx lerna exec --scope $TEST_PACKAGE yarn test + - name: Check coverage report existence + id: check-report + env: + PACKAGE_PATH: ${{ matrix.package.path }} + run: | + if [ -f ./amplify-js/$PACKAGE_PATH/coverage/coverage-final.json ]; then + echo "SHOULD_UPLOAD_REPORT=true" >> $GITHUB_OUTPUT; + fi + - name: Get coverage report flag + if: steps.check-report.outputs.SHOULD_UPLOAD_REPORT == 'true' + env: + PACKAGE_PATH: ${{ matrix.package.path }} + id: split-path + run: echo "REPORT_FLAG=${PACKAGE_PATH##*/}" >> $GITHUB_OUTPUT + - name: Upload coverage report + if: steps.check-report.outputs.SHOULD_UPLOAD_REPORT == 'true' + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d + with: + files: ./amplify-js/${{ matrix.package.path }}/coverage/coverage-final.json + flags: ${{ steps.split-path.outputs.REPORT_FLAG }}