Breaking: DeepSource Test coverage GitHub Action

After a recent change in git, DeepSource’s GitHub action to report the test coverage report to the coverage Analyzer has been broken.

All GitHub actions are containers inside the top-level machine. The DeepSource CLI internally executes git commands to look up the HEAD commit to associate the test coverage artifact.

After the recent git change, executing any git command inside an action is no longer possible because the ownership changes, and git errors out with the following:

fatal: detected dubious ownership in repository at '/github/workspace'
To add an exception for this directory, call:

	git config --global --add safe.directory /github/workspace

This is causing the DeepSource test coverage action to exit with a status code that will fail your CI.

If you’re using the Test coverage action, we recommend switching to using the DeepSource CLI directly. To do this, you’ll need to make the following changes:

steps:
    - name: Checkout code
      uses: actions/checkout@v2
      with:
        ref: ${{ github.event.pull_request.head.sha }}


    # Run your tests here ...

    - 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 <language> --value-file <path/to/coverage/file>

If you want to continue using the Test coverage action, please follow these steps to make it work again:

steps:
    - name: Checkout code
      uses: actions/checkout@v2
      with:
        fetch-depth: 50
        ref: ${{ github.event.pull_request.head.sha }}

    # ADD THIS STEP
    - name: Add git safe.directory for container
      run: |
        mkdir -p /home/runner/work/_temp/_github_home
        printf "[safe]\ndirectory = /github/workspace" > /home/runner/work/_temp/_github_home/.gitconfig

    - name: Report test-coverage to DeepSource
      uses: deepsourcelabs/test-coverage-action@master
      with:
        ... The rest of your config remains the same

1 Like

Update: We have updated the Test coverage GitHub action to work without making any additional changes mentioned in the post above.

The changes were released in v1.1.1. If you’re on a previous version, it is recommended to update your GitHub workflow to use the latest version.

We have also removed the deprecation notice from the action.

1 Like