pull_request triggered by smallsheeeep 🚀 #713
Workflow file for this run
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
### | |
# This workflow is used for daily development | |
# Triggers: | |
# 1. Push | |
# 2. Pull-Request | |
# Jobs: | |
# 1. Check Code Format | |
# 2. PMD Scan | |
# 3. Unit Test | |
# 4. Calculate Version Number | |
# 5. Build RPM (exclude front resources and only x86_64 platform for now) | |
# (Job 3 to 5 are executed only when Pull-Request) | |
### | |
name: Build Dev | |
run-name: ${{ github.event_name }} triggered by ${{ github.actor }} 🚀 | |
on: | |
push: | |
branches: | |
- "**" | |
pull_request: | |
branches: | |
- "**" | |
jobs: | |
check-format: | |
name: Check Code Format | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v3 | |
- name: Setup JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "8" | |
distribution: "temurin" | |
cache: maven | |
- name: Check code format | |
run: mvn impsort:check formatter:validate | |
- name: Check license | |
run: mvn license:check | |
pmd-scan: | |
name: PMD Scan | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v3 | |
- name: Setup JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "8" | |
distribution: "temurin" | |
cache: maven | |
- name: Install db-browser | |
run: | | |
echo "Start install db-browser" | |
pushd libs/db-browser | |
echo "Current dir is "`pwd` | |
mvn clean install -Dmaven.test.skip=true | |
echo "Install db-browser success" | |
popd | |
- name: Install ob-sql-parser | |
run: | | |
echo "Start install ob-sql-parser" | |
pushd libs/ob-sql-parser | |
echo "Current dir is "`pwd` | |
mvn clean install -Dmaven.test.skip=true | |
echo "Install ob-sql-parser success" | |
popd | |
- name: Build project | |
run: mvn clean install -Dmaven.test.skip=true | |
- name: Run PMD scan | |
run: mvn pmd:check | |
unit-test-odc: | |
name: Unit Test (ODC) | |
if: ${{ github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
ut-group: | |
- group_1 | |
- group_2 | |
- group_3 | |
- group_4 | |
- group_5 | |
- group_6 | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v3 | |
- name: Setup JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "8" | |
distribution: "temurin" | |
cache: maven | |
- name: Install db-browser | |
run: | | |
echo "Start install db-browser" | |
pushd libs/db-browser | |
echo "Current dir is "`pwd` | |
mvn clean install -Dmaven.test.skip=true | |
echo "Install db-browser success" | |
popd | |
- name: Install ob-sql-parser | |
run: | | |
echo "Start install ob-sql-parser" | |
pushd libs/ob-sql-parser | |
echo "Current dir is "`pwd` | |
mvn clean install -Dmaven.test.skip=true | |
echo "Install ob-sql-parser success" | |
popd | |
- name: Build project | |
run: mvn clean install -Dmaven.test.skip=true | |
- name: Run unit test | |
id: unit_test | |
run: | | |
export ODC_CONFIG_SECRET=${{ secrets.ODC_UT_SECRET }} | |
export ODC_OB_DEFAULT_MYSQL_COMMANDLINE=${{ secrets.ODC_OB_DEFAULT_MYSQL_COMMANDLINE }} | |
export ODC_OB_DEFAULT_ORACLE_COMMANDLINE=${{ secrets.ODC_OB_DEFAULT_ORACLE_COMMANDLINE }} | |
export ODC_MYSQL_DEFAULT_COMMANDLINE=${{ secrets.ODC_MYSQL_DEFAULT_COMMANDLINE }} | |
echo "Current dir is "`pwd` | |
ut_log_file="unit_test_${{ matrix.ut-group }}.log" | |
echo "ut_log_file=${ut_log_file}" >> $GITHUB_OUTPUT | |
rm -rf ${ut_log_file} && touch ${ut_log_file} | |
if [ ${{ matrix.ut-group }} = "group_1" ]; then ut_args='-Dtest="com.oceanbase.odc.core.**","com.oceanbase.odc.common.**"'; fi | |
if [ ${{ matrix.ut-group }} = "group_2" ]; then ut_args='-Dtest="%regex[^com.oceanbase.odc.service.[acegik]+.*$]"'; fi | |
if [ ${{ matrix.ut-group }} = "group_3" ]; then ut_args='-Dtest="%regex[^com.oceanbase.odc.service.[moqsuwy]+.*$]"'; fi | |
if [ ${{ matrix.ut-group }} = "group_4" ]; then ut_args='-Dtest="%regex[^com.oceanbase.odc.service.[bdfhjl]+.*$]"'; fi | |
if [ ${{ matrix.ut-group }} = "group_5" ]; then ut_args='-Dtest="%regex[^com.oceanbase.odc.service.[nprtvxz]+.*$]"'; fi | |
if [ ${{ matrix.ut-group }} = "group_6" ]; then ut_args='-Dtest="!com.oceanbase.odc.core.**","!com.oceanbase.odc.common.**","!com.oceanbase.odc.service.**"'; fi | |
mvn_test_cmd="mvn test -Dmaven.test.failure.ignore=true -DfailIfNoTests=false ${ut_args} > ${ut_log_file}" | |
echo "Execute unit test command: ${mvn_test_cmd}" | |
eval $mvn_test_cmd | |
- name: Upload unit test log | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.unit_test.outputs.ut_log_file }} | |
path: ${{ steps.unit_test.outputs.ut_log_file }} | |
- name: Check unit test result | |
run: | | |
if grep -q "There are test failures" ${{ steps.unit_test.outputs.ut_log_file }}; then echo "Unit test failed, please check ${{ steps.unit_test.outputs.ut_log_file }} for details"; exist 1; fi | |
unit-test-libs: | |
name: Unit Test (LIBS) | |
if: ${{ github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
lib: | |
- db-browser | |
- ob-sql-parser | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v3 | |
- name: Setup JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "8" | |
distribution: "temurin" | |
cache: maven | |
- name: Build project | |
run: | | |
echo "Start install ${{ matrix.lib }}" | |
pushd libs/${{ matrix.lib }} | |
echo "Current dir is "`pwd` | |
mvn clean install -Dmaven.test.skip=true | |
echo "Install ${{ matrix.lib }} success" | |
- name: Run unit test | |
id: unit_test | |
run: | | |
export ODC_CONFIG_SECRET=${{ secrets.ODC_UT_SECRET }} | |
export ODC_OB_DEFAULT_MYSQL_COMMANDLINE=${{ secrets.ODC_OB_DEFAULT_MYSQL_COMMANDLINE }} | |
export ODC_OB_DEFAULT_ORACLE_COMMANDLINE=${{ secrets.ODC_OB_DEFAULT_ORACLE_COMMANDLINE }} | |
export ODC_MYSQL_DEFAULT_COMMANDLINE=${{ secrets.ODC_MYSQL_DEFAULT_COMMANDLINE }} | |
echo "Start test ${{ matrix.lib }}" | |
pushd libs/${{ matrix.lib }} | |
echo "Current dir is "`pwd` | |
ut_log_file="unit_test_${{ matrix.lib }}.log" | |
echo "ut_log_file=${ut_log_file}" >> $GITHUB_OUTPUT | |
rm -rf ${ut_log_file} && touch ${ut_log_file} | |
mvn_test_cmd="mvn test -Dmaven.test.failure.ignore=true -DfailIfNoTests=false > ${ut_log_file}" | |
echo "Execute unit test command: ${mvn_test_cmd}" | |
eval $mvn_test_cmd | |
- name: Upload unit test log | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.unit_test.outputs.ut_log_file }} | |
path: libs/${{ matrix.lib }}/${{ steps.unit_test.outputs.ut_log_file }} | |
- name: Check unit test result | |
run: | | |
pushd libs/${{ matrix.lib }} | |
echo "Current dir is "`pwd` | |
if grep -q "There are test failures" ${{ steps.unit_test.outputs.ut_log_file }}; then echo "Unit test failed, please check ${{ steps.unit_test.outputs.ut_log_file }} for details"; exist 1; fi | |
calculate-version: | |
name: Calculate Version Number | |
needs: [ check-format, pmd-scan, unit-test-odc, unit-test-libs ] | |
if: ${{ github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
outputs: | |
odc_rpm_release_number: ${{ steps.calculate_version.outputs.odc_rpm_release_number }} | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v3 | |
- name: Calculate version number | |
id: calculate_version | |
run: | | |
odc_rpm_release_number=$(date +%Y%m%d%H%M%S) | |
echo "odc_rpm_release_number=${odc_rpm_release_number}" >> $GITHUB_OUTPUT | |
echo "odc_rpm_release_number=${odc_rpm_release_number}" | |
build-rpm-x86_64: | |
name: Build RPM (x86_64) | |
needs: [ calculate-version ] | |
runs-on: ubuntu-latest | |
env: | |
odc_rpm_release_number: ${{ needs.calculate-version.outputs.odc_rpm_release_number }} | |
steps: | |
- name: Checkout workspace | |
uses: actions/checkout@v3 | |
with: | |
submodules: "recursive" | |
- name: Setup JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "8" | |
distribution: "temurin" | |
cache: maven | |
- name: Setup node 16 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
- name: Set release version | |
id: set_release_version | |
run: | | |
main_version="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | cut -d - -f 1)" | |
new_version="${main_version}-${odc_rpm_release_number}" | |
echo "new_version=${new_version}" >> $GITHUB_OUTPUT | |
echo "RPM's version is "${new_version} | |
mvn versions:set -DnewVersion="${new_version}" | |
mvn versions:commit | |
- name: Install db-browser | |
run: | | |
echo "Start install db-browser" | |
pushd libs/db-browser | |
echo "Current dir is "`pwd` | |
mvn clean install -Dmaven.test.skip=true | |
echo "Install db-browser success" | |
popd | |
- name: Install ob-sql-parser | |
run: | | |
echo "Start install ob-sql-parser" | |
pushd libs/ob-sql-parser | |
echo "Current dir is "`pwd` | |
mvn clean install -Dmaven.test.skip=true | |
echo "Install ob-sql-parser success" | |
popd | |
- name: Build jar & rpm (x86_64) | |
run: | | |
echo "Start prepare oceanbase-client" | |
pushd import | |
echo "Current dir is "`pwd` | |
rm -rf obclient_aarch.tar.gz | |
rm -rf obclient_win.tar.gz | |
mv obclient_x86.tar.gz obclient.tar.gz | |
popd | |
echo "Prepare oceanbase-client success" | |
echo "Start build rpm package" | |
mvn help:system | |
mvn clean install -Dmaven.test.skip=true | |
mvn --file server/odc-server/pom.xml rpm:rpm -Drpm.prefix=/opt | |
echo "Build rpm package success" | |
rm --force --recursive --verbose distribution/docker/resources/odc-*.rpm | |
mkdir -p distribution/docker/resources/ | |
mv --verbose server/odc-server/target/rpm/odc-server/RPMS/*/odc-*.rpm distribution/docker/resources/ | |
- name: Upload rpm (x86_64) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: odc-server-${{ steps.set_release_version.outputs.new_version }}.x86_64.rpm | |
path: distribution/docker/resources/odc-*.rpm |