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

Update find file func according to latest go/cover code #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

richardlt
Copy link

Just an update from latest version of the go cover tool, this improve the way that golang file path are retrieve from profile.
On a big project like the one I'm working on (github.com/ovh/cds), it used to take more than 3 minutes to generate a report now its only 3 seconds.

@coveralls
Copy link

coveralls commented May 7, 2020

Pull Request Test Coverage Report for Build 34

  • 37 of 78 (47.44%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+3.3%) to 82.979%

Changes Missing Coverage Covered Lines Changed/Added Lines %
gocover-cobertura.go 5 7 71.43%
profile.go 13 22 59.09%
func.go 19 49 38.78%
Totals Coverage Status
Change from base Build 29: 3.3%
Covered Lines: 273
Relevant Lines: 329

💛 - Coveralls

@adrienjoly
Copy link

adrienjoly commented Jan 11, 2021

FYI, this PR and the underlying fork by @richardlt helped me fix the XML coverage report I generate for Codacy on the open source project I'm working on! 🎉

Cf signaux-faibles/opensignauxfaibles#289 (in French, but the diff and figures should be self explanatory)

=> I recommend to merge that PR. And thank you Richard, for this fix! 🙌

adrienjoly added a commit to signaux-faibles/opensignauxfaibles that referenced this pull request Jan 11, 2021
## Problème

Suite à la fusion de PR #286 (sensée augmenter le score de couverture des fichiers Go), le score de couverture rapporté par Codacy a baissé de 29 points. (cf #286 (comment))

## Analyse

En réexécutant en local la chaine de mesure employé en CI, je me suis rendu compte que nos fichiers Go les plus couverts montraient un score très bas sur codacy (ex: [`apconso.go`](https://app.codacy.com/gh/signaux-faibles/opensignauxfaibles/file/51943291072/coverage?bid=18037842&fileBranchId=18037842) avec un score de 6%) alors que la couverture retourné par `go test` est élevée. (66%, toujours sur `apconso.go`)

Il s'avère que cette erreur de calcul est causée par l'outil `github.com/t-yuki/gocover-cobertura` employé pour générer un rapport XML requis par Codacy, à partir des résultats fournis par `go test`. Cette erreur a été corrigée dans une PR non fusionnée ([Update find file func according to latest go/cover code](t-yuki/gocover-cobertura#23)).

## Résolution

- remplacer l'outil `github.com/t-yuki/gocover-cobertura` par le fork `github.com/richardlt/gocover-cobertura` (créé par l'auteur de la PR corrige mentionnée ci-dessus)

## Résultats

Rapport XML avant cette PR:

```xml
				<class name="APConso" filename="github.com/signaux-faibles/opensignauxfaibles/lib/apconso/main.go" line-rate="0.04761905" branch-rate="0" complexity="0">
					<methods>
						<method name="Key" signature="" line-rate="0.071428575" branch-rate="0" complexity="0">
							<lines>
								<line number="26" hits="0"></line>
								<line number="27" hits="0"></line>
								<line number="28" hits="0"></line>
								<line number="26" hits="0"></line>
								<line number="27" hits="0"></line>
								<line number="28" hits="0"></line>
								<line number="26" hits="0"></line>
								<line number="27" hits="0"></line>
								<!-- plusieurs fois chaque numéro de ligne, avec un hits à 0 dans la plupart des cas -->
```

Après cette PR:

```xml
				<class name="APConso" filename="github.com/signaux-faibles/opensignauxfaibles/lib/apconso/main.go" line-rate="0.6666667" branch-rate="0" complexity="0">
					<methods>
						<method name="Key" signature="" line-rate="1" branch-rate="0" complexity="0">
							<lines>
								<line number="26" hits="6"></line>
								<line number="27" hits="6"></line>
								<line number="28" hits="6"></line>
							</lines>
						</method>
						<method name="Type" signature="" line-rate="0" branch-rate="0" complexity="0">
							<lines>
								<line number="31" hits="0"></line>
								<line number="32" hits="0"></line>
								<line number="33" hits="0"></line>
							</lines>
						</method>
```

Augmentation du [score de couverture rapporté par Codacy](https://app.codacy.com/gh/signaux-faibles/opensignauxfaibles/pullRequest?prid=6777846):

![image](https://user-images.githubusercontent.com/531781/104167726-22c37c00-53fd-11eb-9a4e-3910d96c803f.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants