-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: add dependency versions script #741
Closed
Closed
Changes from 57 commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
945f7d1
Update ci.yaml
salehsquared d80399b
Check version of google-cloud-shared-config
salehsquared afc4204
Update pom.xml
salehsquared 98282ff
Update ci.yaml
salehsquared 1861d3b
Update pom.xml
salehsquared 438e5fa
Update ci.yaml
salehsquared 02e35fb
Update ci.yaml
salehsquared 77be68a
Updating permissions on versions script
ed61410
deps: update dependency com.google.cloud:google-cloud-logging-logback…
salehsquared 9f1fb9a
deps: update dependency com.google.cloud:google-cloud-firestore-bom t…
salehsquared e224876
Reverting pom.xml after testing changes
0edb0e5
Merge branch 'master' of https://github.com/salehsquared/java-cloud-bom
ed33def
Reverting POM version
b1fe397
Reverting POM version
14c43ec
Fixing formatting change on ci file
1150208
Fixing formatting change on ci file
2616081
Fix for formatting end of file
b164f1a
Updated dependencies scripts. Separated out, so one script checks for…
1ad1ae1
Setting ci.yaml file back to original
807140c
Merge branch 'dependency-versions' of https://github.com/salehsquared…
9ad1268
Updates to make deps-finder more stable, including using regex. Also …
8affd08
Updated deps-finder according to comments from Stephanie, Elliotte, a…
ebbdf93
Updating pom.xml to master branch
8310661
Merge branch 'master' into dependency-versions
salehsquared 7d745a5
Formatting and curl fixes
0c7f9b6
Merge branch 'dependency-versions' of https://github.com/salehsquared…
9d30f20
Merge branch 'master' of https://github.com/googleapis/java-cloud-bom…
741029e
Separate script for helper functions, conventionalized syntax, verbos…
39a4c5e
Updated release-versions to match conventions & be more stable readin…
3039986
Merge branch 'master' into dependency-versions
stephaniewang526 00f6482
Merge branch 'master' into dependency-versions
stephaniewang526 0b51040
Merge branch 'master' into dependency-versions
salehsquared df19e1c
Reformatted comments and added licensing
518f622
Last commenting format change
806be9d
Reformatted to IntelliJ standards
0c0e543
Removing extra words in comment
ca0ec24
Merge branch 'master' into dependency-versions
salehsquared 4009c11
Place checkLibrary into shared-deps-helper.sh. Fixed comment and argu…
c0ce06f
Place checkLibrary into shared-deps-helper.sh. Fixed comment and argu…
f25db57
Merge branch 'dependency-versions' of https://github.com/salehsquared…
bdaa2e9
Removes shared-deps-helper dependence on separated lines
26c6b6b
No longer depending on spacing or line breaks.
782176b
Merge branch 'master' into dependency-versions
salehsquared 02b6eb1
Merge branch 'master' into dependency-versions
stephaniewang526 61e3153
Removed bash scripts and replaced with dependency convergence script …
b772048
Added POM File Change for DependencyUpdateTest & Removed Bash Scripts
043e903
Fixed accidental removal of dependencies.sh
fc11734
Removed deps-finder.sh
1c56168
Cleaned up pom.xml file
44b422a
Cleaned up and removed unnecessary code
7f7a55e
Cleaned code significantly using enum
dc0a76e
Removed unnecessary import
61e5c26
Styling and removed unnecessary imports
6324604
Merge branch 'master' into dependency-versions
salehsquared 8810d5f
Added JUnit Testing and updated Arguments link
048ed26
Merge branch 'dependency-versions' of https://github.com/salehsquared…
4dbc17b
Fixes for Jeff's & Elliotte's comments. Now wrapped in Bash script, n…
87f8c8d
Placed into com.google.cloud. More descriptive error messages. Slight…
fab9af0
Slight change to dependencies script
f07dd58
Merge branch 'master' into dependency-versions
salehsquared 9dc9352
Fixed styling, added new test
125592c
Styling changes
535b378
Merge branch 'master' into dependency-versions
salehsquared 9edb579
Merge branch 'master' into dependency-versions
salehsquared ce9f1a1
Merge branch 'master' into dependency-versions
salehsquared 4098f96
Merge branch 'master' into dependency-versions
stephaniewang526 26b4049
Merge branch 'master' into dependency-versions
salehsquared ea188ac
Update RecentCommitCheckTest.java
salehsquared 034fdca
Merge branch 'master' into dependency-versions
salehsquared d63bce8
Merge branch 'master' into dependency-versions
stephaniewang526 9ec29e2
Merge branch 'master' into dependency-versions
salehsquared File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Print out Java | ||
java -version | ||
|
||
# Get the directory of the build script | ||
scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) | ||
|
||
# Returns 0 if this is a release branch | ||
function isReleaseBranch() { | ||
# Check if we're currently on a non-SNAPSHOT release branch. | ||
currBranch=$(git rev-parse --abbrev-ref HEAD | grep "release-v") | ||
snapShotCheck=$(echo ${currBranch} | grep "\-SNAPSHOT") | ||
# Return 1 (failure) if this is not a release branch | ||
if [[ -z ${currBranch} ]] || [[ ! -z ${snapShotCheck} ]]; then | ||
return 1 | ||
fi | ||
echo ${currBranch} | ||
return 0 | ||
} | ||
|
||
# Returns 0 if a library update commit was found, and 1 otherwise. | ||
# Echos commit message (if found) before completion. | ||
function getLibraryUpdateCommit() { | ||
currentCommitNumber=$(git rev-parse HEAD) | ||
|
||
# Check if we're updating a dependency including shared-dependencies. | ||
currentCommitMessage=$(git log -1 ${currentCommitNumber} | grep "deps: update dependency com.google.cloud:google-cloud-") | ||
|
||
if [[ -z ${currentCommitMessage} ]]; then | ||
return 1 | ||
fi | ||
|
||
echo ${currentCommitMessage} | ||
return 0 | ||
} | ||
|
||
runRelease=$(isReleaseBranch) | ||
returnValue=$? | ||
# If this is a release branch | ||
if [[ ${returnValue} -eq 0 ]]; then | ||
# go to the dependency-convergence directory, i.e. our container for the script | ||
pushd "${scriptDir}/../dependency-convergence" | ||
mvn clean install -DskipTests | ||
# Single quotes around double quotes so that the branch name is counted as only one argument | ||
mvn exec:java -Dexec.args="'${runRelease}'" | ||
exitCode=$? | ||
popd | ||
exit ${exitCode} | ||
fi | ||
|
||
libraryUpdate=$(getLibraryUpdateCommit) | ||
returnValue=$? | ||
|
||
if [[ ${returnValue} -eq 0 ]]; then | ||
# go to the dependency-convergence directory, i.e. our container for the script | ||
pushd "${scriptDir}/../dependency-convergence" | ||
mvn clean install -DskipTests | ||
mvn exec:java -e -Dexec.args="'${libraryUpdate}'" | ||
exitCode=$? | ||
popd | ||
exit ${exitCode} | ||
fi | ||
|
||
echo "No release or library updates found! Assuming no error." | ||
salehsquared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.google.cloud.tools</groupId> | ||
<artifactId>dependencies-parent</artifactId> | ||
<version>1.5.0</version> | ||
</parent> | ||
<groupId>com.google.cloud.tools</groupId> | ||
<artifactId>google-cloud-bom-dependencies-check</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<name>Google Cloud BOM Dependencies Check</name> | ||
<organization> | ||
<name>Google LLC.</name> | ||
<url>https://www.google.com</url> | ||
</organization> | ||
|
||
<licenses> | ||
<license> | ||
<name>The Apache License, Version 2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
</license> | ||
</licenses> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.cloud.tools</groupId> | ||
<artifactId>dependencies</artifactId> | ||
<version>1.5.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<configuration> | ||
<skip>false</skip> | ||
<mainClass>cloudbomcommitcheck.RecentCommitCheck</mainClass> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
145 changes: 145 additions & 0 deletions
145
dependency-convergence/src/main/java/cloudbomcommitcheck/Arguments.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
* Copyright 2020 Google LLC. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package cloudbomcommitcheck; | ||
salehsquared marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import javax.annotation.Nullable; | ||
import org.apache.commons.cli.CommandLine; | ||
import org.apache.commons.cli.CommandLineParser; | ||
import org.apache.commons.cli.DefaultParser; | ||
import org.apache.commons.cli.HelpFormatter; | ||
import org.apache.commons.cli.Option; | ||
import org.apache.commons.cli.OptionGroup; | ||
import org.apache.commons.cli.Options; | ||
import org.apache.commons.cli.ParseException; | ||
|
||
/** | ||
* Command-line option for {@link RecentCommitCheck}. The tool takes either a pom.xml file path or | ||
* Maven coordinates for a BOM. | ||
* | ||
* @see <a href="https://github.com/googleapis/java-cloud-bom/blob/master/dashboard/src/main/java/com/google/cloud/tools/opensource/cloudbomdashboard/DashboardArguments.java"</a> | ||
*/ | ||
final class Arguments { | ||
|
||
private static final Options options = configureOptions(); | ||
private static final HelpFormatter helpFormatter = new HelpFormatter(); | ||
|
||
private final CommandLine commandLine; | ||
|
||
private Arguments(CommandLine commandLine) { | ||
this.commandLine = commandLine; | ||
} | ||
|
||
/** | ||
* Returns true if the argument for a file is specified. False if the argument for coordinates is | ||
* specified. | ||
* | ||
* <p>It is guaranteed that either a file path or Maven coordinates for a BOM are available. | ||
*/ | ||
boolean hasFile() { | ||
return commandLine.hasOption('f'); | ||
} | ||
|
||
/** | ||
* Returns true if the argument for a versionless coordinates is specified; otherwise false. | ||
* | ||
* <p>It is guaranteed that either a file path or Maven coordinates for a BOM are available. | ||
*/ | ||
boolean hasVersionlessCoordinates() { | ||
return commandLine.hasOption('a'); | ||
} | ||
|
||
/** | ||
* Returns an absolute path to pom.xml file of a BOM. Null if file is not specified. | ||
*/ | ||
@Nullable | ||
Path getBomFile() { | ||
if (!commandLine.hasOption('f')) { | ||
return null; | ||
} | ||
// Trim the value so that maven exec plugin can pass arguments with exec.arguments="-f pom.xml" | ||
return Paths.get(commandLine.getOptionValue('f').trim()).toAbsolutePath(); | ||
} | ||
|
||
/** | ||
* Returns the Maven coordinates of a BOM. Null if coordinates are not specified. | ||
*/ | ||
@Nullable | ||
String getBomCoordinates() { | ||
if (!commandLine.hasOption('c')) { | ||
return null; | ||
} | ||
return commandLine.getOptionValue('c').trim(); | ||
} | ||
|
||
/** | ||
* Returns the versionless Maven coordinates of a BOM. Null if versionless coordinates are not | ||
* specified. | ||
*/ | ||
@Nullable | ||
String getVersionlessCoordinates() { | ||
if (!commandLine.hasOption('a')) { | ||
return null; | ||
} | ||
return commandLine.getOptionValue('a').trim(); | ||
} | ||
|
||
static Arguments readCommandLine(String... arguments) throws ParseException { | ||
CommandLineParser parser = new DefaultParser(); | ||
|
||
try { | ||
// Throws ParseException if required option group ('-f' or '-c') is not specified | ||
return new Arguments(parser.parse(options, arguments)); | ||
} catch (ParseException ex) { | ||
helpFormatter.printHelp("DashboardMain", options); | ||
throw ex; | ||
} | ||
} | ||
|
||
private static Options configureOptions() { | ||
Options options = new Options(); | ||
OptionGroup inputGroup = new OptionGroup(); | ||
inputGroup.setRequired(true); | ||
|
||
Option inputFileOption = | ||
Option.builder("f").longOpt("bom-file").hasArg().desc("File to a BOM (pom.xml)").build(); | ||
inputGroup.addOption(inputFileOption); | ||
|
||
Option inputCoordinatesOption = | ||
Option.builder("c") | ||
.longOpt("bom-coordinates") | ||
.hasArg() | ||
.desc( | ||
"Maven coordinates of a BOM. For example, com.google.cloud:libraries-bom:1.0.0") | ||
.build(); | ||
inputGroup.addOption(inputCoordinatesOption); | ||
|
||
Option versionlessCoordinatesOption = | ||
Option.builder("a") | ||
.longOpt("all-versions") | ||
.hasArg() | ||
.desc( | ||
"Maven coordinates of a BOM without version. " | ||
+ "For example, com.google.cloud:libraries-bom") | ||
.build(); | ||
inputGroup.addOption(versionlessCoordinatesOption); | ||
|
||
options.addOptionGroup(inputGroup); | ||
return options; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest we break these into separate checks (rather than re-using the same check). We can run these from GitHub actions and skip if the commit does not match what we expect.