From ca7fe5ea322dfa26614ee9a73f695ae48b11a0c8 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Wed, 7 Feb 2024 09:44:01 +0000 Subject: [PATCH] Merged PR 1265227: Add container build and test github action to heliodb Tested on my own fork: https://github.com/safern/heliodb/actions --- .devcontainer/Dockerfile | 1 + .github/containers/Build-Ubuntu/Dockerfile | 65 ++++++++++++++++++++++ .github/workflows/build_containers.yml | 65 ++++++++++++++++++++++ .github/workflows/regress_tests.yml | 44 +++++++++++++++ .gitignore | 1 + .vscode/tasks.json | 15 +++++ scripts/install_citus_indent.sh | 38 +++++++++++++ 7 files changed, 229 insertions(+) create mode 100644 .github/containers/Build-Ubuntu/Dockerfile create mode 100644 .github/workflows/build_containers.yml create mode 100644 .github/workflows/regress_tests.yml create mode 100644 .vscode/tasks.json create mode 100755 scripts/install_citus_indent.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c059b222..250bf38c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -43,6 +43,7 @@ COPY scripts/ /tmp/install_setup RUN MAKE_PROGRAM=cmake /tmp/install_setup/install_setup_libbson.sh RUN /tmp/install_setup/install_setup_pcre2.sh RUN /tmp/install_setup/install_setup_intel_decimal_math_lib.sh +RUN /tmp/install_setup/install_citus_indent.sh RUN rm -rf /var/lib/apt/lists/* \ diff --git a/.github/containers/Build-Ubuntu/Dockerfile b/.github/containers/Build-Ubuntu/Dockerfile new file mode 100644 index 00000000..b3e59621 --- /dev/null +++ b/.github/containers/Build-Ubuntu/Dockerfile @@ -0,0 +1,65 @@ +FROM --platform=linux/amd64 mcr.microsoft.com/mirror/docker/library/ubuntu:20.04 + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -qy \ + wget \ + curl \ + sudo \ + gnupg2 \ + lsb-release \ + tzdata \ + build-essential \ + pkg-config \ + cmake \ + git \ + && rm -rf /var/lib/apt/lists/* + +# Add pgdg repo +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list && \ + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \ + apt-get update && \ + rm -rf /var/lib/apt/lists/* + +RUN curl -4sSf https://packagecloud.io/install/repositories/citusdata/community/script.deb.sh | bash + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y \ + postgresql-15 \ + postgresql-server-dev-15 \ + libpq-dev \ + postgresql-15-pgcron \ + postgresql-15-pgvector \ + postgresql-15-postgis-3 \ + postgresql-15-rum \ + && rm -rf /var/lib/apt/lists/* + +# Install Libbson, decimal128, pcre +ENV CLEANUP_SETUP=1 +ENV INSTALL_DEPENDENCIES_ROOT=/tmp/install_setup +RUN mkdir -p /tmp/install_setup +COPY scripts/ /tmp/install_setup +RUN MAKE_PROGRAM=cmake /tmp/install_setup/install_setup_libbson.sh +RUN /tmp/install_setup/install_setup_pcre2.sh +RUN /tmp/install_setup/install_setup_intel_decimal_math_lib.sh +RUN /tmp/install_setup/install_citus_indent.sh + + +RUN rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 + +ENV LANG en_US.utf8 + +RUN adduser --disabled-password --gecos "" --uid 1001 runner \ + && groupadd docker --gid 123 \ + && usermod -aG sudo runner \ + && usermod -aG docker runner \ + && echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ + && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers + +WORKDIR /home/runner + +USER runner + +LABEL org.opencontainers.image.source=https://github.com/microsoft/heliodb +LABEL org.opencontainers.image.description="Heliodb ubuntu build image" +LABEL org.opencontainers.image.licenses=MIT \ No newline at end of file diff --git a/.github/workflows/build_containers.yml b/.github/workflows/build_containers.yml new file mode 100644 index 00000000..eed4c529 --- /dev/null +++ b/.github/workflows/build_containers.yml @@ -0,0 +1,65 @@ +name: Build heliodb Containers + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +on: + push: + branches: + - 'main' + paths: + - '.github/containers/**' + - '.github/workflows/build_containers.yml' + pull_request: + types: [opened, reopened, synchronize] + branches: + - 'main' + paths: + - '.github/containers/**' + - '.github/workflows/build_containers.yml' + + workflow_dispatch: + inputs: + pushLatestTag: + description: 'Publish latest tag' + default: false + type: boolean + +env: + tagBranchName: ${{ github.event.pull_request && 'private' || github.ref_name }} + +jobs: + ubuntu_build_container: + + runs-on: ubuntu-latest + + steps: + - name: Set tag name + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/microsoft/heliodb/build_ubuntu + tags: | + ${{ (github.event_name == 'push' || inputs.pushLatestTag == true) && 'type=raw,value={{branch}}_latest' || 'type=raw,value={{branch}}_{{sha}}' }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: 'Login to GitHub Container Registry' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: '{{ defaultContext }}' + file: '.github/containers/Build-Ubuntu/Dockerfile' + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/regress_tests.yml b/.github/workflows/regress_tests.yml new file mode 100644 index 00000000..df6aae1b --- /dev/null +++ b/.github/workflows/regress_tests.yml @@ -0,0 +1,44 @@ +name: Build and Test +run-name: ${{ github.event.pull_request.title || '' }} +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +on: + workflow_dispatch: + push: + branches: + - 'main' + paths-ignore: + - 'docs/**' + - '.github/containers/**' + - '.devcontainer/**' + - '*.md' + pull_request: + types: [opened, reopened,synchronize] + paths-ignore: + - 'docs/**' + - '.github/containers/**' + - '.devcontainer/**' + - '*.md' + merge_group: + +jobs: + ubuntu_build: + + runs-on: ubuntu-latest + container: + image: ghcr.io/safern/heliodb/build_ubuntu:safern-setup_build_action_latest + + steps: + - uses: actions/checkout@v4 + + - name: Build and install + run: sudo make install + + - name: Run Tests + run: make check + + - name: Citus Indent + run: | + citus_indent --check || (echo ""; echo "citus_indent failed, refer to CONTRIBUTING.md on how to use citus_indent"; exit 1) diff --git a/.gitignore b/.gitignore index 85495686..86c6c832 100755 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ build/ # vscode/VS .vscode/* +!.vscode/tasks.json .vs/ *.sln diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..8e1e2e53 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Citus Indent", + "problemMatcher": [ ], + "type": "process", + "command": "citus_indent", + "args": [ ], + "group": "build" + } + ] +} \ No newline at end of file diff --git a/scripts/install_citus_indent.sh b/scripts/install_citus_indent.sh new file mode 100755 index 00000000..f3d1128b --- /dev/null +++ b/scripts/install_citus_indent.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# fail if trying to reference a variable that is not set. +set -u +# exit immediately if a command exits with a non-zero status +set -e + +# Install uncrustify. +# +# Uncrustify changes the way it formats code every release a bit. To make +# sure everyone formats consistently, we use version 0.68.1 as mentioned in +# CONTRIBUTING.md: +pushd $INSTALL_DEPENDENCIES_ROOT +rm -rf citus_indent +mkdir citus_indent +cd citus_indent +git clone https://github.com/uncrustify/uncrustify.git +cd uncrustify +# the commit of version 0.68.1 +git checkout 8c80bd84d023d9ae220c2721e68b09d10403bb41 +mkdir build +cd build/ +cmake .. +make clean && make -sj$(cat /proc/cpuinfo | grep "core id" | wc -l) install + +# Install citus_indent. +git clone https://github.com/citusdata/tools.git +cd tools +# checkout to the commit mapped in component governance. +git checkout e36e4ea4258989bf527744334f6c633bb67e0686 + +make uncrustify/.install + +if [ "${CLEANUP_SETUP:-"0"}" == "1" ]; then + rm -rf $INSTALL_DEPENDENCIES_ROOT/citus_indent +fi + +popd \ No newline at end of file