From 03422126972f9ab64fe90203cdbecfa1a9434538 Mon Sep 17 00:00:00 2001 From: Haifeng Li <168469994+haifeng-li-at-salesforce@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:02:31 -0800 Subject: [PATCH] Coverage report posted to codecov (#156) feat: add codecov tracking service --- .github/workflows/run-tests.yml | 80 ++++++++++++++++++--------------- README.md | 2 + codecov.yml | 18 ++++++++ test/suite/index.ts | 2 +- 4 files changed, 64 insertions(+), 38 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 5172f8b0..a52666db 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,40 +1,46 @@ name: run-tests run-name: Installs project and runs project tests -on: [ push, pull_request ] +on: [push, pull_request] jobs: - run-tests-nix: - runs-on: ubuntu-latest - strategy: - matrix: - node: [ 20, 22 ] - name: Tests with code coverage on Ubuntu with Node ${{ matrix.node }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - - run: | - npm install - npm run compile - # runtTests() which downloads/installs/launches VSCode requires a screen. - # Using xvfb-run to attach a virtual screen for CI running on Ubuntu. - xvfb-run --server-num=99 --server-args="-screen 0 1024x768x24" npm run test-coverage - shell: bash - - run: killall Xvfb || true - run-tests-win: - runs-on: windows-latest - strategy: - matrix: - node: [ 20, 22 ] - name: Tests with code coverage on Windows with Node ${{ matrix.node }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - - run: | - # On Windows there no need for a screen for runTests() to run successfully. - npm install - npm run compile - npm run test-coverage - - run: taskkill /IM Xvfb.exe /F || true + run-tests-nix: + runs-on: ubuntu-latest + strategy: + matrix: + node: [20, 22] + name: Tests with code coverage on Ubuntu with Node ${{ matrix.node }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - run: | + npm install + npm run compile + # runtTests() which downloads/installs/launches VSCode requires a screen. + # Using xvfb-run to attach a virtual screen for CI running on Ubuntu. + xvfb-run --server-num=99 --server-args="-screen 0 1024x768x24" npm run test-coverage + shell: bash + - run: killall Xvfb || true + - name: Upload coverage to codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage/*.json + flags: lsp,extension + run-tests-win: + runs-on: windows-latest + strategy: + matrix: + node: [20, 22] + name: Tests with code coverage on Windows with Node ${{ matrix.node }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - run: | + # On Windows there no need for a screen for runTests() to run successfully. + npm install + npm run compile + npm run test-coverage + - run: taskkill /IM Xvfb.exe /F || true diff --git a/README.md b/README.md index bb89b902..e2ba4b86 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![codecov](https://codecov.io/github/salesforce/salesforcedx-vscode-mobile/branch/main/graph/badge.svg?token=PDZHP80RNO)](https://codecov.io/github/salesforce/salesforcedx-vscode-mobile) + # Salesforce Mobile Extensions for Visual Studio Code This Visual Studio Code extension provides tools to help developers create their Salesforce Mobile experiences in the VSCode development environment. diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..14f642cc --- /dev/null +++ b/codecov.yml @@ -0,0 +1,18 @@ +# Copyright (c) 2024, salesforce.com, inc. +# All rights reserved. +# SPDX-License-Identifier: MIT +# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT +comment: + layout: 'header, diff, tree' + behavior: default + require_changes: false # if true: only post the comment if coverage changes + branches: null + flags: null + paths: null +flags: + extension: + paths: + - src/ + lsp: + paths: + - lsp/ diff --git a/test/suite/index.ts b/test/suite/index.ts index 9fccf327..3a13a82a 100644 --- a/test/suite/index.ts +++ b/test/suite/index.ts @@ -28,7 +28,7 @@ export async function run(): Promise { nyc = new NYC({ ...baseConfig, cwd: path.join(__dirname, '..', '..', '..'), - reporter: ['text-summary', 'html', 'text', 'lcov'], + reporter: ['text-summary', 'html', 'text', 'lcov', 'json'], all: true, silent: false, instrument: true,