From 23fbfdc6bee4f7cd6d6a1197f002ab8aa6502602 Mon Sep 17 00:00:00 2001 From: Manuel Date: Sat, 1 Apr 2023 12:21:37 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Add=20test=20coverage=20for=20de?= =?UTF-8?q?epsource?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .deepsource.toml | 6 ++- .github/workflows/deepsource-tests.yml | 58 ++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deepsource-tests.yml diff --git a/.deepsource.toml b/.deepsource.toml index 2ebcef1..0c1cb01 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -7,4 +7,8 @@ name = "javascript" plugins = ["react"] [[analyzers]] -name = "docker" \ No newline at end of file +name = "docker" + +[[analyzers]] +name = "test-coverage" +enabled = true \ No newline at end of file diff --git a/.github/workflows/deepsource-tests.yml b/.github/workflows/deepsource-tests.yml new file mode 100644 index 0000000..703f3fa --- /dev/null +++ b/.github/workflows/deepsource-tests.yml @@ -0,0 +1,58 @@ +name: Deepsource report test coverage +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +on: + push: + branches: [dev,master] + paths-ignore: + - '.github/**' + - 'images/' + - '*.md' + pull_request: + branches: + - master + - dev + + workflow_dispatch: + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: + report-test-coverage: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Setup + uses: actions/setup-node@v3 + - name: Checkout + uses: actions/checkout@v3 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + - uses: actions/cache@v3 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - run: yarn install --immutable + - run: yarn test:cov + - run: curl https://deepsource.io/cli | sh + - name: Report test-coverage to DeepSource + run: | + # Install the CLI + curl https://deepsource.io/cli | sh + + # Send the report to DeepSource + ./bin/deepsource report --analyzer test-coverage --key javascript --value-file ./coverage/clover.xml + env: + DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} \ No newline at end of file