Skip to content

Commit

Permalink
feat: Use gapic-generator-java jar in the client library generation p…
Browse files Browse the repository at this point in the history
…rocess (#918)
  • Loading branch information
chanseokoh committed Jan 6, 2023
1 parent 29273a6 commit 0051f49
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 555 deletions.
6 changes: 3 additions & 3 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ fi
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ]
then
echo_status "Running Java linter..."
bazel --batch run --disk_cache="$BAZEL_CACHE_DIR" //:google_java_format_verification
mvn fmt:check
FORMAT_STATUS=$?
if [ $FORMAT_STATUS != 0 ]
then
echo_error "Linting failed." "Please run :google_java_format and try again."
echo_error "Linting failed." "Please run mvn fmt:format and try again."
exit 1
fi
fi
Expand All @@ -118,7 +118,7 @@ fi
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_UNIT_GOLDEN_FILES_CHANGED -gt 0 ]
then
echo_status "Checking unit tests..."
bazel --batch test //:units --disk_cache="$BAZEL_CACHE_DIR"
mvn test
TEST_STATUS=$?
if [ $TEST_STATUS != 0 ]
then
Expand Down
78 changes: 52 additions & 26 deletions .github/workflows/ci-maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: ci-maven
env:
SHOWCASE_VERSION: 0.25.0
jobs:
units:
build:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -22,11 +22,34 @@ jobs:
- run: java -version
- name: Unit Tests
run: |
mvn verify --batch-mode --no-transfer-progress -Dcheckstyle.skip \
mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \
-Dfmt.skip
- run: bazelisk version
- name: Integration Tests
run: |
bazel --batch test //test/integration/...
- name: Gradle Build Generated Storage Client Library
run: |
echo "Building Storage lib from generated source..."
mkdir /tmp/java-storage
bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java
tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage
pushd /tmp/java-storage/google-cloud-storage-v2-java
./gradlew clean build publishToMavenLocal sourcesJar allJars
popd
units-java8:
name: "units (8) except gapic-generator-java"
- name: Gradle Build Generated Compute Client Library
run: |
echo "Building Compute lib from generated source..."
mkdir /tmp/java-compute
bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java
tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute
pushd /tmp/java-compute/google-cloud-compute-small-v1-java
./gradlew clean build publishToMavenLocal sourcesJar allJars
popd
build-java8-except-gapic-generator-java:
name: "build(8) except for gapic-generator-java"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -65,8 +88,8 @@ jobs:
-Dcheckstyle.skip -Dmaven.compiler.useIncrementalCompilation=false \
-Dfmt.skip
units-java8-gapic-generator-java:
name: "units (8) for gapic-generator-java"
build-java8-gapic-generator-java:
name: "build(8) for gapic-generator-java"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -89,6 +112,29 @@ jobs:
shell: bash
run: |
mvn -V -B -ntp surefire:test --projects 'gapic-generator-java'
- run: bazelisk version
- name: Integration Tests
run: |
bazelisk --batch test //test/integration/...
- name: Gradle Build Generated Storage Client Library
run: |
echo "Building Storage lib from generated source..."
mkdir /tmp/java-storage
bazelisk --batch build @com_google_googleapis//google/storage/v2:google-cloud-storage-v2-java
tar zxvf bazel-bin/external/com_google_googleapis/google/storage/v2/google-cloud-storage-v2-java.tar.gz -C /tmp/java-storage
pushd /tmp/java-storage/google-cloud-storage-v2-java
./gradlew clean build publishToMavenLocal sourcesJar allJars
popd
- name: Gradle Build Generated Compute Client Library
run: |
echo "Building Compute lib from generated source..."
mkdir /tmp/java-compute
bazelisk --batch build @com_google_googleapis//google/cloud/compute/v1small:google-cloud-compute-small-v1-java
tar zxvf bazel-bin/external/com_google_googleapis/google/cloud/compute/v1small/google-cloud-compute-small-v1-java.tar.gz -C /tmp/java-compute
pushd /tmp/java-compute/google-cloud-compute-small-v1-java
./gradlew clean build publishToMavenLocal sourcesJar allJars
popd
lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -116,26 +162,6 @@ jobs:
java-version: ${{ matrix.java }}
distribution: temurin
- run: java -version

- name: Bazel File Cache Setup
id: cache-bazel
uses: actions/cache@v3
with:
path: ~/.cache/bazel
key: ${{ runner.os }}-${{ hashFiles('WORKSPACE') }}
restore-keys: ${{ runner.os }}-
- name: Bazel Cache Not Found
if: steps.cache-bazel.outputs.cache-hit != 'true'
run: |
echo "No cache found."
- name: Bazel Cache Found
if: steps.cache-bazel.outputs.cache-hit == 'true'
run: |
echo -n "Cache found. Cache size: "
du -sh ~/.cache/bazel
echo "If the cache seems broken, update the root WORKSPACE file with a trivial change."
echo "The old cache will disappear after 7 days."
- name: Install maven modules
run: |
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip
Expand Down
115 changes: 0 additions & 115 deletions .github/workflows/ci.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ target/

# Vscode Settings
.vscode/settings.json

*.iml
Loading

0 comments on commit 0051f49

Please sign in to comment.