From c7eb33164536d4ceb258f73cba46957da724fa81 Mon Sep 17 00:00:00 2001 From: mathieudi Date: Wed, 11 Dec 2024 15:54:54 +0100 Subject: [PATCH 1/2] Revert "fix: Revert "feat: remove coverall upload + upload summary to Cloud Storage"" --- .../workflows/check-nodejs-dependencies.yml | 4 +-- .github/workflows/release_library.yml | 31 ++++++++++++++++--- .github/workflows/verify_library.yml | 6 ---- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.github/workflows/check-nodejs-dependencies.yml b/.github/workflows/check-nodejs-dependencies.yml index 9e7d401..a6babac 100644 --- a/.github/workflows/check-nodejs-dependencies.yml +++ b/.github/workflows/check-nodejs-dependencies.yml @@ -29,7 +29,7 @@ on: required: false type: string secrets: - DEPENDENCY_STATS_SERVICE_ACCOUNT: + LIBRARY_CI_SERVICE_ACCOUNT: required: true NPM_READ_TOKEN: required: true @@ -87,7 +87,7 @@ jobs: uses: google-github-actions/auth@v2 with: project_id: reside-stage - credentials_json: ${{ secrets.DEPENDENCY_STATS_SERVICE_ACCOUNT }} + credentials_json: ${{ secrets.LIBRARY_CI_SERVICE_ACCOUNT }} # setup-gcloud without components is required to have the proper authentication for gsutil commands - name: Set up Google Cloud CLI diff --git a/.github/workflows/release_library.yml b/.github/workflows/release_library.yml index 08c912d..ddc8616 100644 --- a/.github/workflows/release_library.yml +++ b/.github/workflows/release_library.yml @@ -45,7 +45,7 @@ on: required: true NPM_READ_TOKEN: required: true - DEPENDENCY_STATS_SERVICE_ACCOUNT: + LIBRARY_CI_SERVICE_ACCOUNT: required: true #Secret needed when ENABLE_VISUAL_TESTING = true: # - SIDE_CI_APPLICATION_ID @@ -67,6 +67,8 @@ jobs: name: release runs-on: ubuntu-latest timeout-minutes: ${{ inputs.TIMEOUT }} + env: + SERVICE_NAME: ${{ github.event.repository.name }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -102,11 +104,30 @@ jobs: if: inputs.ENABLE_TESTING && inputs.ENABLE_COVERAGE run: yarn test:cov - - name: Upload coverage to Coveralls + - name: Authenticate with Google Cloud if: inputs.ENABLE_TESTING && inputs.ENABLE_COVERAGE - uses: coverallsapp/github-action@v2.3.4 + uses: google-github-actions/auth@v2 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + project_id: reside-stage + credentials_json: ${{ secrets.LIBRARY_CI_SERVICE_ACCOUNT }} + + # setup-gcloud without components is required to have the proper authentication for gsutil commands + - name: Set up Google Cloud CLI + if: inputs.ENABLE_TESTING && inputs.ENABLE_COVERAGE + uses: google-github-actions/setup-gcloud@v2 + with: + install_components: '' + + - name: Upload coverage summary + if: inputs.ENABLE_TESTING && inputs.ENABLE_COVERAGE + run: | + coverage_summary="./coverage/coverage-summary.json" + bucket=reside-stage-plat-tools + summaryFolder=coverage-reporting/summary + + gsutil -m -q cp $coverage_summary gs://$bucket/$summaryFolder/$SERVICE_NAME/$(date +%Y-%m-%d_%H-%M-%S).json + gsutil -m -q cp $coverage_summary gs://$bucket/$summaryFolder/$SERVICE_NAME/latest.json + echo "Coverage summary file uploaded successfully" - name: Build app if: inputs.ENABLE_BUILDING @@ -200,7 +221,7 @@ jobs: NODE_VERSION: ${{ inputs.NODE_VERSION }} secrets: NPM_READ_TOKEN: ${{ secrets.NPM_READ_TOKEN }} - DEPENDENCY_STATS_SERVICE_ACCOUNT: ${{ secrets.DEPENDENCY_STATS_SERVICE_ACCOUNT }} + LIBRARY_CI_SERVICE_ACCOUNT: ${{ secrets.LIBRARY_CI_SERVICE_ACCOUNT }} notification: if: always() && inputs.ENABLE_SLACK_NOTIFICATION diff --git a/.github/workflows/verify_library.yml b/.github/workflows/verify_library.yml index 188e165..7ba7023 100644 --- a/.github/workflows/verify_library.yml +++ b/.github/workflows/verify_library.yml @@ -111,12 +111,6 @@ jobs: if: inputs.ENABLE_TESTING && inputs.ENABLE_COVERAGE run: yarn test:cov - - name: Upload coverage to Coveralls - if: inputs.ENABLE_TESTING && inputs.ENABLE_COVERAGE - uses: coverallsapp/github-action@v2.3.4 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Build app if: inputs.ENABLE_BUILDING run: yarn build From bc05e3a2e82dfd714eeb0507c2349f1b320481b2 Mon Sep 17 00:00:00 2001 From: mdimajo Date: Wed, 11 Dec 2024 15:58:16 +0100 Subject: [PATCH 2/2] fix: produce coverage summary if doesn't exist --- .github/workflows/release_library.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release_library.yml b/.github/workflows/release_library.yml index ddc8616..f77819f 100644 --- a/.github/workflows/release_library.yml +++ b/.github/workflows/release_library.yml @@ -122,6 +122,11 @@ jobs: if: inputs.ENABLE_TESTING && inputs.ENABLE_COVERAGE run: | coverage_summary="./coverage/coverage-summary.json" + + if [ ! -f "$coverage_summary" ]; then + npx nyc report --reporter=json-summary -t coverage + fi + bucket=reside-stage-plat-tools summaryFolder=coverage-reporting/summary