Update CICD workflow for repo #84
Workflow file for this run
This file contains hidden or 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
| name: Build and Unit Test | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| types: [ opened, synchronize, reopened, edited, ready_for_review ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| id-token: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| GO_VERSION: '1.21' | |
| GOPATH: ${{ github.workspace }}/.go | |
| GOBIN: ${{ github.workspace }}/.go/bin | |
| jobs: | |
| build_and_unit_test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.21 | |
| - name: Setup GOPATH/PATH | |
| run: | | |
| echo "GOPATH=${GOPATH}" >> "$GITHUB_ENV" | |
| echo "${GOBIN}" >> "$GITHUB_PATH" | |
| echo "GOFLAGS=-trimpath" >> "$GITHUB_ENV" | |
| - name: Install dependencies | |
| run: make depend | |
| - name: Build binaries | |
| run: make build | |
| - name: Run unit tests with coverage | |
| run: | | |
| make unit | |
| make coverage | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: /tmp/coverage.out | |
| flags: unittests | |
| name: codecov-ubuntu-latest-go${{ env.GO_VERSION }} | |
| fail_ci_if_error: false | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-ubuntu-latest-go${{ env.GO_VERSION }}-${{ github.sha }} | |
| path: | | |
| ${{ env.GOBIN }}/gpbackup | |
| ${{ env.GOBIN }}/gprestore | |
| ${{ env.GOBIN }}/gpbackup_helper | |
| retention-days: 7 | |
| # Integration test with Apache Cloudberry | |
| integration_test: | |
| needs: build_and_unit_test | |
| runs-on: ubuntu-22.04 | |
| if: github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft) | |
| timeout-minutes: 120 | |
| container: | |
| image: apache/incubator-cloudberry:cbdb-build-rocky9-latest | |
| options: >- | |
| --privileged | |
| --user root | |
| --hostname cdw | |
| --shm-size=2gb | |
| --ulimit core=-1 | |
| steps: | |
| - name: Cloudberry Environment Initialization | |
| run: | | |
| set -eo pipefail | |
| if ! su - gpadmin -c "/tmp/init_system.sh"; then | |
| echo "::error::Container initialization failed" | |
| exit 1 | |
| fi | |
| mkdir -p build-logs/details | |
| chown -R gpadmin:gpadmin . | |
| chmod -R 755 . | |
| chmod 777 build-logs | |
| - name: Checkout Apache Cloudberry source | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: apache/cloudberry | |
| ref: main | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| path: cloudberry | |
| - name: Checkout backup utility code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| path: cloudberry-backup | |
| - name: Set up Go in container | |
| run: | | |
| # Install Go 1.21 in the container (retain original approach) | |
| cd /tmp | |
| wget -q https://go.dev/dl/go${{ env.GO_VERSION }}.linux-amd64.tar.gz | |
| tar -C /usr/local -xzf go${{ env.GO_VERSION }}.linux-amd64.tar.gz | |
| echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile | |
| echo 'export GOPATH=/home/gpadmin/go' >> /etc/profile | |
| echo 'export PATH=$PATH:/home/gpadmin/go/bin' >> /etc/profile | |
| echo "/home/gpadmin/go/bin" >> "$GITHUB_PATH" | |
| echo "GOPATH=/home/gpadmin/go" >> "$GITHUB_ENV" | |
| - name: Configure Apache Cloudberry | |
| env: | |
| SRC_DIR: ${{ github.workspace }}/cloudberry | |
| BUILD_DESTINATION: /usr/local/cloudberry-db | |
| ENABLE_DEBUG: false | |
| run: | | |
| set -eo pipefail | |
| chown -R gpadmin:gpadmin ${SRC_DIR} | |
| su - gpadmin -c " | |
| cd ${SRC_DIR} | |
| export SRC_DIR=${SRC_DIR} | |
| export BUILD_DESTINATION=${BUILD_DESTINATION} | |
| export ENABLE_DEBUG=${ENABLE_DEBUG} | |
| chmod +x devops/build/automation/cloudberry/scripts/configure-cloudberry.sh | |
| ./devops/build/automation/cloudberry/scripts/configure-cloudberry.sh | |
| " | |
| - name: Build Apache Cloudberry | |
| env: | |
| SRC_DIR: ${{ github.workspace }}/cloudberry | |
| run: | | |
| set -eo pipefail | |
| su - gpadmin -c " | |
| cd ${SRC_DIR} | |
| export SRC_DIR=${SRC_DIR} | |
| chmod +x devops/build/automation/cloudberry/scripts/build-cloudberry.sh | |
| ./devops/build/automation/cloudberry/scripts/build-cloudberry.sh | |
| " | |
| - name: Create Cloudberry demo cluster | |
| env: | |
| SRC_DIR: ${{ github.workspace }}/cloudberry | |
| NUM_PRIMARY_MIRROR_PAIRS: 1 | |
| run: | | |
| set -eo pipefail | |
| su - gpadmin -c " | |
| cd ${SRC_DIR} | |
| export SRC_DIR=${SRC_DIR} | |
| export NUM_PRIMARY_MIRROR_PAIRS=${NUM_PRIMARY_MIRROR_PAIRS} | |
| chmod +x devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh | |
| ./devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh | |
| " | |
| - name: Verify Cloudberry cluster | |
| run: | | |
| su - gpadmin -c " | |
| source /usr/local/cloudberry-db/cloudberry-env.sh | |
| source ${GITHUB_WORKSPACE}/cloudberry/gpAux/gpdemo/gpdemo-env.sh | |
| gpstate -s | |
| psql -d postgres -c 'SELECT version();' | |
| psql -d postgres -c 'SELECT * FROM gp_segment_configuration;' | |
| " | |
| - name: Build and test backup utility with Cloudberry | |
| env: | |
| GOPATH: /home/gpadmin/go | |
| run: | | |
| su - gpadmin -c " | |
| export PATH=/usr/local/go/bin:\$PATH | |
| export GOPATH=${GOPATH} | |
| export PATH=\$PATH:\$GOPATH/bin | |
| source /usr/local/cloudberry-db/cloudberry-env.sh | |
| source ${GITHUB_WORKSPACE}/cloudberry/gpAux/gpdemo/gpdemo-env.sh | |
| cd ${GITHUB_WORKSPACE}/cloudberry-backup | |
| mkdir -p \$GOPATH/src/github.com/apache | |
| ln -sf ${GITHUB_WORKSPACE}/cloudberry-backup \$GOPATH/src/github.com/apache/cloudberry-backup | |
| cd \$GOPATH/src/github.com/apache/cloudberry-backup | |
| make depend | |
| make build | |
| # Run unit tests (no DB connection required) | |
| make unit | |
| echo 'Running integration tests with Cloudberry cluster...' | |
| make integration || echo 'Integration tests completed with some failures (soft fail in CI)' | |
| " | |
| - name: Upload integration test logs | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: integration-test-logs | |
| path: | | |
| build-logs/ | |
| cloudberry/build-logs/ | |
| retention-days: 7 |