Upload multiple files to codecov

Before submitting a topic, please confirm the following

I have searched for similar issues before creating this topic.
I have verified that my repository is using the Codecov GitHub app, if using GitHub
I have validated my codecov.yaml configuration file.
I have filled out the below sections to the best of my ability.

Description

Hi, i have an issue regarding “uploading multiple code coverage reports” to a codecov.
The issue is happening when i want to do a parallel runs into CircleCI, files are created, stored by node, and can not be uploaded (each 10 in my case, only first one). Is there a way to upload multiple files, as file pattern (you will see example in yaml file)?

Here is my codecov.yml

orbs: # declare what orbs we are going to use
  node: circleci/node@3.0.1 # the node orb provides common node-related configuration
  codecov: codecov/codecov@3.2.3

version: 2.1 # using 2.1 provides access to orbs and other features

jobs:
  build-and-test:
    parallelism: 10
    executor: node/default
    steps:
      - checkout
      - node/install-packages:
          cache-path: ~/project/node_modules
          override-ci-command: npm install
      - run:
          name: Compile
          command: |
            npx hardhat compile --showsize --optimizer
      - run:
          name: Tests
          command: |
            npx hardhat test --optimizer
      - run:
          name: Create shared coverage outputs folder
          command: mkdir -p /tmp/coverage
      - run:
          name: Coverage
          command: |
            TEST_FILES="{$(circleci tests glob "test/contracts/*.js" | \
              circleci tests split --split-by=timings | xargs | sed -e 's/ /,/g')}"
            npm run coverage -- --testfiles "$TEST_FILES"
      - run:
          name: Save coverage
          command: |
            cp coverage.json /tmp/coverage/coverage-$CIRCLE_NODE_INDEX.json
      - persist_to_workspace:
          root: /tmp/coverage
          paths:
            - coverage-*.json
  codecov-job:
    parallelism: 10
    docker:
      - image: cimg/base:stable
    steps:
      - attach_workspace:
          at: /tmp/coverage
      - checkout
      - codecov/upload:
          file: "/tmp/coverage/coverage-*.json"

workflows:
  jobs-workflow:
    jobs:
      - codecov-job:
          requires:
            - build-and-test
      - build-and-test

As you see i’m creating coverage-$CIRCLE_NODE_INDEX.json files depending on a number of nodes. Then i want to upload ALL files with codecov/upload

CI/CD URL

Link to a CI/CD

Codecov Output

Output of all nodes are the same:

Expected Results

Upload all code coverage reports into codecov

Actual Results

Upload only first file coverage-0.json

Additional Information

Here is link to codecov app

i can maybe do something like this:

    steps:
      - checkout
      - attach_workspace:
          at: /tmp/coverage
      - run:
          name: Upload coverage
          command: |
            cp -R /tmp/coverage/coverage-*.json .
            codecov -t $CODECOV_TOKEN

But that throws me an error /bin/bash: line 1: codecov: command not found
Maybe you can point me to an image which has codecov command :man_shrugging:

@gruja.work can you confirm that all 10 files are there? maybe do a ls /tmp/coverage/?

If they are all there, what happens if you remove the file flag altogether

1 Like

Hi @tom thanks for fast response.

I can confirm that all files are there i used now 8 parallel runs

Here is yaml file

orbs: # declare what orbs we are going to use
  node: circleci/node@3.0.1 # the node orb provides common node-related configuration
  codecov: codecov/codecov@3.2.3

version: 2.1 # using 2.1 provides access to orbs and other features

jobs:
  build-and-test:
    parallelism: 8
    executor: node/default
    steps:
      - checkout
      - node/install-packages:
          cache-path: ~/project/node_modules
          override-ci-command: npm install
      - run:
          name: Compile
          command: |
            npx hardhat compile --showsize --optimizer
      - run:
          name: Test and output gas used
          command: |
            set +e
            circleci tests glob 'test/contracts/*/*.js' |
            circleci tests split |
            xargs npm test -- --gas
            EXIT_CODE=$?
            printf "\\n"
            exit $EXIT_CODE
      - run:
          name: Create shared coverage outputs folder
          command: mkdir -p /tmp/coverage
      - run:
          name: Coverage
          command: |
            TEST_FILES="{$(circleci tests glob "test/contracts/*/*.js" | \
              circleci tests split --split-by=timings | xargs | sed -e 's/ /,/g')}"
            npm run coverage -- --testfiles "$TEST_FILES"
      - run:
          name: Save coverage
          command: |
            cp coverage.json /tmp/coverage/coverage-$CIRCLE_NODE_INDEX.json
      - persist_to_workspace:
          root: /tmp/coverage
          paths:
            - coverage-*.json
  codecov-job:
    docker:
      - image: cimg/base:stable
    steps:
      - attach_workspace:
          at: /tmp/coverage
      - checkout
      - run:
          name: LS
          command: |
            ls /tmp/coverage/
      - codecov/upload

workflows:
  jobs-workflow:
    jobs:
      - codecov-job:
          requires:
            - build-and-test
      - build-and-test

Also can confirm that removing the file flag helped. :slight_smile:

1 Like