From cad735bc9e48f247d1ae746a0bd963f212dd41a9 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Fri, 8 Jul 2022 12:42:42 -0400 Subject: [PATCH 1/5] feat: GAPIC library BOM in monorepo_script bootstrap --- README.md | 9 +++++ bom.pom.xml | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++ bootstrap.sh | 41 +++++++++++++++++++++++ parent.pom.xml | 1 + 4 files changed, 141 insertions(+) create mode 100644 bom.pom.xml diff --git a/README.md b/README.md index 1f8596304705..fd8ca0c668da 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,12 @@ For Day 1 cutover, once we have main branch: - Update `googleapis_commit.txt` to an appropriate value - Update `.github/workflows/googleapis_hermetic_sync.yaml` to point to the main branch. + +### The BOM coverage and its version + +Review the artifact name "google-cloud-gapic-bom" in the bom directory and +configure the version managed by Release Please. Ensure the BOM is part of the +entire release pipeline. + +Confirm the effective-pom (`mvn help:effective-pom`) of the BOM covers the same +member of the google-cloud-bom except the handwritten libraries. diff --git a/bom.pom.xml b/bom.pom.xml new file mode 100644 index 000000000000..4909f6c82f46 --- /dev/null +++ b/bom.pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + com.google.cloud + google-cloud-gapic-bom + pom + 0.0.1-SNAPSHOT + Google Cloud Java BOM + https://github.com/googleapis/java-cloud-bom + + BOM for the libraries in google-cloud-java repository. Users should not + depend on this artifact explicitly because this BOM is an implementation + detail of the Libraries BOM. + + +BOM_ARTIFACT_LIST + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + sonatype-nexus-staging + https://google.oss.sonatype.org/ + false + + + + org.apache.maven.plugins + maven-site-plugin + 3.12.0 + + true + + + + + + + + release + + + performRelease + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + + + \ No newline at end of file diff --git a/bootstrap.sh b/bootstrap.sh index adf27be084a3..6febb0b123d0 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -84,3 +84,44 @@ awk -v MODULE=' CoverageAggregator' '/<\/modules>/{print MOD git add --all git commit -am 'feat: create CoverageAggregator module' + +# generate BOM of the artifacts in this repository +bom_lines="" +for bom_directory in $(find . -name 'google-*-bom'); do + pom_file="${bom_directory}/pom.xml" + groupId_line=$(grep --max-count=1 'groupId' "${pom_file}") + artifactId_line=$(grep --max-count=1 'artifactId' "${pom_file}") + version_line=$(grep --max-count=1 'x-version-update' "${pom_file}") + + if [[ $version_line == *"0"* ]]; then + # Not including non-GA libraries, except those that happened to be included + # already in google-cloud-bom. + if [[ $artifactId_line != *"google-cloud-datalabeling"* ]] \ + && [[ $artifactId_line != *"google-cloud-errorreporting"* ]] \ + && [[ $artifactId_line != *"google-cloud-logging-logback"* ]] \ + && [[ $artifactId_line != *"google-cloud-mediatranslation"* ]] \ + && [[ $artifactId_line != *"google-cloud-nio"* ]] \ + && [[ $artifactId_line != *"google-cloud-notification"* ]] \ + && [[ $artifactId_line != *"google-cloud-phishingprotection"* ]]; then + continue + fi + fi + + bom_lines+=" + ${groupId_line} + ${artifactId_line} + ${version_line} + pom + import + +" +done + +mkdir bom +awk -v "dependencyManagements=$bom_lines" '{gsub(/BOM_ARTIFACT_LIST/,dependencyManagements)}1' \ + ../../bom.pom.xml > bom/pom.xml + +git add --all +git commit -am 'feat: create bom module' + +EOL \ No newline at end of file diff --git a/parent.pom.xml b/parent.pom.xml index cb750a374840..ada187cd272b 100644 --- a/parent.pom.xml +++ b/parent.pom.xml @@ -13,6 +13,7 @@ + bom From 9d9e14ec5c51cdfa987ae0c70602af65fc8326f8 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Fri, 8 Jul 2022 12:51:40 -0400 Subject: [PATCH 2/5] fix: fixed typo --- bootstrap.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 6febb0b123d0..27d1c6e7ed4a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -121,7 +121,5 @@ mkdir bom awk -v "dependencyManagements=$bom_lines" '{gsub(/BOM_ARTIFACT_LIST/,dependencyManagements)}1' \ ../../bom.pom.xml > bom/pom.xml -git add --all +git add bom/pom.xml git commit -am 'feat: create bom module' - -EOL \ No newline at end of file From 5373cf57591df2e5785d150feb95cad1ce91f8c2 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Fri, 8 Jul 2022 12:55:32 -0400 Subject: [PATCH 3/5] fix: sort by module name --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 27d1c6e7ed4a..b37f89b3b613 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -87,7 +87,7 @@ git commit -am 'feat: create CoverageAggregator module' # generate BOM of the artifacts in this repository bom_lines="" -for bom_directory in $(find . -name 'google-*-bom'); do +for bom_directory in $(find . -name 'google-*-bom' | sort); do pom_file="${bom_directory}/pom.xml" groupId_line=$(grep --max-count=1 'groupId' "${pom_file}") artifactId_line=$(grep --max-count=1 'artifactId' "${pom_file}") From 3c067d78711451b6f46709de4fa35f0f6fbc2847 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Fri, 8 Jul 2022 14:12:27 -0400 Subject: [PATCH 4/5] fix: fix the build --- bom.pom.xml | 2 ++ bootstrap.sh | 25 +++++++++++++------------ parent.pom.xml | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/bom.pom.xml b/bom.pom.xml index 4909f6c82f46..223ca7973f8d 100644 --- a/bom.pom.xml +++ b/bom.pom.xml @@ -13,7 +13,9 @@ detail of the Libraries BOM. + BOM_ARTIFACT_LIST + diff --git a/bootstrap.sh b/bootstrap.sh index b37f89b3b613..b1168820215e 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -88,12 +88,12 @@ git commit -am 'feat: create CoverageAggregator module' # generate BOM of the artifacts in this repository bom_lines="" for bom_directory in $(find . -name 'google-*-bom' | sort); do + repo_metadata="${bom_directory}/../.repo-metadata.json" pom_file="${bom_directory}/pom.xml" groupId_line=$(grep --max-count=1 'groupId' "${pom_file}") artifactId_line=$(grep --max-count=1 'artifactId' "${pom_file}") version_line=$(grep --max-count=1 'x-version-update' "${pom_file}") - - if [[ $version_line == *"0"* ]]; then + if ! grep --quiet '"release_level": "stable"' "${repo_metadata}"; then # Not including non-GA libraries, except those that happened to be included # already in google-cloud-bom. if [[ $artifactId_line != *"google-cloud-datalabeling"* ]] \ @@ -103,23 +103,24 @@ for bom_directory in $(find . -name 'google-*-bom' | sort); do && [[ $artifactId_line != *"google-cloud-nio"* ]] \ && [[ $artifactId_line != *"google-cloud-notification"* ]] \ && [[ $artifactId_line != *"google-cloud-phishingprotection"* ]]; then + echo "Not adding ${pom_file} to the BOM because it's not stable." continue fi fi - bom_lines+=" - ${groupId_line} - ${artifactId_line} - ${version_line} - pom - import - + bom_lines+=" + ${groupId_line} + ${artifactId_line} + ${version_line} + pom + import + " done -mkdir bom +mkdir google-cloud-gapic-bom awk -v "dependencyManagements=$bom_lines" '{gsub(/BOM_ARTIFACT_LIST/,dependencyManagements)}1' \ - ../../bom.pom.xml > bom/pom.xml + ../../bom.pom.xml > google-cloud-gapic-bom/pom.xml -git add bom/pom.xml +git add google-cloud-gapic-bom/pom.xml git commit -am 'feat: create bom module' diff --git a/parent.pom.xml b/parent.pom.xml index ada187cd272b..5f31cc3520ab 100644 --- a/parent.pom.xml +++ b/parent.pom.xml @@ -13,7 +13,7 @@ - bom + google-cloud-gapic-bom From 6d7fab00c9b021d5fe8416fbdfc8a4783cda6126 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Fri, 8 Jul 2022 15:16:08 -0400 Subject: [PATCH 5/5] fix: run validate before creating CoverageAggregator --- bootstrap.sh | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index b1168820215e..9abd98399aaf 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -42,6 +42,7 @@ do text=${text/api_shortname/api-name} echo -e "\n"$text>> ${service}/.OwlBot.yaml git add . + git config --add secrets.allowed "dest.*src" git commit -am "chore: setup owlbot configuration" cd ../google-cloud-java @@ -63,28 +64,6 @@ cd google-cloud-java git add pom.xml git commit -am 'feat: create aggregator pom' -cp -r --preserve=all ../../templates/. ./ -git add --all -git commit -m 'chore: add template files' - -# generate coverage report -mkdir CoverageAggregator -cp ../../coverage.pom.xml CoverageAggregator/pom.xml - -# create aggregator project for jacoco -mvn compile -Dexec.executable='echo' \ --Dexec.args='${project.groupId}${project.artifactId}${project.version}' \ -exec:exec -q -B | grep -v 'CoverageAggregator\|bom\|parent\|proto\-\|grpc-\|google\-cloud\-java' >> ../coverage-modules.txt - -# insert processed modules into coverage aggregator pom.xml -awk -v MODULES="`awk -v ORS='\\\\n' '1' ../coverage-modules.txt`" '1;//{print MODULES}' ../../coverage.pom.xml > CoverageAggregator/pom.xml - -# add CoverageAggregator to root pom -awk -v MODULE=' CoverageAggregator' '/<\/modules>/{print MODULE};1' pom.xml > pom.xml.tmp && mv pom.xml.tmp pom.xml - -git add --all -git commit -am 'feat: create CoverageAggregator module' - # generate BOM of the artifacts in this repository bom_lines="" for bom_directory in $(find . -name 'google-*-bom' | sort); do @@ -124,3 +103,31 @@ awk -v "dependencyManagements=$bom_lines" '{gsub(/BOM_ARTIFACT_LIST/,dependencyM git add google-cloud-gapic-bom/pom.xml git commit -am 'feat: create bom module' + +# Confirm everything is fine so far +mvn -q -B -ntp validate + + +# Template files +cp -r --preserve=all ../../templates/. ./ +git add --all +git commit -m 'chore: add template files' + + +# generate coverage report +mkdir CoverageAggregator +cp ../../coverage.pom.xml CoverageAggregator/pom.xml + +# create aggregator project for jacoco +mvn compile -Dexec.executable='echo' \ +-Dexec.args='${project.groupId}${project.artifactId}${project.version}' \ +exec:exec -q -B | grep -v 'CoverageAggregator\|bom\|parent\|proto\-\|grpc-\|google\-cloud\-java' >> ../coverage-modules.txt + +# insert processed modules into coverage aggregator pom.xml +awk -v MODULES="`awk -v ORS='\\\\n' '1' ../coverage-modules.txt`" '1;//{print MODULES}' ../../coverage.pom.xml > CoverageAggregator/pom.xml + +# add CoverageAggregator to root pom +awk -v MODULE=' CoverageAggregator' '/<\/modules>/{print MODULE};1' pom.xml > pom.xml.tmp && mv pom.xml.tmp pom.xml + +git add --all +git commit -am 'feat: create CoverageAggregator module'