From 23f47f88176fdf427dce6f959d69d9dc2936473c Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Mon, 6 May 2024 15:06:49 +0800 Subject: [PATCH 1/4] ci: remove drone Signed-off-by: PoAn Yang (cherry picked from commit 683212a959b0b04fe96f5dfef92053bb45ce12e5) --- .drone.yml | 297 ----------------------------------------------------- 1 file changed, 297 deletions(-) delete mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 0827b0659..000000000 --- a/.drone.yml +++ /dev/null @@ -1,297 +0,0 @@ ---- -kind: pipeline -name: default-amd64 - -platform: - os: linux - arch: amd64 - -trigger: - branch: - - master - - main - - v* - -steps: -- name: fetch - image: ubuntu:18.04 - commands: - - apt-get update - - apt-get install -y git - - git fetch --tags - -- name: build - pull: default - image: rancher/dapper:v0.5.3 - commands: - - dapper ci - privileged: true - volumes: - - name: socket - path: /var/run/docker.sock - when: - event: - - pull_request - -- name: build-with-skip-tasks - pull: default - image: rancher/dapper:v0.5.3 - commands: - - dapper ci - environment: - SKIP_TASKS: integration-test - volumes: - - name: socket - path: /var/run/docker.sock - when: - event: - exclude: - - pull_request - -- name: codecov - image: robertstettner/drone-codecov - settings: - token: - from_secret: CODECOV_TOKEN - debug: true - -- name: fossa - image: registry.suse.com/suse/sle15:15.3.17.8.1 - failure: ignore - environment: - FOSSA_API_KEY: - from_secret: FOSSA_API_KEY - commands: - - zypper -n install curl unzip - - "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/spectrometer/master/install.sh | sh" - - fossa analyze - - fossa test - when: - instance: - - drone-publish.longhorn.io - ref: - include: - - "refs/heads/master" - event: - - push - - tag - -- name: publish-image - image: plugins/docker - settings: - build_args: - - ARCH=amd64 - custom_dns: 1.1.1.1 - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: longhornio/longhorn-engine - tag: "${DRONE_BRANCH}-head-amd64" - username: - from_secret: docker_username - when: - event: - - push - -- name: publish-tagged-image - image: plugins/docker - settings: - build_args: - - ARCH=amd64 - custom_dns: 1.1.1.1 - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: longhornio/longhorn-engine - tag: "${DRONE_TAG}-amd64" - username: - from_secret: docker_username - when: - event: - - tag - -- name: slack_notify - image: plugins/slack - settings: - template: "Build {{build.link}} failed.\n" - username: Drone_Publish - webhook: - from_secret: slack_webhook - when: - event: - exclude: - - pull_request - instance: - include: - - drone-publish.longhorn.io - status: - - failure - -volumes: -- name: socket - host: - path: /var/run/docker.sock - ---- -kind: pipeline -name: default-arm64 - -platform: - os: linux - arch: arm64 - -trigger: - branch: - - master - - main - - v* - -steps: -- name: fetch - image: ubuntu:18.04 - commands: - - apt-get update - - apt-get install -y git - - git fetch --tags - -- name: build - pull: default - image: rancher/dapper:v0.5.3 - commands: - - dapper ci - privileged: true - volumes: - - name: socket - path: /var/run/docker.sock - when: - event: - - pull_request - -- name: build-with-skip-tasks - pull: default - image: rancher/dapper:v0.5.3 - commands: - - dapper ci - environment: - SKIP_TASKS: integration-test - volumes: - - name: socket - path: /var/run/docker.sock - when: - event: - exclude: - - pull_request - -- name: publish-image - image: plugins/docker - settings: - build_args: - - ARCH=arm64 - custom_dns: 1.1.1.1 - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: longhornio/longhorn-engine - tag: "${DRONE_BRANCH}-head-arm64" - username: - from_secret: docker_username - when: - event: - - push - -- name: publish-tagged-image - image: plugins/docker - settings: - build_args: - - ARCH=arm64 - custom_dns: 1.1.1.1 - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: longhornio/longhorn-engine - tag: "${DRONE_TAG}-arm64" - username: - from_secret: docker_username - when: - event: - - tag - -- name: slack_notify - image: plugins/slack - settings: - template: "Build {{build.link}} failed.\n" - username: Drone_Publish - webhook: - from_secret: slack_webhook - when: - event: - exclude: - - pull_request - instance: - include: - - drone-publish.longhorn.io - status: - - failure - -volumes: -- name: socket - host: - path: /var/run/docker.sock - ---- -kind: pipeline -name: manifest - -platform: - os: linux - arch: amd64 - -trigger: - event: - exclude: - - pull_request - branch: - - master - - main - - v* - -steps: -- name: manifest - image: plugins/manifest:1 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - platforms: - - linux/amd64 - - linux/arm64 - target: "longhornio/longhorn-engine:${DRONE_BRANCH}-head" - template: "longhornio/longhorn-engine:${DRONE_BRANCH}-head-ARCH" - when: - instance: - - drone-publish.longhorn.io - event: - - push - -- name: manifest-tag - image: plugins/manifest:1 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - platforms: - - linux/amd64 - - linux/arm64 - target: "longhornio/longhorn-engine:${DRONE_TAG}" - template: "longhornio/longhorn-engine:${DRONE_TAG}-ARCH" - when: - instance: - - drone-publish.longhorn.io - event: - - tag - -depends_on: -- default-amd64 -- default-arm64 From 64fa19d10360aca694600c0435e8323a9b1232f0 Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Thu, 9 May 2024 13:49:08 +0800 Subject: [PATCH 2/4] ci: change to use GitHub actions Signed-off-by: PoAn Yang (cherry picked from commit ac50090f23ccdeba54a71c02c0e8bd2f615b3a41) --- .github/workflows/build.yml | 241 ++++++++++++++++++++++++++++++++++++ Dockerfile.dapper | 30 ++--- package/Dockerfile | 3 +- scripts/package | 1 + 4 files changed, 259 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..2b38125ab --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,241 @@ +name: build +on: + push: + branches: + - master + - v* + tags: + - v* + pull_request: +jobs: + build-amd64-binaries: + name: Build AMD64 binaries + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # Build binaries + - name: Run make ci + run: make ci + + - uses: codecov/codecov-action@v4 + with: + files: ./coverage.out + flags: unittests + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Upload binaries + uses: actions/upload-artifact@v4 + with: + name: binaries_amd64_artifact + path: ./bin/* + + build-arm64-binaries: + name: Build ARM64 binaries + runs-on: oracle-aarch64-4cpu-16gb + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install make + run: sudo apt-get install make + + # Build binaries + - name: Run make build + run: | + make build + make package + + - name: Upload binaries + uses: actions/upload-artifact@v4 + with: + name: binaries_arm64_artifact + path: ./bin/* + + build-push-amd64-images: + name: Build and push AMD64 images + runs-on: ubuntu-latest + needs: build-amd64-binaries + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Declare branch + run: | + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV" + + - name: Download binaries + uses: actions/download-artifact@v4 + with: + name: binaries_amd64_artifact + path: ./bin/ + + - name: Add executable permission + run: | + chmod +x ./bin/* + + - name: Copy bin folder to package + run: | + cp -r ./bin ./package/ + + - name: Login to Docker Hub + uses: docker/login-action@v3 + if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }} + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # longhornio/longhorn-engine image + - name: docker-build-longhorn-engine + uses: docker/build-push-action@v5 + with: + context: . + push: false + platforms: linux/amd64 + tags: longhornio/longhorn-engine:${{ env.branch }}-head-amd64 + file: package/Dockerfile + build-args: | + ARCH=amd64 + - name: docker-publish-longhorn-engine + if: ${{ startsWith(github.ref, 'refs/heads/') }} + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/amd64 + tags: longhornio/longhorn-engine:${{ env.branch }}-head-amd64 + file: package/Dockerfile + build-args: | + ARCH=amd64 + - name: docker-publish-longhorn-engine-with-tag + if: ${{ startsWith(github.ref, 'refs/tags/') }} + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/amd64 + tags: longhornio/longhorn-engine:${{ github.ref_name }}-amd64 + file: package/Dockerfile + build-args: | + ARCH=amd64 + + build-push-arm64-images: + name: Build and push ARM64 images + runs-on: oracle-aarch64-4cpu-16gb + needs: build-arm64-binaries + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install make + run: sudo apt-get install make + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Declare branch and sha_short + run: | + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV" + - name: Download binaries + uses: actions/download-artifact@v4 + with: + name: binaries_arm64_artifact + path: ./bin/ + + - name: Add executable permission + run: | + chmod +x ./bin/* + + - name: Copy bin folder to package + run: | + cp -r ./bin ./package/ + + - name: Login to Docker Hub + if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }} + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # longhornio/longhorn-engine image + - name: docker-build-longhorn-engine + uses: docker/build-push-action@v5 + with: + context: . + push: false + platforms: linux/arm64 + tags: longhornio/longhorn-engine:${{ env.branch }}-head-arm64 + file: package/Dockerfile + build-args: | + ARCH=arm64 + - name: docker-publish-longhorn-engine + if: ${{ startsWith(github.ref, 'refs/heads/') }} + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/arm64 + tags: longhornio/longhorn-engine:${{ env.branch }}-head-arm64 + file: package/Dockerfile + build-args: | + ARCH=arm64 + - name: docker-publish-longhorn-engine-with-tag + if: ${{ startsWith(github.ref, 'refs/tags/') }} + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/arm64 + tags: longhornio/longhorn-engine:${{ github.ref_name }}-arm64 + file: package/Dockerfile + build-args: | + ARCH=arm64 + + manifest-image: + name: Manifest images + runs-on: ubuntu-latest + needs: [build-push-amd64-images, build-push-arm64-images] + if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Declare branch and sha_short + run: | + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV" + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # longhornio/longhorn-engine image + - name: docker-pull-longhorn-engine + if: ${{ startsWith(github.ref, 'refs/heads/') }} + run: | + docker pull --platform linux/amd64 longhornio/longhorn-engine:${{ env.branch }}-head-amd64 + docker pull --platform linux/arm64 longhornio/longhorn-engine:${{ env.branch }}-head-arm64 + docker buildx imagetools create -t longhornio/longhorn-engine:${{ env.branch }}-head \ + longhornio/longhorn-engine:${{ env.branch }}-head-amd64 \ + longhornio/longhorn-engine:${{ env.branch }}-head-arm64 + - name: docker-pull-longhorn-engine-with-tag + if: ${{ startsWith(github.ref, 'refs/tags/') }} + run: | + docker pull --platform linux/amd64 longhornio/longhorn-engine:${{ github.ref_name }}-amd64 + docker pull --platform linux/arm64 longhornio/longhorn-engine:${{ github.ref_name }}-arm64 + docker buildx imagetools create -t longhornio/longhorn-engine:${{ github.ref_name }} \ + longhornio/longhorn-engine:${{ github.ref_name }}-amd64 \ + longhornio/longhorn-engine:${{ github.ref_name }}-arm64 diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 1619bd969..e878ffd3f 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -1,6 +1,6 @@ FROM registry.suse.com/bci/bci-base:15.5 -ARG DAPPER_HOST_ARCH=amd64 +ARG DAPPER_HOST_ARCH ARG http_proxy ARG https_proxy ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH} @@ -20,7 +20,7 @@ RUN zypper -n addrepo --refresh https://download.opensuse.org/repositories/syste # Install packages RUN if [ ${ARCH} == "amd64" ]; then \ - zypper -n install autoconf libtool libunwind-devel; \ + zypper -n install autoconf libtool libunwind-devel; \ fi RUN zypper -n install cmake wget curl git less file gcc \ @@ -29,13 +29,13 @@ RUN zypper -n install cmake wget curl git less file gcc \ perl-Config-General libaio-devel glibc-devel-static glibc-devel sg3_utils iptables libltdl7 \ python3-pip uuid-runtime libdevmapper1_03 iproute2 jq unzip zlib-devel zlib-devel-static \ rpm-build rdma-core-devel gcc-c++ docker && \ - rm -rf rm -rf /var/cache/zypp/* + rm -rf /var/cache/zypp/* # needed for ${!var} substitution RUN rm -f /bin/sh && ln -s /bin/bash /bin/sh RUN if [ ${ARCH} == "s390x" ]; then \ - ln -s /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc;\ + ln -s /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc;\ fi # Install Go & tools @@ -48,7 +48,7 @@ RUN wget -O - https://storage.googleapis.com/golang/go1.21.3.linux-${!GOLANG_ARC ENV MINIO_URL_amd64=https://dl.min.io/server/minio/release/linux-amd64/archive/minio.RELEASE.2021-12-20T22-07-16Z \ MINIO_URL_arm64=https://dl.min.io/server/minio/release/linux-arm64/archive/minio.RELEASE.2021-12-20T22-07-16Z \ MINIO_URL_s390x=https://dl.min.io/server/minio/release/linux-s390x/archive/minio.RELEASE.2021-12-20T22-07-16Z \ - MINIO_URL=MINIO_URL_${ARCH} + MINIO_URL=MINIO_URL_${ARCH} RUN wget ${!MINIO_URL} -O /usr/bin/minio && chmod +x /usr/bin/minio @@ -66,19 +66,19 @@ RUN ldconfig ENV GRPC_HEALTH_PROBE_amd64=https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.3.2/grpc_health_probe-linux-amd64 \ GRPC_HEALTH_PROBE_arm64=https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.3.2/grpc_health_probe-linux-arm64 \ GRPC_HEALTH_PROBE_s390x=https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.3.2/grpc_health_probe-linux-s390x \ - GRPC_HEALTH_PROBE=GRPC_HEALTH_PROBE_${ARCH} + GRPC_HEALTH_PROBE=GRPC_HEALTH_PROBE_${ARCH} RUN wget ${!GRPC_HEALTH_PROBE} -O /usr/local/bin/grpc_health_probe && \ chmod +x /usr/local/bin/grpc_health_probe # protoc ENV PROTOC_amd64=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VER}/protoc-${PROTOBUF_VER}-linux-x86_64.zip \ - PROTOC_arm64=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VER}/protoc-${PROTOBUF_VER}-linux-aarch_64.zip \ - PROTOC_s390x=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VER}/protoc-${PROTOBUF_VER}-linux-s390_64.zip \ - PROTOC=PROTOC_${ARCH} + PROTOC_arm64=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VER}/protoc-${PROTOBUF_VER}-linux-aarch_64.zip \ + PROTOC_s390x=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VER}/protoc-${PROTOBUF_VER}-linux-s390_64.zip \ + PROTOC=PROTOC_${ARCH} RUN cd /usr/src && \ - wget ${!PROTOC} -O protoc_${ARCH}.zip && \ + wget ${!PROTOC} -O protoc_${ARCH}.zip && \ unzip protoc_${ARCH}.zip -d /usr/local/ # protoc-gen-go @@ -94,10 +94,10 @@ RUN cd /go/src/github.com/ && \ # python grpc-tools RUN if [ "${ARCH}" == "s390x" ]; then \ - zypper -n in libopenssl-devel && \ - GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=True pip3 install grpcio==1.25.0 grpcio_tools==1.25.0 protobuf==${PROTOBUF_VER}; \ + zypper -n in libopenssl-devel && \ + GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=True pip3 install grpcio==1.25.0 grpcio_tools==1.25.0 protobuf==${PROTOBUF_VER}; \ else \ - pip3 install grpcio==1.25.0 grpcio_tools==1.25.0 protobuf==${PROTOBUF_VER}; \ + pip3 install grpcio==1.25.0 grpcio_tools==1.25.0 protobuf==${PROTOBUF_VER}; \ fi # buf @@ -125,9 +125,9 @@ RUN mkdir integration/ COPY integration/setup.py integration/tox.ini integration/requirements.txt integration/flake8-requirements.txt integration/ RUN cd integration && \ if [ "${ARCH}" == "s390x" ]; then \ - GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=True tox --notest;\ + GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=True tox --notest;\ else \ - tox --notest; \ + tox --notest; \ fi # Build longhorn-instance-manager for integration testing diff --git a/package/Dockerfile b/package/Dockerfile index 49eef6379..c62184d85 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -56,7 +56,8 @@ COPY --from=builder \ /usr/sbin/tgtimg \ /usr/local/bin/ -COPY bin/longhorn bin/longhorn-instance-manager /usr/local/bin/ +COPY package/bin/longhorn /usr/local/bin/ +COPY package/bin/longhorn-instance-manager /usr/local/bin/ COPY package/launch-simple-longhorn package/engine-manager package/launch-simple-file /usr/local/bin/ diff --git a/scripts/package b/scripts/package index ec3d88263..3e3a43e8d 100755 --- a/scripts/package +++ b/scripts/package @@ -31,6 +31,7 @@ if [ ! -x ./bin/longhorn ]; then fi cp /usr/local/bin/longhorn-instance-manager ./bin/ +cp -r ./bin ./package/ # update base image to get latest changes grep FROM package/Dockerfile | awk '{print $2}' | while read -r BASE_IMAGE From 0ced45f4f1273525bc93f273f4b44beda174abe1 Mon Sep 17 00:00:00 2001 From: Phan Le Date: Wed, 29 May 2024 16:57:57 -0700 Subject: [PATCH 3/4] ci: change oracle-aarch64-4cpu-16gb to longhorn-infra-arm64-runners longhorn-8039 Signed-off-by: Phan Le (cherry picked from commit b65548d14fe13edc366852dbd8a9f596b20529c1) --- .github/workflows/build.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b38125ab..e5feacda4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,14 +33,16 @@ jobs: build-arm64-binaries: name: Build ARM64 binaries - runs-on: oracle-aarch64-4cpu-16gb + runs-on: longhorn-infra-arm64-runners steps: + - name: Install make curl git + run: | + sudo apt update + sudo apt-get -y install make curl git + - name: Checkout code uses: actions/checkout@v4 - - name: Install make - run: sudo apt-get install make - # Build binaries - name: Run make build run: | @@ -127,15 +129,17 @@ jobs: build-push-arm64-images: name: Build and push ARM64 images - runs-on: oracle-aarch64-4cpu-16gb + runs-on: longhorn-infra-arm64-runners needs: build-arm64-binaries steps: + - name: Install make curl git + run: | + sudo apt update + sudo apt-get -y install make curl git + - name: Checkout code uses: actions/checkout@v4 - - name: Install make - run: sudo apt-get install make - - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx From 3d81f2c4fb6ee33519dd9357c56b525518f9991f Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Fri, 14 Jun 2024 11:14:00 +0800 Subject: [PATCH 4/4] ci: fix dry build image tag Signed-off-by: PoAn Yang (cherry picked from commit 8252f66ee7f7ed2290fa05e2aa707d9bbd8ffefb) --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e5feacda4..7561cf5d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,7 +100,7 @@ jobs: context: . push: false platforms: linux/amd64 - tags: longhornio/longhorn-engine:${{ env.branch }}-head-amd64 + tags: longhornio/longhorn-engine:dry-build file: package/Dockerfile build-args: | ARCH=amd64 @@ -176,7 +176,7 @@ jobs: context: . push: false platforms: linux/arm64 - tags: longhornio/longhorn-engine:${{ env.branch }}-head-arm64 + tags: longhornio/longhorn-engine:dry-build file: package/Dockerfile build-args: | ARCH=arm64