From 48270ad8e6b1ceac53a719c4443944504f4c0212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xuebin=20Su=20=28=E8=8B=8F=E5=AD=A6=E6=96=8C=29?= <12034000+xuebinsu@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:29:48 +0800 Subject: [PATCH] Migrate to monorepo for CI (#220) --- concourse/README.md | 98 ----------- concourse/fly.sh | 174 -------------------- concourse/lib/.editorconfig | 11 -- concourse/lib/.github/workflows/check.yml | 39 ----- concourse/lib/README.md | 1 - concourse/lib/base.lib.yml | 60 ------- concourse/lib/fly.sh | 178 -------------------- concourse/lib/res_def_gpdb.yml | 148 ----------------- concourse/lib/res_def_misc.yml | 7 - concourse/lib/res_types_def.yml | 21 --- concourse/pipeline/base.lib.yml | 34 ---- concourse/pipeline/commit.yml | 40 ----- concourse/pipeline/dev.yml | 38 ----- concourse/pipeline/job_def.lib.yml | 150 ----------------- concourse/pipeline/pr.yml | 47 ------ concourse/pipeline/release.yml | 47 ------ concourse/pipeline/res_def.yml | 52 ------ concourse/pipeline/trigger_def.lib.yml | 73 --------- concourse/scripts/entry.sh | 189 ---------------------- concourse/scripts/test.sh | 19 --- concourse/test.sh | 55 +++++++ 21 files changed, 55 insertions(+), 1426 deletions(-) delete mode 100644 concourse/README.md delete mode 100755 concourse/fly.sh delete mode 100644 concourse/lib/.editorconfig delete mode 100644 concourse/lib/.github/workflows/check.yml delete mode 100644 concourse/lib/README.md delete mode 100644 concourse/lib/base.lib.yml delete mode 100755 concourse/lib/fly.sh delete mode 100644 concourse/lib/res_def_gpdb.yml delete mode 100644 concourse/lib/res_def_misc.yml delete mode 100644 concourse/lib/res_types_def.yml delete mode 100644 concourse/pipeline/base.lib.yml delete mode 100644 concourse/pipeline/commit.yml delete mode 100644 concourse/pipeline/dev.yml delete mode 100644 concourse/pipeline/job_def.lib.yml delete mode 100644 concourse/pipeline/pr.yml delete mode 100644 concourse/pipeline/release.yml delete mode 100644 concourse/pipeline/res_def.yml delete mode 100644 concourse/pipeline/trigger_def.lib.yml delete mode 100755 concourse/scripts/entry.sh delete mode 100755 concourse/scripts/test.sh create mode 100755 concourse/test.sh diff --git a/concourse/README.md b/concourse/README.md deleted file mode 100644 index 69a0e04c..00000000 --- a/concourse/README.md +++ /dev/null @@ -1,98 +0,0 @@ -# Pipelines - -## Naming Prefix Rule - -- `pr.` for pull-request pipelines -- `merge..` for branch pipelines. It will be executed when a commit committed/merged into the branch. -- `dev...` for personal development usage. Put your name into the pipeline name so others can know who own it. -- `_test..` for pipeline debugging. - -## Pipelines for daily work - -### PR Pipeline - -https://dev2.ci.gpdb.pivotal.io/teams/gp-extensions/pipelines/pr.greenplumpython - -### Main Branch Pipeline - -The development happens on the `main` branch. The merge pipeline for the `main` branch is -https://dev2.ci.gpdb.pivotal.io/teams/gp-extensions/pipelines/merge.greenplumpython.main - - -# Fly a pipeline - -## Prerequisite - -- Install [ytt](https://carvel.dev/ytt/). It's written in go. So just download the executable for your platform from the [release page](https://github.com/vmware-tanzu/carvel-ytt/releases). -- Make the `fly` command in the `PATH` or export its location to `FLY` env. -- Login with the `fly` command. Assume we are using `dev2` as the target name. - -``` -# -n gp-extensions is to set the concourse team -fly -t dev2 login -c https://dev2.ci.gpdb.pivotal.io -n gp-extensions -``` - -- `cd` to the `concourse` directory. - -## Fly the PR pipeline - -``` -./fly.sh -t dev2 -c pr -``` - -## Fly the merge pipeline - -``` -./fly.sh -t dev2 -c merge -``` - -## Fly the release pipeline - -By default, the release is built from the `main` branch. - -The release pipeline should be located in https://prod.ci.gpdb.pivotal.io - -``` -# Login to prod -fly -t prod login -c https://prod.ci.gpdb.pivotal.io -# Fly the release pipeline -./fly.sh -t prod -c rel -``` - -To fly a release pipeline from a specific branch: - -``` -./fly.sh -t -c rel -b release/. -``` - -## Fly the dev pipeline - -``` -./fly.sh -t dev2 -c dev -p -b -``` - -## Webhook - -By default, the PR and merge pipelines are using webhook instead of polling to trigger a build. The webhook URL will be printed when flying such a pipeline by `fly.sh`. The webhook needs to be set in the `github repository` -> `Settings` -> `Webhooks` with push notification enabled. - -To test if the webhook works, use `curl` to send a `POST` request to the hook URL with some random data. If it is the right URL, the relevant resource will be refreshed on the Concourse UI. The command line looks like: - -``` -curl --data-raw "foo" -``` - -## Update gp-extensions-ci - -We place some of the resources of concourse in a separate repository https://github.com/pivotal/gp-extensions-ci/. And we use that repo as a subtree with prefix ./concourse/lib. This is how to pull from the repo gp-extensions-ci: - -```sh - git subtree pull --prefix concourse/lib git@github.com:pivotal/gp-extensions-ci.git main --squash -``` - -# FAQ - -## PR pipeline is not triggered. - -The PR pipeline relies on the webhook to detect the new PR. However, due to the the limitation of the webhook implemention of concourse, we rely on the push hook for this. It means if the PR is from a forked repo, the PR pipeline won't be triggered immediately. To manually trigger the pipeline, go to https://dev2.ci.gpdb.pivotal.io/teams/gp-extensions/pipelines/pr.greenplumpython/resources/greenplumpython_pr and click ⟳ button there. - -TIPS: Just don't fork, name your branch as `/` and push it here to create PR. diff --git a/concourse/fly.sh b/concourse/fly.sh deleted file mode 100755 index 3642fdc1..00000000 --- a/concourse/fly.sh +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/bash - -set -e - -fly=${FLY:-"fly"} -echo "'fly' command: ${fly}" -echo "" - -my_path=$(realpath -s "${BASH_SOURCE[0]}") -my_dir=$(dirname "${my_path}") -proj_name="greenplumpython" -concourse_team="main" - -usage() { - if [ -n "$1" ]; then - echo "$1" 1>&2 - echo "" 1>&2 - fi - - echo "Usage: $0 -t -c [-p ] [-b branch] [-T]" - echo "Options:" - echo " '-T' adds '_test' suffix to the pipeline type. Useful for pipeline debugging." - exit 1 -} - -# Hacky way to find out which concourse team is being used. -# The team name is needed to generate webhook URL -detect_concourse_team() { - local target="$1" - local fly_rc_file="$HOME/.flyrc" - local found_target=false - while read -r line; - do - line="$(echo -e "${line}" | tr -d '[:space:]')" - if [ ${found_target} != true ] && [ "${line}" = "${target}:" ]; then - found_target=true - fi - if [ ${found_target} = true ] && [[ "${line}" == team:* ]]; then - concourse_team=$(echo "${line}" | cut --delimiter=":" --fields=2) - echo "Use concourse target: ${target}, team: ${concourse_team}" - return - fi - done < "${fly_rc_file}" -} - -# Parse command line options -while getopts ":c:t:p:b:T" o; do - case "${o}" in - c) - # pipeline type/config. pr/merge/dev/rel - pipeline_config=${OPTARG} - ;; - t) - # concourse target - target=${OPTARG} - ;; - p) - # pipeline name - postfix=${OPTARG} - ;; - b) - # branch name - branch=${OPTARG} - ;; - T) - test_suffix="_test" - ;; - *) - usage "" - ;; - esac -done -shift $((OPTIND-1)) - -if [ -z "${target}" ] || [ -z "${pipeline_config}" ]; then - usage "" -fi - -detect_concourse_team "${target}" - -pipeline_type="" -# Decide ytt options to generate pipeline -case ${pipeline_config} in - pr) - pipeline_type="pr" - config_file="pr.yml" - hook_res="${proj_name}_pr" - ;; - merge|commit) - # Default branch is 'main' as it is our main branch - if [ -z "${branch}" ]; then - branch="main" - fi - pipeline_type="merge" - config_file="commit.yml" - hook_res="${proj_name}_commit" - ;; - dev) - if [ -z "${postfix}" ]; then - usage "'-p' needs to be supplied to specify the pipeline name postfix for flying a 'dev' pipeline." - fi - if [ -z "${branch}" ]; then - usage "'-b' needs to be supplied to specify the branch for flying a 'dev' pipeline." - fi - pipeline_type="dev" - config_file="dev.yml" - ;; - release|rel) - # Default branch is 'gpdb' as it is our main branch - if [ -z "${branch}" ]; then - branch="gpdb" - fi - pipeline_type="rel" - config_file="release.yml" - hook_res="${proj_name}_commit" - ;; - *) - usage "" - ;; -esac - -yml_path="/tmp/${proj_name}.yml" -pipeline_dir="${my_dir}/pipeline" -lib_dir="${my_dir}/lib" -# pipeline cannot contain '/' -pipeline_name=${pipeline_name/\//"_"} - -# Generate pipeline name -if [ -n "${test_suffix}" ]; then - pipeline_type="${pipeline_type}_test" -fi -pipeline_name="${pipeline_type}.${proj_name}" -if [ -n "${branch}" ]; then - pipeline_name="${pipeline_name}.${branch}" -fi -if [ -n "${postfix}" ]; then - pipeline_name="${pipeline_name}.${postfix}" -fi -# pipeline cannot contain '/' -pipeline_name=${pipeline_name/\//"_"} - -ytt \ - --data-values-file "${pipeline_dir}/res_def.yml" \ - --data-values-file "${lib_dir}/res_def_gpdb.yml" \ - --data-values-file "${lib_dir}/res_def_misc.yml" \ - --data-values-file "${lib_dir}/res_types_def.yml" \ - -f "${lib_dir}/base.lib.yml" \ - -f "${pipeline_dir}/job_def.lib.yml" \ - -f "${pipeline_dir}/trigger_def.lib.yml" \ - -f "${pipeline_dir}/${config_file}" >"${yml_path}" -echo "Generated pipeline yaml '${yml_path}'." - -echo "" -echo "Fly the pipeline..." -set -v -"${fly}" \ - -t "${target}" \ - sp \ - -p "${pipeline_name}" \ - -c "${yml_path}" \ - -v "${proj_name}-branch=${branch}" -set +v - -if [ "${pipeline_config}" == "dev" ]; then - exit 0 -fi - -concourse_url=$(fly targets | awk "{if (\$1 == \"${target}\") {print \$2}}") -echo "" -echo "================================================================================" -echo "Remeber to set the the webhook URL on GitHub:" -echo "${concourse_url}/api/v1/teams/${concourse_team}/pipelines/${pipeline_name}/resources/${hook_res}/check/webhook?webhook_token=" -echo "You may need to change the base URL if a different concourse server is used." -echo "================================================================================" diff --git a/concourse/lib/.editorconfig b/concourse/lib/.editorconfig deleted file mode 100644 index c13f84c9..00000000 --- a/concourse/lib/.editorconfig +++ /dev/null @@ -1,11 +0,0 @@ -# top-most EditorConfig file -root = true - -# Unix-style newlines with a newline ending every file -[*] -end_of_line = lf -trim_trailing_whitespace = true -insert_final_newline = false -charset = utf-8 -indent_style = space -indent_size = 4 diff --git a/concourse/lib/.github/workflows/check.yml b/concourse/lib/.github/workflows/check.yml deleted file mode 100644 index f2b6e299..00000000 --- a/concourse/lib/.github/workflows/check.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Check - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - workflow_dispatch: - -concurrency: - group: ${{ github.event.number || github.run_id }} - cancel-in-progress: true - -jobs: - run_shellcheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install shellcheck - run: | - export scversion=v0.9.0 - wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv - sudo cp "shellcheck-${scversion}/shellcheck" /usr/bin/ - shellcheck --version - - name: Check with shellcheck - run: | - shellcheck $(find . -type f -name "*.sh" -print) - run_shfmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install shfmt - run: | - wget https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64 -O shfmt - chmod +x shfmt - sudo cp shfmt /usr/bin/ - - name: Check with shfmt - run: | - shfmt -l -d . diff --git a/concourse/lib/README.md b/concourse/lib/README.md deleted file mode 100644 index 0dd8ca55..00000000 --- a/concourse/lib/README.md +++ /dev/null @@ -1 +0,0 @@ -# Common ytt libs for gp-extensions concourse diff --git a/concourse/lib/base.lib.yml b/concourse/lib/base.lib.yml deleted file mode 100644 index 78072de5..00000000 --- a/concourse/lib/base.lib.yml +++ /dev/null @@ -1,60 +0,0 @@ -#@ load("@ytt:data", "data") -#@ load("@ytt:struct", "struct") - -#! resources and resource_types could be declared in different data-value files. -#! We check the key prefix, if they are 'resources' and 'resource_types', just -#! merge them into local dictionaries. -#@ resources = [] -#@ resource_types = [] -#@ data_values_dict = struct.decode(data.values) -#@ for key in data_values_dict.keys(): -#@ if key.startswith('resources'): -#@ resources.extend(data_values_dict[key]) -#@ end -#@ end -#@ for key in data_values_dict.keys(): -#@ if key.startswith('resource_type'): -#@ resource_types.extend(data_values_dict[key]) -#@ end -#@ end - -#! add_res_by_xxx is to solve the unused resources error for concourse -#@ def add_res_by_conf(res_map, job_conf): -#@ for key in job_conf: -#@ if key.startswith("res_"): -#@ val = job_conf[key] -#@ if type(val) == "list" or type(val) == "yamlfragment": -#@ for res_name in val: -#@ res_map[res_name] = True -#@ end -#@ else: -#@ res_name = val -#@ res_map[res_name] = True -#@ end -#@ end -#@ end -#@ end -#@ -#@ def add_res_by_name(res_map, res_name): -#@ res_map[res_name] = True -#@ end -#@ -#@ def declare_res(res_type_map, res_map): -#@ for val in resources: -#@ res_name = val["name"] -#@ res_type = val["type"] -#@ if res_map.get(val["name"]): -#@ res_type_map[res_type] = True - - #@ val -#@ end -#@ end -#@ end -#@ -#@ def declare_res_type(res_type_map): -#@ for val in resource_types: -#@ type_name = val["name"] -#@ if res_type_map.get(type_name): - - #@ val -#@ end -#@ end -#@ end diff --git a/concourse/lib/fly.sh b/concourse/lib/fly.sh deleted file mode 100755 index 576bcd85..00000000 --- a/concourse/lib/fly.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/bash - -set -e - -fly=${FLY:-"fly"} -echo "'fly' command: ${fly}" -echo "" - -my_path=$(realpath -s "${BASH_SOURCE[0]}") -my_dir=$(dirname "${my_path}") -proj_name_file="${my_dir}/PROJ_NAME" -if [ ! -f "${proj_name_file}" ]; then - echo "A 'PROJ_NAME' file is needed in '${my_dir}'" - exit 1 -fi -proj_name=$(cat "${proj_name_file}") -concourse_team="main" - -usage() { - if [ -n "$1" ]; then - echo "$1" 1>&2 - echo "" 1>&2 - fi - - echo "Usage: $0 -t -c [-p ] [-b branch] [-T]" - echo "Options:" - echo " '-T' adds '_test' suffix to the pipeline type. Useful for pipeline debugging." - exit 1 -} - -# Hacky way to find out which concourse team is being used. -# The team name is needed to generate webhook URL -detect_concourse_team() { - local target="$1" - local fly_rc_file="$HOME/.flyrc" - local found_target=false - while read -r line; do - line="$(echo -e "${line}" | tr -d '[:space:]')" - if [ ${found_target} != true ] && [ "${line}" = "${target}:" ]; then - found_target=true - fi - if [ ${found_target} = true ] && [[ "${line}" == team:* ]]; then - concourse_team=$(echo "${line}" | cut --delimiter=":" --fields=2) - echo "Use concourse target: ${target}, team: ${concourse_team}" - return - fi - done <"${fly_rc_file}" -} - -# Parse command line options -while getopts ":c:t:p:b:T" o; do - case "${o}" in - c) - # pipeline type/config. pr/merge/dev/rel - pipeline_config=${OPTARG} - ;; - t) - # concourse target - target=${OPTARG} - ;; - p) - # pipeline name - postfix=${OPTARG} - ;; - b) - # branch name - branch=${OPTARG} - ;; - T) - test_suffix="_test" - ;; - *) - usage "" - ;; - esac -done -shift $((OPTIND - 1)) - -if [ -z "${target}" ] || [ -z "${pipeline_config}" ]; then - usage "" -fi - -detect_concourse_team "${target}" - -pipeline_type="" -# Decide ytt options to generate pipeline -case ${pipeline_config} in -pr) - pipeline_type="pr" - config_file="pr.yml" - hook_res="${proj_name}_pr" - ;; -merge | commit) - # Default branch is 'gpdb' as it is our main branch - if [ -z "${branch}" ]; then - branch="gpdb" - fi - pipeline_type="merge" - config_file="commit.yml" - hook_res="${proj_name}_commit" - ;; -dev) - if [ -z "${postfix}" ]; then - usage "'-p' needs to be supplied to specify the pipeline name postfix for flying a 'dev' pipeline." - fi - if [ -z "${branch}" ]; then - usage "'-b' needs to be supplied to specify the branch for flying a 'dev' pipeline." - fi - pipeline_type="dev" - config_file="dev.yml" - ;; -release | rel) - # Default branch is 'gpdb' as it is our main branch - if [ -z "${branch}" ]; then - branch="gpdb" - fi - pipeline_type="rel" - config_file="release.yml" - hook_res="${proj_name}_commit" - ;; -*) - usage "" - ;; -esac - -yml_path="/tmp/${proj_name}.yml" -pipeline_dir="${my_dir}/pipeline" -lib_dir="${my_dir}/lib" -# pipeline cannot contain '/' -pipeline_name=${pipeline_name/\//"_"} - -# Generate pipeline name -if [ -n "${test_suffix}" ]; then - pipeline_type="${pipeline_type}_test" -fi -pipeline_name="${pipeline_type}.${proj_name}" -if [ -n "${branch}" ]; then - pipeline_name="${pipeline_name}.${branch}" -fi -if [ -n "${postfix}" ]; then - pipeline_name="${pipeline_name}.${postfix}" -fi -# pipeline cannot contain '/' -pipeline_name=${pipeline_name/\//"_"} - -ytt \ - --data-values-file "${pipeline_dir}/res_def.yml" \ - --data-values-file "${lib_dir}/res_def_gpdb.yml" \ - --data-values-file "${lib_dir}/res_def_misc.yml" \ - --data-values-file "${lib_dir}/res_types_def.yml" \ - -f "${lib_dir}/base.lib.yml" \ - -f "${pipeline_dir}/job_def.lib.yml" \ - -f "${pipeline_dir}/trigger_def.lib.yml" \ - -f "${pipeline_dir}/${config_file}" >"${yml_path}" -echo "Generated pipeline yaml '${yml_path}'." - -echo "" -echo "Fly the pipeline..." -set -v -"${fly}" \ - -t "${target}" \ - sp \ - -p "${pipeline_name}" \ - -c "${yml_path}" \ - -v "${proj_name}-branch=${branch}" -set +v - -if [ "${pipeline_config}" == "dev" ]; then - exit 0 -fi - -concourse_url=$(fly targets | awk "{if (\$1 == \"${target}\") {print \$2}}") -echo "" -echo "================================================================================" -echo "Remeber to set the the webhook URL on GitHub:" -echo "${concourse_url}/api/v1/teams/${concourse_team}/pipelines/${pipeline_name}/resources/${hook_res}/check/webhook?webhook_token=" -echo "You may need to change the base URL if a different concourse server is used." -echo "================================================================================" diff --git a/concourse/lib/res_def_gpdb.yml b/concourse/lib/res_def_gpdb.yml deleted file mode 100644 index b4384480..00000000 --- a/concourse/lib/res_def_gpdb.yml +++ /dev/null @@ -1,148 +0,0 @@ -resources_gpdb: -# Image Resources -# centos6 -- name: centos6-gpdb6-image-build - type: registry-image - source: - repository: gcr.io/data-gpdb-public-images/gpdb6-centos6-build - tag: latest -- name: centos6-gpdb6-image-test - type: registry-image - source: - repository: gcr.io/data-gpdb-public-images/gpdb6-centos6-test - tag: latest -# centos7 -- name: centos7-gpdb6-image-build - type: registry-image - source: - repository: gcr.io/data-gpdb-public-images/gpdb6-centos7-build - tag: latest -- name: centos7-gpdb6-image-test - type: registry-image - source: - repository: gcr.io/data-gpdb-public-images/gpdb6-centos7-test - tag: latest -# rhel8 -- name: rhel8-gpdb6-image-build - type: registry-image - source: - repository: gcr.io/data-gpdb-private-images/gpdb6-rhel8-build - tag: latest - username: _json_key - password: ((data-gpdb-private-images-container-registry-readonly-service-account-key)) -- name: rhel8-gpdb6-image-test - type: registry-image - source: - repository: gcr.io/data-gpdb-private-images/gpdb6-rhel8-test - tag: latest - username: _json_key - password: ((data-gpdb-private-images-container-registry-readonly-service-account-key)) -# Ubuntu18 -- name: ubuntu18-gpdb6-image-build - type: registry-image - source: - repository: gcr.io/data-gpdb-public-images/gpdb6-ubuntu18.04-build - tag: latest -- name: ubuntu18-gpdb6-image-test - type: registry-image - source: - repository: gcr.io/data-gpdb-public-images/gpdb6-ubuntu18.04-test - tag: latest -# GPDB7 -# build -- name: rocky8-gpdb7-image-build - type: registry-image - source: - repository: gcr.io/data-gpdb-public-images/gpdb7-rocky8-build - tag: latest -# test -- name: rocky8-gpdb7-image-test - type: registry-image - source: - repository: gcr.io/data-gpdb-public-images/gpdb7-rocky8-test - tag: latest -- name: rhel8-gpdb7-image-test - type: registry-image - source: - repository: gcr.io/data-gpdb-private-images/gpdb7-rhel8-test - tag: latest - username: _json_key - password: ((data-gpdb-private-images-container-registry-readonly-service-account-key)) - -# gpdb binary on gcs is located as different folder for different version -# Latest build with assertion enabled: -# --enable-cassert --enable-tap-tests --enable-debug-extensions -- name: bin_gpdb6_centos6_debug - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/published/gpdb6/server-rc-(.*\+dev\.\d+.*)-rhel6_x86_64.debug.tar.gz -- name: bin_gpdb6_centos7_debug - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/published/gpdb6/server-rc-(.*\+dev\.\d+.*)-rhel7_x86_64.debug.tar.gz -- name: bin_gpdb6_rhel8_debug - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/published/gpdb6/server-rc-(.*\+dev\.\d+.*)-rhel8_x86_64.debug.tar.gz -- name: bin_gpdb6_ubuntu18_debug - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/published/gpdb6/server-rc-(.*\+dev\.\d+.*)-ubuntu18.04_x86_64.debug.tar.gz -- name: bin_gpdb7_el8_debug - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/published/main/server-rc-(.*\+dev\.\d+.*)-el8_x86_64.debug.tar.gz -# Latest release candidates, no fault-injector, no assertion: -# --disable-debug-extensions --disable-tap-tests --enable-ic-proxy -- name: bin_gpdb6_centos6 - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb6/greenplum-db-server-(6\.([0-9]|([1-8][0-9])|(9[0-8]))\..*\+dev\.\d+)-.*-centos6.tar.gz -- name: bin_gpdb6_centos7 - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb6/greenplum-db-server-(6\.([0-9]|([1-8][0-9])|(9[0-8]))\..*\+dev\.\d+)-.*-centos7.tar.gz -- name: bin_gpdb6_rhel8 - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb6/greenplum-db-server-(6\.([0-9]|([1-8][0-9])|(9[0-8]))\..*\+dev\.\d+)-.*-rhel8.tar.gz -- name: bin_gpdb6_ubuntu18 - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb6/greenplum-db-server-(6\.([0-9]|([1-8][0-9])|(9[0-8]))\..*\+dev\.\d+)-.*-ubuntu18.04.tar.gz -- name: bin_gpdb7_el8 - type: gcs - source: - bucket: pivotal-gpdb-concourse-resources-prod - json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb7/greenplum-db-server-(7\.([0-9]|([1-8][0-9])|(9[0-8]))\..*\+dev\.\d+)-.*-el8.tar.gz - -# Greenplum sources -- name: gpdb6_src - type: git - source: - branch: 6X_STABLE - uri: https://github.com/greenplum-db/gpdb.git -- name: gpdb7_src - type: git - source: - branch: main - uri: https://github.com/greenplum-db/gpdb.git diff --git a/concourse/lib/res_def_misc.yml b/concourse/lib/res_def_misc.yml deleted file mode 100644 index 3105dd38..00000000 --- a/concourse/lib/res_def_misc.yml +++ /dev/null @@ -1,7 +0,0 @@ -resources_misc: - -# Other dependencies -- name: slack_notify_extensions - type: slack-alert - source: - url: ((extension/extensions-slack-webhook)) diff --git a/concourse/lib/res_types_def.yml b/concourse/lib/res_types_def.yml deleted file mode 100644 index 07eebf6e..00000000 --- a/concourse/lib/res_types_def.yml +++ /dev/null @@ -1,21 +0,0 @@ -resource_types_common: -- name: gcs - type: registry-image - check_every: 1h - source: - repository: frodenas/gcs-resource - tag: latest - -- name: pull-request - type: registry-image - check_every: 1h - source: - repository: teliaoss/github-pr-resource - tag: latest - -- name: slack-alert - type: registry-image - source: - repository: arbourd/concourse-slack-alert-resource - tag: latest - diff --git a/concourse/pipeline/base.lib.yml b/concourse/pipeline/base.lib.yml deleted file mode 100644 index 3b71d4ca..00000000 --- a/concourse/pipeline/base.lib.yml +++ /dev/null @@ -1,34 +0,0 @@ -#@ load("@ytt:data", "data") -#! add_res_by_xxx is to solve the unused resources error for concourse -#@ def add_res_by_conf(res_map, job_conf): -#@ for key in job_conf: -#@ if key.startswith("res_"): -#@ res_name = job_conf[key] -#@ res_map[res_name] = True -#@ end -#@ end -#@ end -#@ -#@ def add_res_by_name(res_map, res_name): -#@ res_map[res_name] = True -#@ end -#@ -#@ def declare_res(res_type_map, res_map): -#@ for val in data.values.resources: -#@ res_name = val["name"] -#@ res_type = val["type"] -#@ if res_map.get(val["name"]): -#@ res_type_map[res_type] = True - - #@ val -#@ end -#@ end -#@ end -#@ -#@ def declare_res_type(res_type_map): -#@ for val in data.values.resource_types: -#@ type_name = val["name"] -#@ if res_type_map.get(type_name): - - #@ val -#@ end -#@ end -#@ end diff --git a/concourse/pipeline/commit.yml b/concourse/pipeline/commit.yml deleted file mode 100644 index 7f990522..00000000 --- a/concourse/pipeline/commit.yml +++ /dev/null @@ -1,40 +0,0 @@ -#@ load("job_def.lib.yml", -#@ "entrance_job", -#@ "build_test_job", -#@ "centos7_gpdb6_conf", -#@ "ubuntu18_gpdb6_conf", -#@ "rhel8_gpdb6_conf", -#@ "el8_gpdb7_conf", -#@ ) -#@ load("trigger_def.lib.yml", -#@ "commit_trigger", -#@ ) -#@ -#@ load("base.lib.yml", "declare_res", "declare_res_type") -#@ res_map = {} -#@ res_type_map = {} -#@ trigger = commit_trigger(res_map) -#@ confs = [ -#@ rhel8_gpdb6_conf(), -#@ centos7_gpdb6_conf(), -#@ ubuntu18_gpdb6_conf(), -#@ el8_gpdb7_conf(), -#@ ] -jobs: -#@ param = { -#@ "res_map": res_map, -#@ "trigger": trigger, -#@ } -- #@ entrance_job(param) -#@ for conf in confs: -#@ param = { -#@ "res_map": res_map, -#@ "trigger": trigger, -#@ "conf": conf -#@ } -- #@ build_test_job(param) -#@ end - -resources: #@ declare_res(res_type_map, res_map) - -resource_types: #@ declare_res_type(res_type_map) diff --git a/concourse/pipeline/dev.yml b/concourse/pipeline/dev.yml deleted file mode 100644 index 4ff226ec..00000000 --- a/concourse/pipeline/dev.yml +++ /dev/null @@ -1,38 +0,0 @@ -#@ load("job_def.lib.yml", -#@ "entrance_job", -#@ "build_test_job", -#@ "centos7_gpdb6_conf", -#@ "ubuntu18_gpdb6_conf", -#@ "rhel8_gpdb6_conf", -#@ "el8_gpdb7_conf") -#@ -#@ load("trigger_def.lib.yml", -#@ "commit_dev_trigger", -#@ ) -#@ -#@ load("base.lib.yml", "declare_res", "declare_res_type") -#@ res_map = {} -#@ res_type_map = {} -#@ trigger = commit_dev_trigger(res_map) -#@ confs= [ -#@ rhel8_gpdb6_conf(release_build=False), -#@ el8_gpdb7_conf(release_build=False) -#@ ] -jobs: -#@ param = { -#@ "res_map": res_map, -#@ "trigger": trigger, -#@ } -- #@ entrance_job(param) -#@ for conf in confs: -#@ param = { -#@ "res_map": res_map, -#@ "trigger": trigger, -#@ "conf": conf -#@ } -- #@ build_test_job(param) -#@ end - -resources: #@ declare_res(res_type_map, res_map) - -resource_types: #@ declare_res_type(res_type_map) diff --git a/concourse/pipeline/job_def.lib.yml b/concourse/pipeline/job_def.lib.yml deleted file mode 100644 index d8eec71f..00000000 --- a/concourse/pipeline/job_def.lib.yml +++ /dev/null @@ -1,150 +0,0 @@ -#@ load("base.lib.yml", "add_res_by_conf", "add_res_by_name") -#@ load("@ytt:template", "template") - -#! Use bin_gpdb_postfix="" to use a release version of gpdb binary -#! Job config for centos7 -#@ def centos7_gpdb6_conf(release_build=False): -res_test_image: centos7-gpdb6-image-test -res_gpdb_bin: bin_gpdb6_centos7 -res_gpdb_src: gpdb6_src -gpdb_version: gpdb6 -res_plpython3_bin: bin_plpython3_gpdb6_rhel7 -os: rhel7 -#@ end - -#! Job config for rhel8 -#@ def rhel8_gpdb6_conf(release_build=False): -res_test_image: rhel8-gpdb6-image-test -res_gpdb_bin: bin_gpdb6_rhel8 -res_gpdb_src: gpdb6_src -gpdb_version: gpdb6 -res_plpython3_bin: bin_plpython3_gpdb6_rhel8 -os: rhel8 -#@ end - -#! Job config for ubuntu18 -#@ def ubuntu18_gpdb6_conf(release_build=False): -res_test_image: ubuntu18-gpdb6-image-test -res_gpdb_bin: bin_gpdb6_ubuntu18 -res_gpdb_src: gpdb6_src -gpdb_version: gpdb6 -res_plpython3_bin: bin_plpython3_gpdb6_ubuntu18 -os: ubuntu1804 -#@ end - -#! Job config for gpdb7 el8 -#@ def el8_gpdb7_conf(release_build=False): -res_test_image: rhel8-gpdb7-image-test -res_gpdb_bin: #@ "bin_gpdb7_el8" + ("" if release_build else "_debug") -res_gpdb_src: gpdb7_src -gpdb_version: gpdb7 -os: el8 -#@ end - -#! The entry point of a pipeline. The job name must be 'entrance'. -#@ def entrance_job(param): -#@ trigger = param["trigger"] -name: entrance -on_failure: #@ trigger["on_failure"] -on_error: #@ trigger["on_error"] -plan: -#@ for to_get in trigger["to_get"]: -- trigger: #@ trigger["auto_trigger"] - _: #@ template.replace(to_get) -#@ end -#@ for to_put in trigger["to_put_pre"]: -- #@ to_put -#@ end -#@ end - -#@ def exit_job(param): -#@ trigger = param["trigger"] -#@ confs = param["confs"] -#@ passed_jobs = [] -#@ for conf in confs: -#@ passed_jobs.append(build_test_job_name(conf)) -#@ end -name: exit -on_failure: #@ trigger["on_failure"] -on_error: #@ trigger["on_error"] -on_success: #@ trigger["on_success"] -plan: -#@ for to_get in trigger["to_get"]: -- passed: passed_jobs - trigger: true - _: #@ template.replace(to_get) -#@ end -#@ end - -#@ def exit_pr_job(param): -#@ trigger = param["trigger"] -#@ confs = param["confs"] -#@ passed_jobs = [] -#@ for conf in confs: -#@ passed_jobs.append(build_test_job_name(conf)) -#@ end -name: exit_pr -on_failure: #@ trigger["on_failure"] -on_error: #@ trigger["on_error"] -on_success: #@ trigger["on_success"] -plan: -#@ for to_get in trigger["to_get"]: -- passed: #@ passed_jobs - trigger: true - _: #@ template.replace(to_get) -#@ end -#@ end - -#@ def _test_task(conf): -task: #@ "test_" + conf["os"] -timeout: 2h -config: - platform: linux - run: - path: greenplumpython_src/concourse/scripts/entry.sh - args: - - test - inputs: - - name: bin_gpdb - - name: gpdb_src - - name: greenplumpython_src -#@ if conf["gpdb_version"] == "gpdb6": - - name: bin_plpython3 -#@ end -image: image_test -params: -#@ end - -#@ def build_test_job_name(conf): -#@ return "build_test_" + conf["gpdb_version"] + "_" + conf["os"] -#@ end -#@ def build_test_job(param): -#@ res_map = param["res_map"] -#@ trigger = param["trigger"] -#@ conf = param["conf"] -#@ add_res_by_conf(res_map, conf) -name: #@ build_test_job_name(conf) -max_in_flight: 10 -on_failure: #@ trigger["on_failure"] -on_error: #@ trigger["on_error"] -plan: -#@ for to_get in trigger["to_get"]: -- passed: [entrance] - trigger: true - _: #@ template.replace(to_get) -#@ end -- in_parallel: - - get: image_test - resource: #@ conf["res_test_image"] - - get: bin_gpdb - resource: #@ conf["res_gpdb_bin"] - - get: gpdb_src - resource: #@ conf["res_gpdb_src"] -#@ if conf["gpdb_version"] == "gpdb6": - - get: bin_plpython3 - resource: #@ conf["res_plpython3_bin"] - params: - unpack: true -#@ end -- #@ _test_task(conf) -#@ end diff --git a/concourse/pipeline/pr.yml b/concourse/pipeline/pr.yml deleted file mode 100644 index 4e36bd93..00000000 --- a/concourse/pipeline/pr.yml +++ /dev/null @@ -1,47 +0,0 @@ -#@ load("job_def.lib.yml", -#@ "entrance_job", -#@ "exit_pr_job", -#@ "build_test_job", -#@ "centos7_gpdb6_conf", -#@ "rhel8_gpdb6_conf", -#@ "ubuntu18_gpdb6_conf", -#@ "el8_gpdb7_conf", -#@ ) -#@ load("trigger_def.lib.yml", -#@ "pr_trigger", -#@ ) -#@ load("base.lib.yml", -#@ "declare_res", -#@ "declare_res_type") -#@ res_map = {} -#@ res_type_map = {} -#@ trigger = pr_trigger(res_map) -#@ confs = [ -#@ centos7_gpdb6_conf(), -#@ rhel8_gpdb6_conf(), -#@ ubuntu18_gpdb6_conf(), -#@ el8_gpdb7_conf(), -#@ ] -jobs: -#@ param = { -#@ "res_map": res_map, -#@ "trigger": trigger, -#@ } -- #@ entrance_job(param) -#@ for conf in confs: -#@ param = { -#@ "res_map": res_map, -#@ "trigger": trigger, -#@ "conf": conf -#@ } -- #@ build_test_job(param) -#@ end -#@ param = { -#@ "trigger": trigger, -#@ "confs": confs -#@ } -- #@ exit_pr_job(param) - -resources: #@ declare_res(res_type_map, res_map) - -resource_types: #@ declare_res_type(res_type_map) diff --git a/concourse/pipeline/release.yml b/concourse/pipeline/release.yml deleted file mode 100644 index eda067c4..00000000 --- a/concourse/pipeline/release.yml +++ /dev/null @@ -1,47 +0,0 @@ -#@ load("job_def.lib.yml", -#@ "entrance_job", -#@ "build_test_job", -#@ "exit_release_job", -#@ "centos7_gpdb6_conf", -#@ "rhel8_gpdb6_conf", -#@ "ubuntu18_gpdb6_conf", -#@ "el8_gpdb7_conf", -#@ ) -#@ load("trigger_def.lib.yml", -#@ "release_trigger", -#@ ) -#@ -#@ load("base.lib.yml", "declare_res", "declare_res_type") -#@ res_map = {} -#@ res_type_map = {} -#@ trigger = release_trigger(res_map) -#@ confs = [ -#@ centos7_gpdb6_conf(release_build=True), -#@ rhel8_gpdb6_conf(release_build=True), -#@ ubuntu18_gpdb6_conf(release_build=True), -#@ el8_gpdb7_conf(release_build=True), -#@ ] -jobs: -#@ param = { -#@ "res_map": res_map, -#@ "trigger": trigger, -#@ } -- #@ entrance_job(param) -#@ for conf in confs: -#@ param = { -#@ "res_map": res_map, -#@ "trigger": trigger, -#@ "conf": conf -#@ } -- #@ build_test_job(param) -#@ end -#@ param = { -#@ "res_map": res_map, -#@ "trigger": trigger, -#@ "confs": confs -#@ } -- #@ exit_release_job(param) - -resources: #@ declare_res(res_type_map, res_map) - -resource_types: #@ declare_res_type(res_type_map) diff --git a/concourse/pipeline/res_def.yml b/concourse/pipeline/res_def.yml deleted file mode 100644 index 69da96f8..00000000 --- a/concourse/pipeline/res_def.yml +++ /dev/null @@ -1,52 +0,0 @@ -resources: -# Pull Request -- name: greenplumpython_pr - type: pull-request - # We should rely on the webhook. See README if webhook doesn't work - webhook_token: ((extension/extensions-webhook-token)) - check_every: 24h - source: - disable_forks: true - repository: greenplum-db/GreenplumPython - access_token: ((extension/github-access-token)) - base_branch: main -# Commit trigger -- name: greenplumpython_commit - type: git - # We should rely on the webhook. See README if webhook doesn't work - webhook_token: ((extension/extensions-webhook-token)) - check_every: 1h - source: - branch: ((greenplumpython-branch)) - uri: https://github.com/greenplum-db/GreenplumPython - username: ((extension/github-access-token)) - password: x-oauth-basic -# Commit dev trigger. Not using webhook -- name: greenplumpython_commit_dev - type: git - check_every: 1m - source: - branch: ((greenplumpython-branch)) - uri: https://github.com/greenplum-db/GreenplumPython - username: ((extension/github-access-token)) - password: x-oauth-basic - -# plpython3 for gpdb6 -- name: bin_plpython3_gpdb6_rhel7 - type: gcs - source: - bucket: gp-extensions-ci - json_key: ((extension/extensions-gcs-service-account-key-dev2)) - versioned_file: intermediates_release/plpython3/plpython3_rhel7_gpdb6.tar.gz -- name: bin_plpython3_gpdb6_rhel8 - type: gcs - source: - bucket: gp-extensions-ci - json_key: ((extension/extensions-gcs-service-account-key-dev2)) - versioned_file: intermediates_release/plpython3/plpython3_rhel8_gpdb6.tar.gz -- name: bin_plpython3_gpdb6_ubuntu18 - type: gcs - source: - bucket: gp-extensions-ci - json_key: ((extension/extensions-gcs-service-account-key-dev2)) - versioned_file: intermediates_release/plpython3/plpython3_ubuntu18.04_gpdb6.tar.gz diff --git a/concourse/pipeline/trigger_def.lib.yml b/concourse/pipeline/trigger_def.lib.yml deleted file mode 100644 index d83b0bad..00000000 --- a/concourse/pipeline/trigger_def.lib.yml +++ /dev/null @@ -1,73 +0,0 @@ -#@ load("base.lib.yml", "add_res_by_name") - -#! PR trigger. For pull request pipelines -#@ def pr_trigger(res_map): -#@ add_res_by_name(res_map, "greenplumpython_pr") -auto_trigger: true -to_get: - - get: greenplumpython_src - resource: greenplumpython_pr - params: - fetch_tags: true - submodules: true -to_put_pre: - - put: greenplumpython_pr - params: - path: greenplumpython_src - status: pending -to_put_post: #@ [] -on_failure: - put: greenplumpython_pr - params: - path: greenplumpython_src - status: failure -on_error: - put: greenplumpython_pr - params: - path: greenplumpython_src - status: failure -on_success: - put: greenplumpython_pr - params: - path: greenplumpython_src - status: success -#@ end - -#! Commit trigger. For main pipelines -#@ def commit_trigger(res_map): -#@ add_res_by_name(res_map, "greenplumpython_commit") -#@ add_res_by_name(res_map, "slack_notify_extensions") -auto_trigger: true -to_get: -- get: greenplumpython_src - resource: greenplumpython_commit -to_put_pre: #@ [] -to_put_post: #@ [] -#! To set the github commit status, https://github.com/Pix4D/cogito is a good choice. -#! Unfortunately it doesn't work with Concourse 5. -on_success: -on_failure: - put: slack_notify_extensions - params: - alert_type: failed -on_error: - put: slack_notify_extensions - params: - alert_type: errored -#@ end - -#! Commit trigger. For dev pipelines. No webhook -#@ def commit_dev_trigger(res_map): -#@ add_res_by_name(res_map, "greenplumpython_commit_dev") -auto_trigger: true -to_get: -- get: greenplumpython_src - resource: greenplumpython_commit_dev -to_put_pre: #@ [] -to_put_post: #@ [] -#! To set the github commit status, https://github.com/Pix4D/cogito is a good choice. -#! Unfortunately it doesn't work with Concourse 5. -on_success: -on_failure: -on_error: -#@ end diff --git a/concourse/scripts/entry.sh b/concourse/scripts/entry.sh deleted file mode 100755 index ccf10adb..00000000 --- a/concourse/scripts/entry.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash - -# Entry point for GPDB source & cluster related tasks. -# This script setup basic build/test environment including: -# - Create a gpadmin user -# - Copy all files from /tmp/build/xxx (concourse WORKDIR) to /home/gpadmin/ and chown to gpadmin -# - Some dependencies doesn't exist in build/test image. -# - Special setup for individual task which needs root permission. -# - At the end, call the task script with gpadmin permission. -# -# Simple rules: -# 1. Any root operations should happen in this script. -# 2. Task script only requires gpadmin permission. -# 3. Since everything has been copied to the /home/gpadmin directory, use absolute path as much as -# as possible in the task script, it will reduce the confusion when we fly into the concourse -# container. -# 4. Bash functions should be idempotent as much as possible to make fly hijack debugging easier. - -set -eox - -if [[ ! ${PWD} =~ /tmp/build/[0-9a-z]* ]]; then - echo "This script should always be started from concourse WORKDIR." -fi - -# Internal utilty functions -_determine_os() { - local name version - if [ -f /etc/redhat-release ]; then - name="rhel" - version=$(sed /dev/stderr - exit 1 - fi - echo "${name}${version}" -} - -OS_NAME=$(_determine_os) - -# Global ENV defines -# /tmp/build/xxxxx. it should not be used in normal conditions. Use /home/gpadmin instead. -# Everything has been linked there. -export CONCOURSE_WORK_DIR=${PWD} - -install_extra_build_dependencies() { - case "$OS_NAME" in - rhel7) - yum install -y wget - wget https://bootstrap.pypa.io/pip/get-pip.py - ;; - rhel8) - ;; - ubuntu*) - wget https://bootstrap.pypa.io/pip/get-pip.py - ;; - *) ;; - esac -} - -# Dependency installers -# Ideally all dependencies should exist in the docker image. Use this script to install them only -# if it is more difficult to change it in the image side. -# Download the dependencies with concourse resources as much as possible, then we could benifit from -# concourse's resource cache system. -install_dependencies() { - unset PYTHONPATH - unset PYTHONHOME - - - local python_bin=$(which "python3.9") - if [[ -z $python_bin ]]; then - local python_bin="${GPHOME}/ext/python3.9/bin/python3.9" - fi - ${python_bin} -m ensurepip - ${python_bin} -m pip install tox -} - -# Create gpadmin user and chown all files in the PWD. All files will be linked to /home/gpadmin. -# All of our work should be started from there. -setup_gpadmin() { - # If the gpadmin exist, quit - if grep -c '^gpadmin:' /etc/passwd; then - return - fi - - # If the image has sshd, then we call gpdb's setup_gpadmin_user.sh to create the gpadmin user - # and setup the ssh. - # Otherwise, create the gpadmin user only. - if [ -f /etc/ssh/sshd_config ]; then - pushd "${CONCOURSE_WORK_DIR}" - local gpdb_concourse_dir="${CONCOURSE_WORK_DIR}/gpdb_src/concourse/scripts" - "${gpdb_concourse_dir}/setup_gpadmin_user.bash" - popd - else - # Below is copied from setup_gpadmin_user.bash - groupadd supergroup - case "$OS_NAME" in - rhel*) - /usr/sbin/useradd -G supergroup,tty gpadmin - ;; - ubuntu*) - /usr/sbin/useradd -G supergroup,tty gpadmin -s /bin/bash - ;; - sles*) - # create a default group gpadmin, and add user gpadmin to group gapdmin, supergroup, - # tty - /usr/sbin/useradd -U -G supergroup,tty gpadmin - ;; - photon*) - /usr/sbin/useradd -U -G supergroup,tty,root gpadmin - ;; - *) echo "Unknown OS: $OS_NAME"; exit 1 ;; - esac - echo -e "password\npassword" | passwd gpadmin - fi - mkdir -p /home/gpadmin - chown gpadmin:gpadmin /home/gpadmin - - chown -R gpadmin:gpadmin /tmp/build - ln -s "${CONCOURSE_WORK_DIR}"/* /home/gpadmin -} - -function install_plpython3() { - mkdir -p bin_plpython3/install_tmp - pushd bin_plpython3/install_tmp - find .. -maxdepth 1 -regex ".*-[0-9\.]*-.*\.tar\.gz" -exec tar xfv {} \; - ./install_gpdb_component - popd -} - -# Extract gpdb binary -function install_gpdb() { - [ ! -d /usr/local/greenplum-db-devel ] && mkdir -p /usr/local/greenplum-db-devel - tar -xzf "${CONCOURSE_WORK_DIR}"/bin_gpdb/*.tar.gz -C /usr/local/greenplum-db-devel - local python_bin=$(which "python3.9") - if [[ -z $python_bin ]]; then - GPHOME=/usr/local/greenplum-db-devel install_plpython3 - fi - - chown -R gpadmin:gpadmin /usr/local/greenplum-db-devel - # Start cluster - source "/home/gpadmin/gpdb_src/concourse/scripts/common.bash" - make_cluster - source /home/gpadmin/gpdb_src/gpAux/gpdemo/gpdemo-env.sh -} - -function setup_gpadmin_bashrc() { - { - echo "source /usr/local/greenplum-db-devel/greenplum_path.sh" - echo "source /home/gpadmin/gpdb_src/gpAux/gpdemo/gpdemo-env.sh" - echo "export OS_NAME=${OS_NAME}" - echo "export PATH=\$PATH:${GPHOME}/ext/python3.9/bin" - # psycopg2 needs Python.h - echo "export CFLAGS=-I/usr/local/greenplum-db-devel/ext/python3.9/include/python3.9" - } >> /home/gpadmin/.bashrc -} - - -# Setup common environment -install_extra_build_dependencies -setup_gpadmin -install_gpdb -install_dependencies -setup_gpadmin_bashrc - -# Do the special setup with root permission for the each task, then run the real task script with -# gpadmin. bashrc won't be read by 'su', it needs to be sourced explicitly. -case "$1" in - test) - - # To make fly debug easier - su gpadmin -c \ - "source /home/gpadmin/.bashrc &&\ - /home/gpadmin/greenplumpython_src/concourse/scripts/test.sh" - ;; - *) - echo "Unknown target task $1" - exit 1 - ;; -esac diff --git a/concourse/scripts/test.sh b/concourse/scripts/test.sh deleted file mode 100755 index 52e3ec06..00000000 --- a/concourse/scripts/test.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -l - -set -exo pipefail - -function _main() { - # FIXME: The test db and extension creation should be handled by python code. - createdb gpadmin - psql gpadmin -c "CREATE LANGUAGE plpython3u;" - - # Run testing - pushd /home/gpadmin/greenplumpython_src - unset PYTHONPATH - unset PYTHONHOME - python3.9 -m pip install . - tox -e test_py39 - popd -} - -_main diff --git a/concourse/test.sh b/concourse/test.sh new file mode 100755 index 00000000..3c43ad6f --- /dev/null +++ b/concourse/test.sh @@ -0,0 +1,55 @@ +#!/bin/bash -l + +set -o xtrace -o errexit -o nounset -o pipefail + +install_plpython3() { + if [[ $GP_MAJOR_VERSION == 6 && ! -f "$(pg_config --pkglibdir)/plpython3.so" ]]; then + mkdir -p bin_plpython3/install_tmp + pushd bin_plpython3/install_tmp + find .. -maxdepth 1 -regex ".*-[0-9\.]*-.*\.tar\.gz" -exec tar xfv {} \; + ./install_gpdb_component + popd + fi +} + +start_gpdb_as_gpadmin() { + if ! gpstate; then + source "$CI_REPO_DIR/common/entry_common.sh" + sudo passwd --delete gpadmin # for `su gpadmin` in start_gpdb + if [[ "$(source /etc/os-release && echo "$ID")" == "ubuntu" ]]; then + su () { + sudo "su" "$@" + } + fi + set +o nounset + start_gpdb + source "$HOME/.bashrc" # for gpdemo-env.sh + set -o nounset + fi +} + +setup_testdb() { + local testdb=$1 + # FIXME: The test db and extension creation should be handled by python code. + if ! psql "$testdb" -c ''; then + createdb "$testdb" + fi + psql "$testdb" -c "CREATE EXTENSION IF NOT EXISTS plpython3u;" +} + +_main() { + install_plpython3 + start_gpdb_as_gpadmin + setup_testdb gpadmin + + # Run testing + pushd /home/gpadmin/greenplumpython_src + unset PYTHONPATH + unset PYTHONHOME + python3.9 -m pip install tox + python3.9 -m pip install . + tox -e test_py39 + popd +} + +_main