Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverageLocations fails with more than once package #153

Closed
awentzel opened this issue Apr 16, 2020 · 10 comments · Fixed by #163
Closed

coverageLocations fails with more than once package #153

awentzel opened this issue Apr 16, 2020 · 10 comments · Fixed by #163
Assignees
Labels
bug Something isn't working

Comments

@awentzel
Copy link

Using coverageLocations fails to work. I've tried many different options and the only one that seems to work is running on a single package.

 - name: Collect and upload code coverage to Code Climate
      uses: paambaati/codeclimate-action@v2.5.6
      env: 
        CC_TEST_REPORTER_ID: xxxx
      with:
        coverageCommand: yarn run jest --coverage
        coverageLocations:
          "./packages/react/fast-components-foundation-react/coverage/lcov.info:lcov",
          "./packages/react/fast-components-react-base/coverage/lcov.info:lcov"
          # './packages/react/fast-components-react-msft/coverage/lcov.info:lcov',
          # './packages/react/fast-components-styles-msft/coverage/lcov.info:lcov',
          # './packages/react/fast-jss-manager-react/coverage/lcov.info:lcov',
          # './packages/react/fast-jss-utilities/coverage/lcov.info:lcov',
          # './packages/react/fast-layouts-react/coverage/lcov.info:lcov',
          # './packages/react/fast-react-utilities/coverage/lcov.info:lcov',
          # './packages/tooling/fast-tooling/coverage/lcov.info:lcov',
          # './packages/tooling/fast-tooling-react/coverage/lcov.info:lcov',
          # './packages/utilities/fast-animation/coverage/lcov.info:lcov',
          # './packages/utilities/fast-colors/coverage/lcov.info:lcov',
          # './packages/utilities/fast-web-utilities/coverage/lcov.info:lcov'
        debug: true
@awentzel awentzel changed the title coverageLocations fails to work on GH Action coverageLocations fails with more than once package Apr 16, 2020
@paambaati
Copy link
Owner

paambaati commented Apr 17, 2020

@awentzel Can you link me to a failing run? And also please try the latest v2.5.7.

@awentzel
Copy link
Author

awentzel commented Apr 20, 2020

Hi @paambaati - here is a draft pr with update v2.5.7https://github.com/microsoft/fast-dna/actions/runs/83426464 the errors include "You have an error in your yaml syntax on line 51" the problems I'm having, however, is that I can't seem to get any format to work for multiple packages so it's not clear what's expected or why it's breaking.

It's possible my syntax isn't correct. If you can share an example array that would be great. Thanks

Thanks,
Aaron

@MartinNuc
Copy link
Contributor

I have the same problem. coverageLocations doesn't accept an array like mentioned in docs but just a string.

I believe the reason is described here: https://github.community/t5/GitHub-Actions/Can-action-inputs-be-arrays/td-p/33776

Action inputs only supports string keys and string values at this time. This is because they translate to environment variables within the action's execution run.

There are two workarounds:

  1. use JSON
  2. use string with spaces/newlines and split it into the array in the code

I will try it and make a PR 🙂

@awentzel
Copy link
Author

Thanks @MartinNuc, appreciate your help. I was going to submit some doc updates as well as soon as I got it figured out. Were you able to get it to actually format_coverage, sum_coverage, and upload_coverage? If that works it's a step in the right direction for sure. The script methods I used on Circle CI seem to be broken on GH Actions now with the cc-test-reporter. In fact, cc-test-reporter itself doesn't seem to handle mono-repos well. Thanks again.

@MartinNuc
Copy link
Contributor

Not yet. Still working on it. I had to convert also prefix into array. So files are being passed now as a multiline string (last segment after :):

        with:
          coverageLocations: |
            ${{github.workspace}}/client/coverage/lcov.info:lcov:${{github.workspace}}/client
            ${{github.workspace}}/server/coverage/lcov.info:lcov:${{github.workspace}}/server

Right now have a problem that format_coverage is trying to read files without prefix. I will have to try it locally first and then I will submit PR.

@awentzel
Copy link
Author

@MartinNuc , I did a test and got through that part thanks to your suggestion. But, haven't had any luck yet getting format_coverage to work. In fact, I have a few threads on this issue, including a different approach scripting in the CI rather than using an Action. But, all roads for that have resulted in no such file or directory. Very challenging problem on mono-repositories. What coverageCommand are you using? Technically, unit testing has already created my /coverage data. But, it's unclear how things process inside this black box. I haven't dug into the source code yet.

@MartinNuc
Copy link
Contributor

MartinNuc commented Apr 22, 2020

Finally got it working. My problem was actually with the instanbul coverage file. There were relative paths which didn't work well with monorepo like:

SF:src/server.ts

I had to set the projectRoot in jest config. After that I had this path in lcov.info:

SF:server/src/server.ts

Which worked with formatter correctly. Here is the related issue: istanbuljs/istanbuljs#529

Solved by setting projectRoot for lcov reporter to the actually root of the monorepo:

// server/jest.config.js
coverageReporters: [['lcov', { projectRoot: '..' }]]

After that it turned out that there is no need to use different prefix for each covarageLocation therefore I removed that feature.

If you want you can try my version using:

      - name: Coverage to Codeclimate
        uses: MartinNuc/codeclimate-action@v2.5.10
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_REPORTER_ID }}
        with:
          coverageLocations: |
            ${{github.workspace}}/client/coverage/lcov.info:lcov
            ${{github.workspace}}/server/coverage/lcov.info:lcov

I will post the PR to this repo.

@paambaati
Copy link
Owner

@MartinNuc Would be super-helpful if you can add these to the README's examples section as well.

@MartinNuc
Copy link
Contributor

MartinNuc commented Apr 23, 2020

@paambaati Actually I did here https://github.com/paambaati/codeclimate-action/pull/163/files#diff-04c6e90faac2675aa89e2176d2eec7d8L44

I will add few more

@paambaati paambaati added the bug Something isn't working label Apr 24, 2020
@paambaati
Copy link
Owner

Thanks a ton @MartinNuc! This fix has now landed in v2.6.0.

justinharringa added a commit to salesforce/dockerfile-image-update that referenced this issue Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants