Skip to content

Commit

Permalink
chore: Convert existing CI workflows to maven (#376)
Browse files Browse the repository at this point in the history
* chore: Add initial pom.xml

* chore: Convert workflows to maven

* chore: Cleanup the existing workflows

* chore: Fix format of ci.yaml

* chore: Fix format of ci.yaml

* chore: Use seperate job for java 8

* chore: Update required status checks

* chore: Run java formatter

* chore: Resolve checkstyle issues

* chore: Empty commit

* chore: Run on java 11 or lint job

* chore: Change to use temurin

* chore: Empty commit

* chore: Update for PR comments

* chore: Add clirr check in GH actions

* chore: Revert build.gradle to google, inc

* chore: Revert license to Inc.

* chore: Revert license to Inc.

* chore: Update license in files

* chore: Update the rest of the files to correct license

* chore: temp add in old ci workflows for status checks

* chore: temp remove required status checks

* chore: revert previous commit
  • Loading branch information
lqiu96 authored Nov 29, 2022
1 parent e2b1325 commit 5cb5ca2
Show file tree
Hide file tree
Showing 57 changed files with 406 additions and 870 deletions.
36 changes: 24 additions & 12 deletions api-common-java/.github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,65 @@ branchProtectionRules:
- pattern: main
isAdminEnforced: true
requiredStatusCheckContexts:
- units
- format
- units (8)
- units (11)
- units (17)
- lint
- cla/google
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: true
- pattern: 1.10.1-sp
isAdminEnforced: true
requiredStatusCheckContexts:
- units
- format
- units (8)
- units (11)
- units (17)
- lint
- cla/google
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: true
- pattern: java7
isAdminEnforced: true
requiredStatusCheckContexts:
- units
- format
- units (8)
- units (11)
- units (17)
- lint
- cla/google
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: true
- pattern: 2.0.x
isAdminEnforced: true
requiredStatusCheckContexts:
- units
- format
- units (8)
- units (11)
- units (17)
- lint
- cla/google
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: true
- pattern: 2.1.x
isAdminEnforced: true
requiredStatusCheckContexts:
- units
- format
- units (8)
- units (11)
- units (17)
- lint
- cla/google
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: true
- pattern: 2.2.x
isAdminEnforced: true
requiredStatusCheckContexts:
- units
- format
- units (8)
- units (11)
- units (17)
- lint
- cla/google
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
Expand Down
115 changes: 98 additions & 17 deletions api-common-java/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,104 @@ jobs:
JVM_OPTS: -Xmx3200m
TERM: dumb
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- run: java -version
- name: Gradle Assemble
run: ./gradlew assemble
- name: Gradle Test
run: ./gradlew test
- name: Gradle Build
run: ./gradlew build publishToMavenLocal
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- run: java -version
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- name: Java Linter
run: ./gradlew googleJavaFormat
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
clirr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
- run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
- run: .kokoro/build.sh
env:
JOB_TYPE: clirr
units-8:
name: units (8) - Maven
runs-on: ubuntu-latest
steps:
- name: Get current week within the year
id: date
run: echo "::set-output name=week_of_year::$(date +'%W' --utc)"
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 8
distribution: temurin
- run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
- run: echo "JAVA11_HOME=${JAVA_HOME}" >> $GITHUB_ENV
- uses: actions/cache@v3
id: mvn-cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-unified-${{ steps.date.outputs.week_of_year }}
- run: .kokoro/build.sh
env:
JOB_TYPE: test
JOB_NAME: units-8
units-maven:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 11, 17 ]
steps:
- name: Get current week within the year
id: date
run: echo "::set-output name=week_of_year::$(date +'%W' --utc)"
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{matrix.java}}
- run: java -version
- uses: actions/cache@v3
id: mvn-cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-unified-${{ steps.date.outputs.week_of_year }}
- run: .kokoro/build.sh
env:
JOB_TYPE: test
JOB_NAME: units-${{matrix.java}}
lint:
runs-on: ubuntu-latest
steps:
- name: Get current week within the year
id: date
run: echo "::set-output name=week_of_year::$(date +'%W' --utc)"
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- run: java -version
- uses: actions/cache@v3
id: mvn-cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-unified-${{ steps.date.outputs.week_of_year }}
- run: java -version
- run: mvn -B -ntp com.coveo:fmt-maven-plugin:check
- run: mvn -B -ntp checkstyle:check@checkstyle
2 changes: 1 addition & 1 deletion api-common-java/.github/workflows/downstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v3
with:
distribution: zulu
distribution: temurin
java-version: ${{matrix.java}}
- run: java -version
- run: sudo apt-get update -y
Expand Down
2 changes: 2 additions & 0 deletions api-common-java/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ tmp_gh-pages

# Vim
*.sw*

target/
3 changes: 0 additions & 3 deletions api-common-java/.kokoro/build.bat

This file was deleted.

53 changes: 48 additions & 5 deletions api-common-java/.kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,54 @@

set -eo pipefail

cd github/api-common-java/
## Get the directory of the build script
scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
## cd to the parent directory, i.e. the root of the git repo
cd ${scriptDir}/..

# Print out Java
# include common functions
source ${scriptDir}/common.sh

function setJava() {
export JAVA_HOME=$1
export PATH=${JAVA_HOME}/bin:$PATH
}

# This project requires compiling the classes in JDK 11 or higher for GraalVM
# classes. Compiling this project with Java 8 or earlier would fail with "class
# file has wrong version 55.0, should be 53.0" and "unrecognized --release 8
# option" (set in build.gradle).
if [ ! -z "${JAVA11_HOME}" ]; then
setJava "${JAVA11_HOME}"
fi

echo "Compiling using Java:"
java -version
echo $JOB_TYPE
mvn clean install -B -Dcheckstyle.skip -Dfmt.skip

# We ensure the generated class files are compatible with Java 8
if [ ! -z "${JAVA8_HOME}" ]; then
setJava "${JAVA8_HOME}"
fi

RETURN_CODE=0

./gradlew assemble
./gradlew build install
case ${JOB_TYPE} in
test)
retry_with_backoff 3 10 \
mvn -B -ntp \
-Dclirr.skip=true \
-Denforcer.skip=true \
-Dcheckstyle.skip=true \
-Dflatten.skip=true \
-Danimal.sniffer.skip=true \
-Dmaven.wagon.http.retryHandler.count=5 \
test
RETURN_CODE=$?
;;
clirr)
mvn -B -ntp -Denforcer.skip=true clirr:check
RETURN_CODE=$?
;;
*) ;;
esac
6 changes: 5 additions & 1 deletion api-common-java/.kokoro/coerce_logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
## cd to the parent directory, i.e. the root of the git repo
cd ${scriptDir}/..

job=$(basename ${KOKORO_JOB_NAME})
if [ -z "${KOKORO_JOB_NAME}" ]; then
job="${JOB_NAME}"
else
job=$(basename ${KOKORO_JOB_NAME})
fi

echo "coercing sponge logs..."
for xml in `find . -name *-sponge_log.xml`
Expand Down
25 changes: 0 additions & 25 deletions api-common-java/.kokoro/continuous/common.cfg

This file was deleted.

7 changes: 0 additions & 7 deletions api-common-java/.kokoro/continuous/java11.cfg

This file was deleted.

7 changes: 0 additions & 7 deletions api-common-java/.kokoro/continuous/java7.cfg

This file was deleted.

12 changes: 0 additions & 12 deletions api-common-java/.kokoro/continuous/java8.cfg

This file was deleted.

Loading

0 comments on commit 5cb5ca2

Please sign in to comment.