Giter VIP home page Giter VIP logo

jx-app-jacoco's People

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jx-app-jacoco's Issues

Better defaulting of namespace

Currently the environment variable TEAM_NAMESPACE is read to determine which namespace should be watched for pipelineactivities, defaulting to jx, and the old extension install script expect to set this in turn on the chart via some EXT_TEAM_NAMESPACE variable. I expect that this logic needs to be replaced by something which just reads /var/run/secrets/kubernetes.io/serviceaccount/namespace (discussion).

Read jacoco.xml from private gh-pages

This code does not look like it would work when jacoco.xml was published to a private repository, as the GH raw URL will be inaccessible without an API token. I believe you need to use this idiom, as alluded to in storage documentation.

(It seems likely that there will be a lot of boilerplate code like this common to many apps processing build metadata. Perhaps some helper functions could be extracted to a common repository for reuse?)

Allow for proper shutdown of app

The go routine channel handling, in particular, the usage of the stop channel, does not allow for a clean shutdown of the container/app.

A top level stop channel should be created and used and passed to the go sub routines. Then an event handler for the various shutdown signals should be registered and used to allow a clean shutdown.

The signal channel watcher should close the dine channel

Currently, only a single struct is sent down the done channel. This means only one go routine will receive the done signal. Instead the done channel should be closed at this point.

func setupSignalChannel(done chan struct{}) {
	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGTERM)

	go func() {
		logger.Info("waiting for shutdown signal in the background")
		<-sigChan
		logger.Info("received SIGTERM signal - initiating shutdown")
		done <- struct{}{}
	}()
}

Jacoco facts get re-created each time the app (re)-starts

Each time the app starts, all PipelineActivitity CRDs get replayed and re-processed. This means activities with the jacoco fact get handled again and the already existing fact replaced with a new identical one.

Either we add a check whether the fact already exists or we investigate how to monitor for only new changes.

Makefile target don't work properly

  • build does not have any dependencies. Recompilation does not occur even if files change. Either make build phony or create a proper dependency
  • full and related dependencies don't seem to work

Extension delayed processing

I've seen the extension processor getting a 404 when retrieving the report from GH pages shortly after the pipeline activity was updated.

My guess is that the GH pages may have a small delay to update after pushing to the corresponding branch in GH repository.

The problem with the current implementation is that it won't retry to query before the 10 minutes watch delay, which is too long. There should be an exponential backoff to retry to retrieve a report in order to generate the facts as soon as the report is available.

Switch to pipeline extension app

Instead of being a Kuberenetes controller, the Jacoco App should be changed to be of type Pipeline Extension.

In this model, the App gets called as part of the metapipeline execution where it can contribute to the pipeline, by making changes to the source, eg the pipeline configuration, but also things like pom.xml. This would also allow for example to implement issue #63.

Generated fact contains wrong data

Below you find an example Fact as currently generated by the app. There seem to be several things not quite right:

  • The fact id is '0'. In fact, the code never sets it, meaning all facts will have the same id. What is the intention here? Do we want a random id (aka uuid) in order to identify this particular fact at any time or should the id be some sort of hash over the data, so that two facts which are identical in data get the same id?
  • The measurement type says "percent", but we are processing counters. Should the type be "count" or we want to calculate percentages?
  • We are only processing the top level aggregated counters in these facts. The underlying jacoco report is more detailed. Is it intentional to only look at the aggregate
  • ' Instructions-Coverage', 'Complexity-Coverage', etc is imo misleading. It is not "coverage" which we record, but lines "covered". That's an issue in the Fact definition though
facts:
  - factType: jx.coverage
    id: 0
    measurements:
    - measurementType: percent
      measurementValue: 3
      name: Instructions-Coverage
    - measurementType: percent
      measurementValue: 5
      name: Instructions-Missed
    - measurementType: percent
      measurementValue: 8
      name: Instructions-Total
    - measurementType: percent
      measurementValue: 1
      name: Lines-Coverage
    - measurementType: percent
      measurementValue: 2
      name: Lines-Missed
    - measurementType: percent
      measurementValue: 3
      name: Lines-Total
    - measurementType: percent
      measurementValue: 1
      name: Complexity-Coverage
    - measurementType: percent
      measurementValue: 1
      name: Complexity-Missed
    - measurementType: percent
      measurementValue: 2
      name: Complexity-Total
    - measurementType: percent
      measurementValue: 1
      name: Methods-Coverage
    - measurementType: percent
      measurementValue: 1
      name: Methods-Missed
    - measurementType: percent
      measurementValue: 2
      name: Methods-Total
    - measurementType: percent
      measurementValue: 1
      name: Classes-Coverage
    - measurementType: percent
      measurementValue: 0
      name: Classes-Missed
    - measurementType: percent
      measurementValue: 1
      name: Classes-Total
    name: ""
    original:
      mimetype: application/xml
      tags:
      - jacoco.xml
      url: https://raw.githubusercontent.com/hf-bee/spring-boot-test/gh-pages/jenkins-x/jacoco/hf-bee/spring-boot-test/PR-5/1/target/site/jacoco/jacoco.xml
    statements: []
    tags:
    - jacoco

@deanesmith, @pmuir - WDYT?

Use 'jx step stash' in documentation for this app

The readme refers to jx step collect in the Jenkinsfile as a required step for configuring the app. collect is really just a command alias for stash which I think is much more self-explanatory. I think we should use stash.

Maybe we should also make the implicit git flags in this command explicit, mainly to make it easier for the user to connect the dots.

Add labels to Fact object to allow clients to filter

It will be pretty common to fetch a list of Facts from the API, but currently, the API server doesn't support filtering based on fields, so the only way to filter is to use labels. Adding these labels to the generated Facts, we make it easier for other potential components to filter.

Allow app to run locally

This makes development easier. Use something like this to create JX client:

	factory := clients.NewFactory()
	jxClient, _, err := factory.CreateJXClient()
	if err != nil {
		logger.Fatal(err)
	}

Avoid having to configure jacoco in pom.xml

The current version of the app requires that the Maven build has the jacoco-maven-plugin configured in its pom.xml. The app then just collects and stores the report.

If the app is installed, the configuration of pom.xml should not be required. jacoco should be run transparently.

Artefacts are released in the wrong order

The Helm release occurs before the Docker image is built and published.

For example:

Received 201 response: {"saved":true}
[Pipeline] }
[Pipeline] // dir
[Pipeline] dir
Running in /home/jenkins/go/src/github.com/jenkins-x-apps/jx-app-jacoco
[Pipeline] {
[Pipeline] sh
+ cat VERSION
+ docker build -t docker.io/jenkinsxio/jx-app-jacoco:0.0.85 .
Sending build context to Docker daemon  38.41MB
Step 1/5 : FROM scratch
 ---> 
Step 2/5 : EXPOSE 8080
 ---> Using cache
 ---> c2e4b86d4c12
Step 3/5 : ENTRYPOINT /jx-app-jacoco
 ---> Using cache
 ---> 4d401c8b366e
Step 4/5 : COPY ./tmp/ca-certificates.crt /etc/ssl/certs/
 ---> 307d8bcfcdb2
Removing intermediate container fd273e9a213d
Step 5/5 : COPY ./build/ /
 ---> b709b3263687
Removing intermediate container b828714f6368
Successfully built b709b3263687
[Pipeline] sh
+ cat VERSION
+ docker push docker.io/jenkinsxio/jx-app-jacoco:0.0.85
The push refers to a repository [docker.io/jenkinsxio/jx-app-jacoco]
d880d2ced03f: Preparing
9be191bb1453: Preparing
9be191bb1453: Pushed
d880d2ced03f: Pushed
0.0.85: digest: sha256:ebb82e77f3f78572ae5ef103ea4dfadce5e48d7552e3cc21f164d01045f28550 size: 739

See https://github.com/jenkins-x-apps/jx-app-jacoco/blob/master/Jenkinsfile#L64

If the image build fails, you might end up with a released Helm chart which does not work, since there is no matching image. Something like this might have had happened with 0.0.84, where there was a Helm chart, but no matching image.

Jacoco App is not registered under apps.jenkins.io CRD

At the moment kubectl get apps does not list the Jacoco App. This is because there is no associated resource in the helm template for the app.

We have 2 options here:

  1. Add a resource template here similar to how some of the other Apps work.
  2. Find a way to auto generate an App Resource definition.

Introduce proper logging

Some info logging is currently done using log.Printf which per default will write to stderr. This leads to the fact that the log messages will appear as errors in the logs.

We should introduce a proper logger (logrus!?) and properly handle the logging levels (error|warning|info).

Unable to install golint

The golint import path has changed. If it is not installed and one runs make check:

make check
go: finding github.com/golang/lint/golint latest
go: finding github.com/golang/lint latest
go: github.com/golang/[email protected]: parsing go.mod: unexpected module path "golang.org/x/lint"
go: error loading module requirements
make: *** [/Users/hardy/work/go/bin/golint] Error 1

Links in pull request builds are not linking to the logs

For example from an actual pull request:


Test name Commit Details Rerun command
serverless-jenkins 284967d link /test this

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.


In the above example the target of the link is empty

Update NOTES.txt of the Helm chart

Currently NOTES.txt shows the command on how to get the apps ingress which is not useful.
The notes should contain information similar to the one in the README, aka how do I get jacoco reports generated and how can I view them.

Derive from a different base image in Dockerfile

The idea is to avoid

COPY ./tmp/ca-certificates.crt /etc/ssl/certs/

and the coressponding code in the Makefile and its cert target.

The reason this exists atm is that the scratch image does not contain certificates.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.