|
| 1 | +# -------------------------------------------------------------------- |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | +# contributor license agreements. See the NOTICE file distributed |
| 5 | +# with this work for additional information regarding copyright |
| 6 | +# ownership. The ASF licenses this file to You under the Apache |
| 7 | +# License, Version 2.0 (the "License"); you may not use this file |
| 8 | +# except in compliance with the License. You may obtain a copy of the |
| 9 | +# License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 16 | +# implied. See the License for the specific language governing |
| 17 | +# permissions and limitations under the License. |
| 18 | +# |
| 19 | +# -------------------------------------------------------------------- |
| 20 | +# GitHub Actions Workflow: Apache Cloudberry SonarQube Pipeline |
| 21 | +# -------------------------------------------------------------------- |
| 22 | +# Description: |
| 23 | +# |
| 24 | +# This workflow performs scheduled SonarQube analysis for Cloudberry. |
| 25 | +# |
| 26 | +# Workflow Overview: |
| 27 | +# 1. **Check Skip**: |
| 28 | +# - workflow run currently is limited to "apache" GitHub organization |
| 29 | +# |
| 30 | +# 2. **scan Job**: |
| 31 | +# - performs scan and upload result to https://sonarcloud.io/project/overview?id=apache_cloudberry |
| 32 | +# Triggers: |
| 33 | +# - Weekly schedule |
| 34 | +# - optional manual dispatch. |
| 35 | +# |
| 36 | +# Notes: |
| 37 | +# - SONARCLOUD_TOKEN secret is provided by the ASF Infra team |
| 38 | +# -------------------------------------------------------------------- |
| 39 | +name: Apache Cloudberry SonarQube Cloud Analysis |
| 40 | + |
| 41 | +on: |
| 42 | + schedule: |
| 43 | + - cron: "0 0 * * 1" |
| 44 | + workflow_dispatch: |
| 45 | + |
| 46 | +permissions: |
| 47 | + contents: read |
| 48 | + |
| 49 | +jobs: |
| 50 | + sonarqube-analysis: |
| 51 | + runs-on: ubuntu-22.04 |
| 52 | + if: ${{ github.repository_owner == 'apache' }} |
| 53 | + |
| 54 | + container: |
| 55 | + image: apache/incubator-cloudberry:cbdb-build-rocky9-latest |
| 56 | + options: >- |
| 57 | + --user root |
| 58 | + -h cdw |
| 59 | + env: |
| 60 | + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed |
| 61 | + |
| 62 | + steps: |
| 63 | + - name: Checkout Apache Cloudberry |
| 64 | + uses: actions/checkout@v4 |
| 65 | + with: |
| 66 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 67 | + submodules: true |
| 68 | + |
| 69 | + - name: Environment Initialization |
| 70 | + run: | |
| 71 | + if ! su - gpadmin -c "/tmp/init_system.sh"; then |
| 72 | + echo "::error::Container initialization failed" |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | +
|
| 76 | + - name: Install Build Wrapper |
| 77 | + uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5 |
| 78 | + |
| 79 | + - name: Run Build Wrapper |
| 80 | + run: | |
| 81 | + set -euox pipefail |
| 82 | + sudo chmod a+w /usr/local |
| 83 | + mkdir -p /usr/local/cloudberry-db/lib |
| 84 | + sudo cp /usr/local/xerces-c/lib/libxerces-c.so \ |
| 85 | + /usr/local/xerces-c/lib/libxerces-c-3.3.so \ |
| 86 | + /usr/local/cloudberry-db/lib |
| 87 | + sudo chown -R gpadmin:gpadmin /usr/local/cloudberry-db |
| 88 | + export LD_LIBRARY_PATH=/usr/local/cloudberry-db/lib:LD_LIBRARY_PATH |
| 89 | + ./configure --prefix=/usr/local/cloudberry-db \ |
| 90 | + --disable-external-fts \ |
| 91 | + --enable-gpcloud \ |
| 92 | + --enable-ic-proxy \ |
| 93 | + --enable-orafce \ |
| 94 | + --enable-orca \ |
| 95 | + --enable-pax \ |
| 96 | + --enable-pxf \ |
| 97 | + --enable-tap-tests \ |
| 98 | + --with-gssapi \ |
| 99 | + --with-ldap \ |
| 100 | + --with-libxml \ |
| 101 | + --with-lz4 \ |
| 102 | + --with-openssl \ |
| 103 | + --with-pam \ |
| 104 | + --with-perl \ |
| 105 | + --with-pgport=5432 \ |
| 106 | + --with-python \ |
| 107 | + --with-pythonsrc-ext \ |
| 108 | + --with-ssl=openssl \ |
| 109 | + --with-uuid=e2fs \ |
| 110 | + --with-includes=/usr/local/xerces-c/include \ |
| 111 | + --with-libraries=/usr/local/cloudberry-db/lib |
| 112 | + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j$(nproc) |
| 113 | +
|
| 114 | + - name: SonarQube Scan |
| 115 | + uses: SonarSource/sonarqube-scan-action@v5 |
| 116 | + env: |
| 117 | + SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} |
| 118 | + with: |
| 119 | + args: > |
| 120 | + --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" |
0 commit comments