What is wrong with my CodeCov Uploader configuration?


I want to configure CodeCov to measure both Unit Tests and Integration Tests coverage. I have read Flags and Codecov Uploader documentation which was both very helpful.
Thanks to them I configured my CI (GitHub Actions) with following job:

    runs-on: ubuntu-latest

      - uses: actions/checkout@v2

      - name: Set up Python 3.9
        uses: actions/setup-python@v1
          python-version: 3.9

      - name: Install project dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install --upgrade setuptools
          pip install -r requirements.txt

      - name: Install external packages used for dynamic tests
        run: |
          pip install -r tests/requirements_for_software_tests.txt

      - name: Prepare coverage uploader [CodeCov]
        run: |
          curl -Os https://app.codecov.io/gh/mdabrowski1990/uds/uploader/linux/codecov
          chmod +x codecov

      - name: Execute unit tests [pytest]
        run: |
          pytest --cov-report=xml --cov=uds tests/software_tests -m "not integration"

      - name: Upload unit tests results [codecov]
        run: |
          ./codecov -t ${{ secrets.CODECOV_TOKEN }} --url https://app.codecov.io/gh/mdabrowski1990/uds/ -F unit-tests -f coverage.xml

      - name: Execute integration tests [pytest]
        run: |
          pytest --cov-report=xml --cov=uds tests/software_tests -m "integration"

      - name: Upload unit tests results [codecov]
        run: |
          ./codecov -t ${{ secrets.CODECOV_TOKEN }} --url https://app.codecov.io/gh/mdabrowski1990/uds/ -F integration-tests -f coverage.xml


Codecov Output

This is the output I see when I try to upload the coverage results

GitHub Actions Log:

2021-12-03T12:55:59.4466456Z ##[group]Run ./codecov -t ${CODECOV_TOKEN} --url https://app.codecov.io/gh/mdabrowski1990/uds/ -F unit-tests -f coverage.xml
2021-12-03T12:55:59.4467776Z e[36;1m./codecov -t ${CODECOV_TOKEN} --url https://app.codecov.io/gh/mdabrowski1990/uds/ -F unit-tests -f coverage.xmle[0m
2021-12-03T12:55:59.4509201Z shell: /usr/bin/bash -e {0}
2021-12-03T12:55:59.4509577Z env:
2021-12-03T12:55:59.4510101Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.9/x64
2021-12-03T12:55:59.4510651Z ##[endgroup]
2021-12-03T12:55:59.4593950Z ./codecov: line 1: syntax error near unexpected token `<'
2021-12-03T12:55:59.4597034Z ./codecov: line 1: `<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>Codecov</title><script>;(function(w, d, s, l, i) {'
2021-12-03T12:55:59.4607875Z ##[error]Process completed with exit code 2.

Expected Results

I would like to have results uploaded to CodeCov during the job.

Actual Results

GitHub actions job raises an error due to (what seems to be) “TOKEN” issue :frowning:

Additional Information

Link to my project on CodeCov: Codecov
I have my CodeCov token configured in GitHub and named CODECOV_TOKEN
I send report in Cobertura XML (XML output from pytest-cov is Cobertura, isn’t it?) format (which seems to be supported Supported Coverage Report Formats)

PS. I am new to CodeCov so please forgive me if I made some rookie mistake.

My CodeCov token on GitHub:

@mdabrowski1990 I think it needs to be secrets.CODECOV_TOKEN

I have managed to work it around:

      - name: Upload integration tests report [CodeCov]
        uses: codecov/codecov-action@v2
          token: ${{ secrets.CODECOV_TOKEN }}
          files: coverage.xml
          flags: integration-tests

It is not longer a problem for me.

1 Like