Skip to content

Commit

Permalink
chore: spring-cloud-generator script refactor (#1956)
Browse files Browse the repository at this point in the history
This PR refactors spring-cloud-generator scripts, with the following goals:
* Small fix for pattern-matching when sorting README table entries (follow-up on [1529-comment](#1529 (comment)))
* Post-migration follow-up: simplify amount of script processing and files
  - Different piecewise scripts (e.g. `generate-one.sh`, `setup-build-rule.sh`, ...) consolidated into functions living in `generate-steps.sh`
  - Main script of `generate.sh` contains end-to-end workflow that invokes the various functions defined above
  - This also sets up pieces of the generation generation steps for potential reuse / reducing duplication in the showcase testing generation script ([#1957](#1957)), though related changes are not made in this PR to keep the refactoring incremental.
  • Loading branch information
emmileaf authored Jun 29, 2023
1 parent 3c32c5e commit 6364f89
Show file tree
Hide file tree
Showing 13 changed files with 323 additions and 321 deletions.
28 changes: 4 additions & 24 deletions .github/workflows/generateAutoConfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,6 @@ jobs:
go install github.com/bazelbuild/buildtools/buildozer@latest
export PATH=$PATH:$(go env GOPATH)/bin
buildozer --version
- name: Clean previews folder
continue-on-error: false
working-directory: spring-cloud-generator
run: |
set -x
bash scripts/reset-previews-folder.sh
- name: Generate library list
id: generate_library_list
continue-on-error: false
working-directory: spring-cloud-generator
run: |
set -x
set -e
echo "Libraries BOM version: $LIBRARIES_BOM_VERSION"
MONOREPO_TAG=v$(bash scripts/compute-monorepo-tag.sh -v $LIBRARIES_BOM_VERSION)
echo "MONOREPO_COMMITISH=$MONOREPO_TAG" >> $GITHUB_OUTPUT
bash scripts/generate-library-list.sh -c $MONOREPO_TAG
cat scripts/resources/library_list.txt
env:
LIBRARIES_BOM_VERSION: ${{ steps.get_libraries_bom_version.outputs.LIBRARIES_BOM_VERSION }}
- name: Compile non-autogen libraries
continue-on-error: false
run: |
Expand All @@ -105,15 +85,15 @@ jobs:
set -e
export PATH=$PATH:$(go env GOPATH)/bin
buildozer --version
bash scripts/generate-all.sh -m $MONOREPO_COMMITISH
bash scripts/generate.sh
env:
MONOREPO_COMMITISH: ${{ steps.generate_library_list.outputs.MONOREPO_COMMITISH }}
LIBRARIES_BOM_VERSION: ${{ steps.get_libraries_bom_version.outputs.LIBRARIES_BOM_VERSION }}
- name: Sanity checks
continue-on-error: false
working-directory: spring-cloud-generator/scripts
working-directory: spring-cloud-generator
run: |
set -x
bash sanity-checks.sh
bash scripts/sanity-checks.sh
- name: Check for generation errors
continue-on-error: false
working-directory: spring-cloud-generator
Expand Down
15 changes: 0 additions & 15 deletions spring-cloud-generator/scripts/compute-monorepo-tag.sh

This file was deleted.

81 changes: 0 additions & 81 deletions spring-cloud-generator/scripts/generate-all.sh

This file was deleted.

16 changes: 8 additions & 8 deletions spring-cloud-generator/scripts/generate-library-list.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

WORKING_DIR=`pwd` # spring-cloud-generator
# If not set, assume working directory is spring-cloud-generator
if [[ -z "$SPRING_GENERATOR_DIR" ]]; then
SPRING_GENERATOR_DIR=`pwd`
fi

while getopts c: flag
do
Expand All @@ -10,20 +13,17 @@ do
done
echo "Monorepo tag: $commitish";

# install jq for json parsing if not already installed
sudo apt-get -y install jq

# download the monorepo, need to loop through metadata there
git clone https://github.com/googleapis/google-cloud-java.git

# switch to the specified release commitish
cd ./google-cloud-java
git checkout $commitish

cd ${WORKING_DIR}
cd ${SPRING_GENERATOR_DIR}
# start file, always override is present
filename=${WORKING_DIR}/scripts/resources/library_list.txt
echo "# api_shortname, googleapis-folder, distribution_name:version, googleapis_committish, monorepo_folder" > $filename
filename=${SPRING_GENERATOR_DIR}/scripts/resources/library_list.txt
echo "# api_shortname, googleapis-folder, distribution_name:version, googleapis_committish, monorepo_folder" > "$filename"

# loop through folders
count=0
Expand Down Expand Up @@ -52,7 +52,7 @@ for d in ./google-cloud-java/*java-*/; do
continue
fi
# checks if library is in the manual modules exclusion list
if [[ $(cat ${WORKING_DIR}/scripts/resources/manual_modules_exclusion_list.txt | tail -n+2 | grep $artifact_id | wc -l) -ne 0 ]] ; then
if [[ $(cat ${SPRING_GENERATOR_DIR}/scripts/resources/manual_modules_exclusion_list.txt | tail -n+2 | grep $artifact_id | wc -l) -ne 0 ]] ; then
echo "$artifact_id is already present in manual modules."
continue
fi
Expand Down
100 changes: 0 additions & 100 deletions spring-cloud-generator/scripts/generate-one.sh

This file was deleted.

Loading

0 comments on commit 6364f89

Please sign in to comment.