Commit graph

50 commits

Author SHA1 Message Date
daz
d4e24dfc10
Register pre-installed JDKs in .m2/toolchains.xml
Since adding these to the `org.gradle.java.installations.fromEnv` property
is problematic (#1024), this mechanism allows the default toolchains to
be discovered by Gradle via a different mechanism.

The default JDK installations are added to `~/.m2/toolchains.xml` such that
they are discoverable by Gradle toolchain support.
The `setup-java` action also writes to this file, so we merge with any existing
content: this allows both pre-installed and "setup" JDKs to be automatically
detected by Gradle.
2024-01-03 21:08:40 -07:00
daz
a4dabb3a70
Adapt dependency-graph support for new artifact API
- Don't upload artifacts when using 'generate-and-submit'
- New option 'generate-and-upload' to be used with 'download-and-submit'
- Use Artifact API for downloading in the same and different workflow
2023-12-23 21:24:11 -07:00
daz
982da8e78c
Attempt to make init-script compatible with Gradle 1.12
The `PluginManager` type wasn't introduced until Gradle 2.x.
Remove this type from the method signature in an attempt to allow this
file to be parsed with Gradle 1.12.
2023-12-19 14:12:27 -07:00
daz
8cbcb9948b
Plugin repository URL is configurable
The repository URL used to resolve the `github-dependency-graph-gradle-plugin` is now
configurable, allowing a user to specify an internal proxy if the public portal is not available.

Specify a custom plugin repository using the `GRADLE_PLUGIN_REPOSITORY_URL` env var,
or the `gradle.plugin-repository.url` System property.

Fixes #933
2023-12-11 21:15:34 -07:00
daz
77699bae74
Handle failure writing build-results file
Fixes #866
2023-12-11 20:18:58 -07:00
daz
87a9a15658
Use 1.0.0 release of dependency graph plugin 2023-11-27 17:46:35 +10:00
daz
8b6c211905
Bump to RC of github dependency graph plugin 2023-11-08 21:11:42 -08:00
daz
d1b726d8c1 Do not generate dependency graph in cache-cleanup
- Allow environment variables to be overridden by system properties in dependency-graph initscript
- Set `GITHUB_DEPENDENCY_GRAPH_ENABLED=false` when executing Gradle for cache cleanup
2023-09-29 22:55:54 +02:00
daz
324fbdc804
Update to dep-graph plugin 0.4.1 2023-09-29 13:22:08 -06:00
daz
4441c9f9bf Update to dep-graph plugin 0.4.0 2023-09-26 15:51:30 +02:00
Daz DeBoer
ef76a971e2
Simplify GE-inject config params (#863) 2023-08-28 11:59:09 -06:00
daz
05acc776e8
Wire new init-script into action
- Copy init-script to Gradle User Home
- Rename init-scripts for consistency and clarity
2023-08-20 16:29:23 -06:00
daz
97d9c134b7
Add init-script for Gradle Enterprise injection
Adds a new init-script which can enable and configure the Gradle Enterprise plugin(s)
for a build, without needing to modify the settings script for the project.
The functionality is enabled and configured via environment variables or system properties.

Not yet wired into `gradle-build-action`.
2023-08-20 16:29:23 -06:00
daz
9e58f8b1de
Add dependency-graph-file as step output
Fixes #804
2023-07-24 08:37:14 -06:00
daz
632e888003
Update to the latest dependency-graph plugin
- Remove experimental warning
- Update documentation
2023-07-24 08:37:14 -06:00
daz
ced6859e9c
Update Build Scan™ to Build Scan® 2023-07-22 08:53:58 -06:00
daz
915a66c096
Bump dependency-graph version number 2023-07-17 15:46:14 -06:00
daz
9f977db2d8
Update to latest plugin version 2023-07-17 15:12:30 -06:00
daz
f59a6d4310
Avoid log messages for included builds 2023-07-15 22:33:54 -06:00
daz
b69de5f2a9
Support multiple invocations in dependency-graph init script
If an existing dependency graph file is present for the configured job correlator,
we now generate a unique correlator value for the invocation. This allows the action
to submit dependency snapshots for a series of Gradle invocations within the same Job.

This commit updates to `github-dependency-graph-gradle-plugin@v0.0.6`, which reduces
redundancy in the mapping of resolved Gradle dependencies to the GitHub Dependency Graph.
2023-07-15 22:33:31 -06:00
daz
cef72ff9e4
Use latest github-dependency-graph-gradle-plugin 2023-07-10 07:16:49 -06:00
daz
f01b48d89d
Do not attempt dependency graph on unsupported Gradle versions 2023-07-07 20:42:49 -06:00
daz
1e71bceb3f
Supply plugin portal URL directly
The 'gradlePluginPortal()' convenience isn't supported in older Gradle versions.
2023-07-07 20:42:49 -06:00
daz
820b228f28
Switch back to using published plugin 2023-07-07 20:42:48 -06:00
daz
4c9c435d2f
Configure Gradle User Home for dependency-graph
Instead of requiring an action step to generate the graph, configure Gradle User Home
so that subsequent Gradle invocations can generate a graph. Any generated graph files
are uploaded as artifacts on job completion.

- Construct job.correlator from workflow/job/matrix
- Export job.correlator as an environment var
- Upload artifacts at job completion in post-action step
- Specify the location of dependency graph report
- Only apply dependency graph init script when explicitly enabled
2023-07-07 20:42:48 -06:00
daz
a6ad1901be
Copy dependency graph init script to Gradle Home
- Temporarily use a hard-coded plugin for convenience
2023-07-07 20:42:48 -06:00
daz
be413309fa
First cut at actions for dependency-graph
- Dependency graph init-script references published version of plugin jar.
- `dependency-graph-generate` action will:
     - Provision Gradle if required
     - Execute Gradle with dependency-graph plugin to generate graph JSON
     - Upload dependency-graph JSON file as workflow artifact
- `dependency-graph-submit` action will:
    - Download dependency-graph JSON artifact
    - Submit the graph via the GitHub dependency submission API
2023-06-28 11:24:57 -06:00
daz
a580d9bd57
Detect GE plugin applied in settingsEvaluated
The `PluginManager.hasPlugin` method was not detecting the GE plugin when it
was applied during settingsEvaluated.
Switching to `PluginManager.withPlugin` fixes this.

Fixes #626
2023-04-26 10:49:32 -06:00
Daz DeBoer
6095a76664
Update tests for Gradle 8 2023-02-18 13:25:58 -07:00
Daz DeBoer
3fbe033aaa
Retain 'set-output' command when GITHUB_OUTPUT is not set
This should maintain compatibility with older GitHub Enterprise versions
2022-10-22 08:20:16 -06:00
Daz DeBoer
3b959539de
Remove use of deprecated 'set-output' command
- Use GITHUB_OUTPUT file in init script
- Write to a marker file in configuratiion-cache tests

Fixes #461
2022-10-20 14:09:12 -06:00
Daz DeBoer
394498f89f
Avoid appending to existing build-results file
When configuration-cache is enabled, the invocationId may not be unique, which can result in
mulitple builds writing to the same file. Rather than failing the post-action, we simply
ignore any subsequent build results with the same ID.

Fixes #441
2022-09-26 11:03:26 -06:00
Daz DeBoer
531cc21aeb
Clarify comment 2022-08-25 20:26:16 -06:00
Daz DeBoer
792a93a5e3
Do not write build-results file outside GitHub Actions context
The init-scripts added to Gradle User Home were assuming the presence of certain
GitHub Actions environment variables. With this fix, these init scripts behave
better without these env vars.

Fixes #350
2022-07-11 15:09:56 -06:00
Daz DeBoer
df4c1902a6
Extract common functionality for recording build results 2022-06-15 08:29:55 -06:00
Daz DeBoer
132237ba05
Capture failure to publish build scan in results 2022-06-15 08:08:41 -06:00
Daz DeBoer
3d091fa7a8
Move initscripts into src/resources/init-scripts 2022-06-11 09:33:38 -06:00
Daz DeBoer
0b5047ec4d
Prevent duplicate JSON being written to build-results 2022-06-05 21:55:11 -06:00
Daz DeBoer
e644288a42
Use build-results file for root project dirs
Instead of using a separate mechanism and init script, reuse the information
captured in the build-results file.
2022-06-05 08:34:07 -06:00
Daz DeBoer
e234151ec9
Add more information to captured build results
- Root project dir: will allow us to replace project-root-capture init script
- Gradle home dir: will allow us to stop all started daemons
2022-06-05 08:18:25 -06:00
Daz DeBoer
3f2d9cde44
Capture build results when GE plugin is applied but no build-scan is published 2022-06-05 00:32:29 -06:00
Daz DeBoer
5203a0b09d
Capture build results when config-cache is enabled
When enabled, the configuration-cache will cause the build to fail when a
`buildFinished` listener is added. Instead, use a BuildService to listen for task
failures and to write the results on build completion.
2022-06-05 00:29:42 -06:00
Daz DeBoer
500607bc35
Capture build-results without build-scan publication
The `buildScanPublished` is only called when a build scan is published by the build.
Support other invocations by adding a `buildFinished` listener.
2022-06-05 00:28:24 -06:00
Daz DeBoer
748dc30fdc
Support and test Gradle 3.5.1
Fix build-scan-capture.init.gradle so that it applies to versions 3.+,
and include this version in test coverage.
2022-06-05 00:26:21 -06:00
Daz DeBoer
ece69c52b2
Save project-root-list in RUNNER_TEMP dir
This feels better than saving in Gradle User Home and is consistent
with where the build results are written.
2022-06-05 00:24:57 -06:00
Daz DeBoer
dff0fe1b20
Remove debug output from init script 2022-06-03 13:51:36 -06:00
Daz DeBoer
ae74c01440
Use a BuildService to always collect project root
Using `settingsEvaluated` meant that the project root was not recorded
when the build was run with a config-cache hit. This meant that the subsequent
build would not restore the config-cache, resulting in a cache miss.

In order to avoid issues running the init script on older versions of Gradle
the project-collection is extracted into a separate groovy file that is only
applied conditionally on Gradle 7 or higher.
2022-06-03 13:51:36 -06:00
Daz DeBoer
6cc033f2b3
Make build-result-capture script compatible with config-cache 2022-06-03 07:12:23 -06:00
Daz DeBoer
86e82987ba
Write job summary in post action
- Save build results in file encoded as JSON
- Read all build results in post action and render as table in job summary
2022-06-02 12:58:49 -06:00
Daz DeBoer
d95713bd5d
Extract init scripts into resource files 2022-06-02 11:53:33 -06:00