Bug 474156 - Run API Tools builder in the Gerrit verification build
Summary: Run API Tools builder in the Gerrit verification build
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Releng (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.13 M1   Edit
Assignee: Mickael Istria CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 548680 547206 547877 548242
Blocks: 548537
  Show dependency tree
 
Reported: 2015-08-03 11:28 EDT by Dani Megert CLA
Modified: 2020-02-07 11:33 EST (History)
12 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2015-08-03 11:28:28 EDT
Our build produces an API Tools verification report but it would be better to run the PDE API Tools builder during the build, so that we get errors and warnings. This would be especially helpful for Gerrit changes.
Comment 1 David Williams CLA 2015-08-05 13:05:15 EDT
As mentioned in a status meeting, it would be best to convert the "API Tools verification" task to a maven plugin, in order to implement this. It would also likely require some "re-design" since the current way we do this is on "SDK as a whole" which does not make much sense for a "Gerrit job" that only builds one repository (or, one bundle). If nothing else, would be faster to run on a subset ... I am assuming the "whole SDK" takes a long time, but honestly have not measured it.
Comment 2 Lars Vogel CLA 2019-05-09 02:47:34 EDT
We could also simple add a Ant build step in our Gerrit build.

Sravan, could you share the wiki / command how to run the API tools check via Ant?
Comment 3 Mickael Istria CLA 2019-05-09 03:22:37 EDT
(In reply to Lars Vogel from comment #2)
> We could also simple add a Ant build step in our Gerrit build.
> Sravan, could you share the wiki / command how to run the API tools check
> via Ant?

It would be the simplest approach, but API Tools currently are only able to create report, that still need human processing. In order to make things fully automated and valuable, we first need an option for the API Tools to *fail* (ie app exists with a non-0 code) in case of inconsistency. Then, adding this as a build step would fail the build.
Comment 4 Lars Vogel CLA 2019-05-09 04:35:39 EDT
(In reply to Mickael Istria from comment #3)
> (In reply to Lars Vogel from comment #2)
> > We could also simple add a Ant build step in our Gerrit build.
> > Sravan, could you share the wiki / command how to run the API tools check
> > via Ant?
> 
> It would be the simplest approach

If someone tells me how to add this Ant step to the Gerrit verification build, I guess return a failure if case of a negative result for Jenkins should be trivial.

If the Ant things is implemented, I can have a look for failing the build, if no one else steps up.
Comment 5 Sravan Kumar Lakkimsetti CLA 2019-05-09 04:45:23 EDT
(In reply to Lars Vogel from comment #2)
> We could also simple add a Ant build step in our Gerrit build.
> 
> Sravan, could you share the wiki / command how to run the API tools check
> via Ant?

We use previous successful eclipse build to run api tools

Here is the script. https://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git/tree/cje-production/mbscripts/mb510_createApiToolsReports.sh

Here the LAUNCHER_JAR points to the launcher from the eclipse installation

Here is a script to create eclipse instance with all the necessary plugins 
https://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git/tree/cje-production/mbscripts/mb020_createBaseBuilder.sh

Here is the documentation on apitooling's ant tasks. https://help.eclipse.org/2019-03/nav/4_3_0_0

The ant tasks talk about apitools-ant.jar. But I don't think we are building it anymore.
Comment 6 Mickael Istria CLA 2019-05-09 04:47:26 EDT
I think it would be a bit simpler to write some IApplication in API Tools directly rather than relying on Ant here; both in term of implementation and usage.
Comment 7 Lars Vogel CLA 2019-05-09 04:49:42 EDT
(In reply to Mickael Istria from comment #6)
> I think it would be a bit simpler to write some IApplication in API Tools
> directly rather than relying on Ant here; both in term of implementation and
> usage.

Can you try that?
Comment 8 Mickael Istria CLA 2019-05-09 04:50:36 EDT
(In reply to Lars Vogel from comment #7)
> Can you try that?

Not right now, but I'm discussing with Alex and it's something I may be able to try next week or the week after that.
Comment 9 Lars Vogel CLA 2019-05-09 07:55:28 EDT
(In reply to Mickael Istria from comment #8)
> Not right now, but I'm discussing with Alex and it's something I may be able
> to try next week or the week after that.

Awesome Mickael, thanks.
Comment 10 Eclipse Genie CLA 2019-05-15 11:31:07 EDT
New Gerrit change created: https://git.eclipse.org/r/142204
Comment 12 Mickael Istria CLA 2019-05-17 11:40:06 EDT
See how this can look like once bug 547206 is fixed: https://git.eclipse.org/r/#/c/142341/1/bundles/org.eclipse.jface.databinding/pom.xml
Comment 13 Vikas Chandra CLA 2019-05-18 07:59:28 EDT
https://ci.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/18367/console

This failed to execute ( as expected as api-analysis is still not in build).

I will commit bug 547206 and re-trigger this with tomorrow's build.
Comment 14 Eclipse Genie CLA 2019-05-21 12:21:31 EDT
New Gerrit change created: https://git.eclipse.org/r/142534
Comment 15 Lars Vogel CLA 2019-05-23 04:58:50 EDT
I assume this is planned for 4.13.
Comment 16 Eclipse Genie CLA 2019-05-23 09:02:49 EDT
New Gerrit change created: https://git.eclipse.org/r/142665
Comment 18 Mickael Istria CLA 2019-05-27 05:19:25 EDT
The CI build triggered by shows that
1. API checks seem to run, but
2. API analyzer app is not tolerant to other errors in workspace, and some plugins do have errors in their plugin.xml
so API analyzer fails the build for an unrelated reason.

Should we just fix the bundle that have errors by turning those errors into warnings if they're not causing actual failures; or should we instruct the API Analyzer app to ignore some errors? The issue with the later is that we can't know which error are blockers for API Tools processing.
Comment 19 Alexander Kurtakov CLA 2019-05-27 06:05:18 EDT
(In reply to Mickael Istria from comment #18)
> The CI build triggered by shows that
> 1. API checks seem to run, but
> 2. API analyzer app is not tolerant to other errors in workspace, and some
> plugins do have errors in their plugin.xml
> so API analyzer fails the build for an unrelated reason.
> 
> Should we just fix the bundle that have errors by turning those errors into
> warnings if they're not causing actual failures; or should we instruct the
> API Analyzer app to ignore some errors? The issue with the later is that we
> can't know which error are blockers for API Tools processing.

IMHO warnings should be fixed as any white/black listing should be done on per bundle basis in the bundle configs.
Comment 20 Mickael Istria CLA 2019-05-31 13:38:02 EDT
So the actual (first known) issue is

* Marker [on: /org.eclipse.osgi/plugin.xml, id: 144, type: org.eclipse.pde.core.problem, attributes: [categoryId: , compilerKey: compilers.p.unresolved-ex-points, lineNumber: 5, message: Unknown extension point: 'org.eclipse.ui.trace.traceComponents', problemId: 4135, severity: 2], created: 5/31/19, 7:01 PM]
Some blocking (most likely link/compilation) errors are present ^^^

Indeed, the org.eclipse.ui.trace bundle is not in the target-platform for org.eclipse.osgi (that's a good thing per se).
However, I don't see a way to turn those errors as warnings.
Comment 21 Vikas Chandra CLA 2019-06-03 01:09:49 EDT
(In reply to Mickael Istria from comment #20)
> So the actual (first known) issue is
> 
> * Marker [on: /org.eclipse.osgi/plugin.xml, id: 144, type:
> org.eclipse.pde.core.problem, attributes: [categoryId: , compilerKey:
> compilers.p.unresolved-ex-points, lineNumber: 5, message: Unknown extension
> point: 'org.eclipse.ui.trace.traceComponents', problemId: 4135, severity:
> 2], created: 5/31/19, 7:01 PM]
> Some blocking (most likely link/compilation) errors are present ^^^
> 
> Indeed, the org.eclipse.ui.trace bundle is not in the target-platform for
> org.eclipse.osgi (that's a good thing per se).
> However, I don't see a way to turn those errors as warnings.

See PDEPreferencesTestCase::testCompilerPreferences  ( there are options to set preference too)
(plugin : org.eclipse.pde.ui.tests)

Project PDE compiler settings "compilers.p.unresolved-ex-points=0" in org.eclipse.pde.prefs in .settings folder in project  sets this compiler issue to ignore. ( 1 for warning and 2 for error).
Comment 22 Eclipse Genie CLA 2019-06-03 13:55:20 EDT
New Gerrit change created: https://git.eclipse.org/r/143216
Comment 23 Eclipse Genie CLA 2019-06-03 13:56:15 EDT
New Gerrit change created: https://git.eclipse.org/r/143218
Comment 26 Mickael Istria CLA 2019-06-12 08:45:07 EDT
With https://git.eclipse.org/r/#/c/142665/ , all the configuration is contained in a profile, that's opt-in.
Then, once this parent pom is available (`mvn install`ed locally or found on remote repo), once can run any Gerrit or local build with

  mvn clean verify -Pbuild-individual-bundles,api-check

This will add a few extra build step the do report API failures.
To try it, you can take a bundle like org.eclipse.compare.core, build it with command above and parent pom installed locally => Build says "0 API ERRORS
0 API warnings". Then, add a public string to an API like IHunk, do NOT change MANIFEST.MF, save, commit, build with same command =>
```
2 API ERRORS
* Marker [on: /org.eclipse.compare.core/META-INF/MANIFEST.MF, id: 18, type: org.eclipse.pde.api.tools.version_numbering, attributes: [apiMarkerID: 4, charEnd: 152, charStart: 135, description: - The field org.eclipse.compare.patch.IHunk.STING has been added in an interface that is tagged with '@noimplement'
, lineNumber: 5, message: The minor version should be incremented in version 3.6.500, since new APIs have been added since version 3.6.500, messagearguments: 3.6.500#3.6.500, problemid: 924844039, severity: 2, sourceId: API Tools, version: 3.7.0.qualifier], created: 6/12/19, 2:29 PM]
* Marker [on: /org.eclipse.compare.core/src/org/eclipse/compare/patch/IHunk.java, id: 17, type: org.eclipse.pde.api.tools.marker.sincetags, attributes: [apiMarkerID: 5, charEnd: 1477, charStart: 1472, lineNumber: 40, message: Missing @since tag on STING, messagearguments: STING, org.eclipse.jdt.internal.core.JavaModelManager.handleId: =org.eclipse.compare.core/src<org.eclipse.compare.patch{IHunk.java[IHunk^STING, problemTypeName: org.eclipse.compare.patch.IHunk, problemid: 1211105284, severity: 2, sourceId: API Tools, version: 3.6], created: 6/12/19, 2:29 PM]
0 API warnings
```

Once https://git.eclipse.org/r/#/c/142665/ is merged, we can progressively enable the profile on the Gerrit job, and start brainstorming of a new hot topic for frequent quarrels as a replacement ;)
Comment 28 Mickael Istria CLA 2019-06-13 10:34:08 EDT
Thanks for the merge.
The `api-check` profile is now available for wider usage and can be tried locally.
It still has an important flaw that prevents from enabling it on Gerrit builds though: bug 548242 .
Comment 29 Eclipse Genie CLA 2019-06-14 17:31:33 EDT
New Gerrit change created: https://git.eclipse.org/r/144093
Comment 30 Eclipse Genie CLA 2019-06-15 15:59:23 EDT
New Gerrit change created: https://git.eclipse.org/r/144123
Comment 31 Eclipse Genie CLA 2019-06-15 16:38:53 EDT
New Gerrit change created: https://git.eclipse.org/r/144127
Comment 32 Mickael Istria CLA 2019-06-17 12:12:04 EDT
Bug 548279 isn't a blocker for this one.
Comment 35 Mickael Istria CLA 2019-06-19 15:14:25 EDT
The api-check profile is now enabled on Gerrit jobs eclipse.platform.team-Gerrit and eclipse.platform.resources-Gerrit and works as expected.
I've submitted a patch to merge in JDT/Core before we can enable the profile on it: https://git.eclipse.org/r/144123
I'll try to process all other Equinox/Platform jobs by the end of the week. Assistance is welcome: just run `mvn clean verify -DskipTests -Papi-check,build-individual-bundles` locally, adjust some preferences if needed (usually maling «missing extension point» a warning by tweaking the org.eclipse.pde.prefs as shown in other commits), and push a patch.with the modification and/or tweak the CI job to enable the profile.
Comment 36 Lars Vogel CLA 2019-06-20 02:42:33 EDT
Thanks Mickael for working on this. I see in resources an error now:

[ERROR] Failed to execute goal org.eclipse.tycho.extras:tycho-eclipserun-plugin:1.4.0:eclipse-run (api-analysis) on project org.eclipse.core.filesystem.linux.ppc64le: Execution api-analysis of goal org.eclipse.tycho.extras:tycho-eclipserun-plugin:1.4.0:eclipse-run failed: Cannot resolve dependencies of null: See log for details -> [Help 1]

Can you please have a look?
Comment 37 Mickael Istria CLA 2019-06-20 03:34:33 EDT
(In reply to Lars Vogel from comment #36)
> Can you please have a look?

The IMO too prompt revert of some other commit is causing that. I won't work on the issue you found until we're done with bug 548242 as doing it the other way round would be a waste of time for me.
Comment 38 Lars Vogel CLA 2019-06-20 03:36:42 EDT
(In reply to Mickael Istria from comment #37)
> (In reply to Lars Vogel from comment #36)
> > Can you please have a look?
> 
> The IMO too prompt revert of some other commit is causing that. I won't work
> on the issue you found until we're done with bug 548242 as doing it the
> other way round would be a waste of time for me.

+1, makes sense.
Comment 39 Eclipse Genie CLA 2019-06-20 08:25:22 EDT
New Gerrit change created: https://git.eclipse.org/r/144527
Comment 41 Eclipse Genie CLA 2019-06-20 12:12:22 EDT
New Gerrit change created: https://git.eclipse.org/r/144539
Comment 43 Eclipse Genie CLA 2019-06-21 08:58:11 EDT
New Gerrit change created: https://git.eclipse.org/r/144629
Comment 44 Eclipse Genie CLA 2019-06-21 09:35:29 EDT
New Gerrit change created: https://git.eclipse.org/r/144635
Comment 47 Eclipse Genie CLA 2019-06-21 13:07:42 EDT
New Gerrit change created: https://git.eclipse.org/r/144657
Comment 48 Eclipse Genie CLA 2019-06-21 15:15:04 EDT
New Gerrit change created: https://git.eclipse.org/r/144661
Comment 51 Eclipse Genie CLA 2019-06-24 04:46:04 EDT
New Gerrit change created: https://git.eclipse.org/r/144701
Comment 53 Eclipse Genie CLA 2019-06-24 06:14:41 EDT
New Gerrit change created: https://git.eclipse.org/r/144710
Comment 54 Eclipse Genie CLA 2019-06-24 07:01:53 EDT
New Gerrit change created: https://git.eclipse.org/r/144713
Comment 56 Eclipse Genie CLA 2019-06-24 09:04:42 EDT
New Gerrit change created: https://git.eclipse.org/r/144719
Comment 58 Eclipse Genie CLA 2019-06-24 09:41:18 EDT
New Gerrit change created: https://git.eclipse.org/r/144723
Comment 59 Mickael Istria CLA 2019-06-24 09:47:13 EDT
This is now enabled on most Gerrit builds
Some exceptions:
* eclipse.platform.runtime => Stuck by bug 547877
* eclipse.platform.ui => Stuck by bug 548249
* eclipse.jdt.core => need `api-check` profile to be added to CI Job
* eclipse.jdt.ui => https://git.eclipse.org/r/144723 + need `api-check` profile to be added to CI Job
* eclipse.jdt.debug => https://git.eclipse.org/r/144713 + need `api-check` profile to be added to CI Job
* eclipse.pde.ui => https://git.eclipse.org/r/c/144657/ +  need `api-check` profile to be added to CI Job
* eclipse.pde.build ->  need `api-check` profile to be added to CI Job

We're also unveiling some glitches in the application itself. Not blockers and API Check still provide value and catches a wide variety of issues, but it seems to miss some bug 548574
Comment 60 Roland Grunberg CLA 2019-06-24 10:07:28 EDT
* eclipse.jdt.core has -Papi-check enabled, and seems to be running ( https://ci.eclipse.org/jdt/job/eclipse.jdt.core-Gerrit/2061/consoleFull ) .
Comment 61 Mickael Istria CLA 2019-06-24 10:10:20 EDT
(In reply to Roland Grunberg from comment #60)
> * eclipse.jdt.core has -Papi-check enabled, and seems to be running (
> https://ci.eclipse.org/jdt/job/eclipse.jdt.core-Gerrit/2061/consoleFull ) .

Right thanks. Those lines of log confirm it's running
"""
10:06:02 [INFO] --- tycho-eclipserun-plugin:1.4.0:eclipse-run (api-analysis) @ org.eclipse.jdt.core ---
10:06:02 [INFO] Toolchain in tycho-eclipserun-plugin: JDK[/opt/public/common/jdk1.8.0_x64-latest/jre]
10:06:02 [INFO] Expected eclipse log file: /jobs/genie.jdt/eclipse.jdt.core-Gerrit/workspace/org.eclipse.jdt.core/target/eclipserun-work/data/.metadata/.log
10:06:02 [INFO] Command line:
10:06:02 	[/opt/public/common/jdk1.8.0_x64-latest/jre/bin/java, -Xmx2048M, -jar, /jobs/genie.jdt/eclipse.jdt.core-Gerrit/workspace/.repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.5.400.v20190515-0925/org.eclipse.equinox.launcher-1.5.400.v20190515-0925.jar, -install, /jobs/genie.jdt/eclipse.jdt.core-Gerrit/workspace/org.eclipse.jdt.core/target/eclipserun-work, -configuration, /jobs/genie.jdt/eclipse.jdt.core-Gerrit/workspace/org.eclipse.jdt.core/target/eclipserun-work/configuration, -data, /jobs/genie.jdt/eclipse.jdt.core-Gerrit/workspace/org.eclipse.jdt.core/../target/org.eclipse.jdt.core-apiAnalyzer-workspace, -application, org.eclipse.pde.api.tools.apiAnalyzer, -project, /jobs/genie.jdt/eclipse.jdt.core-Gerrit/workspace/org.eclipse.jdt.core, -baseline, default, -dependencyList, /jobs/genie.jdt/eclipse.jdt.core-Gerrit/workspace/org.eclipse.jdt.core/target/dependencies-list.txt, -failOnError]
10:06:02 Picked up JAVA_TOOL_OPTIONS: -Xmx2G -Djava.io.tmpdir=/tmp/genie.jdt
10:06:37 0 API ERRORS
10:06:37 37 API warnings
"""
Comment 64 Eclipse Genie CLA 2019-06-25 04:00:27 EDT
New Gerrit change created: https://git.eclipse.org/r/144803
Comment 65 Eclipse Genie CLA 2019-06-25 06:17:21 EDT
New Gerrit change created: https://git.eclipse.org/r/144823
Comment 66 Eclipse Genie CLA 2019-06-25 11:52:52 EDT
New Gerrit change created: https://git.eclipse.org/r/144858
Comment 67 Eclipse Genie CLA 2019-06-25 12:54:00 EDT
New Gerrit change created: https://git.eclipse.org/r/144865
Comment 70 Eclipse Genie CLA 2019-06-27 07:07:46 EDT
New Gerrit change created: https://git.eclipse.org/r/144999
Comment 72 Mickael Istria CLA 2019-06-27 08:23:23 EDT
And with this last commit, we're done.
On Gerrit jobs, Jenkins will report a failure for API Tools errors.
To run the checks locally, add the `-Papi-check` profile to your local build command.
Comment 73 Dani Megert CLA 2020-02-07 08:25:49 EST
(In reply to Mickael Istria from comment #72)
> And with this last commit, we're done.
> On Gerrit jobs, Jenkins will report a failure for API Tools errors.
> To run the checks locally, add the `-Papi-check` profile to your local build
> command.
Currently we get the following in the console when it fails:

[ERROR] Failed to execute goal org.eclipse.tycho.extras:tycho-eclipserun-plugin:1.6.0:eclipse-run (api-analysis) on project org.eclipse.jdt.ui: Error while executing platform: Error while executing platform (return code: 4) -> [Help 1]

Are there (somewhere) more details why it fails?
Comment 74 Mickael Istria CLA 2020-02-07 09:07:18 EST
(In reply to Dani Megert from comment #73)
> Currently we get the following in the console when it fails:
> 
> [ERROR] Failed to execute goal
> org.eclipse.tycho.extras:tycho-eclipserun-plugin:1.6.0:eclipse-run
> (api-analysis) on project org.eclipse.jdt.ui: Error while executing
> platform: Error while executing platform (return code: 4) -> [Help 1]
> 
> Are there (somewhere) more details why it fails?

Do you know a CI build I can see with this issue?
Or some steps to reproduce?

I think it could be related to usage of -fae: the api comparison mojo writes issues in the log and continues the build if -fae is set, then at the end of the build, the error is shown but not the logged messages (similarly to test mojo reporting "test failures" but not giving details in the error message so you need to scroll up).
Were you using -fae?
Comment 75 Dani Megert CLA 2020-02-07 09:17:11 EST
(In reply to Mickael Istria from comment #74)
> (In reply to Dani Megert from comment #73)
> > Currently we get the following in the console when it fails:
> > 
> > [ERROR] Failed to execute goal
> > org.eclipse.tycho.extras:tycho-eclipserun-plugin:1.6.0:eclipse-run
> > (api-analysis) on project org.eclipse.jdt.ui: Error while executing
> > platform: Error while executing platform (return code: 4) -> [Help 1]
> > 
> > Are there (somewhere) more details why it fails?
> 
> Do you know a CI build I can see with this issue?
> Or some steps to reproduce?
https://ci.eclipse.org/jdt/job/eclipse.jdt.ui-Gerrit/4212/

> I think it could be related to usage of -fae: the api comparison mojo writes
> issues in the log and continues the build if -fae is set, then at the end of
> the build, the error is shown but not the logged messages (similarly to test
> mojo reporting "test failures" but not giving details in the error message
> so you need to scroll up).
> Were you using -fae?
I don't know. I didn't configure the JDT job.
Comment 76 Mickael Istria CLA 2020-02-07 09:34:32 EST
(In reply to Dani Megert from comment #75)
> > Do you know a CI build I can see with this issue?
> > Or some steps to reproduce?
> https://ci.eclipse.org/jdt/job/eclipse.jdt.ui-Gerrit/4212/

If you scroll a few lines up, you see the details and the specific API Error, so the cause is close enough.
At the moment, I don't think Tycho eclipse-run goal can allow the application to return a specific error message, nor a way to map an exit code with a specific message. Please open a ticket against Tycho for that so we can investigate possible ways to improve this message.
Comment 77 Dani Megert CLA 2020-02-07 11:33:51 EST
(In reply to Mickael Istria from comment #76)
> (In reply to Dani Megert from comment #75)
> > > Do you know a CI build I can see with this issue?
> > > Or some steps to reproduce?
> > https://ci.eclipse.org/jdt/job/eclipse.jdt.ui-Gerrit/4212/
> 
> If you scroll a few lines up, you see the details and the specific API
> Error, so the cause is close enough.
No one will find this since it is not marked as [Error]. At least the final error should tell the user to look above in the log for API Errors.