Skip to content

Commit

Permalink
ci: change to use GitHub actions
Browse files Browse the repository at this point in the history
Signed-off-by: PoAn Yang <poan.yang@suse.com>
  • Loading branch information
FrankYang0529 committed May 9, 2024
1 parent 9c74b58 commit ff364a3
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 4 deletions.
239 changes: 239 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
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

- 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
7 changes: 4 additions & 3 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM registry.suse.com/bci/bci-base:15.6

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}
Expand Down Expand Up @@ -30,7 +30,7 @@ RUN zypper -n install cmake wget curl git less file gcc python311 python311-pip
bash-completion librdmacm1 librdmacm-utils libibverbs xsltproc docbook-xsl-stylesheets \
perl-Config-General libaio-devel glibc-devel-static glibc-devel sg3_utils iptables libltdl7 \
libdevmapper1_03 iproute2 jq unzip zlib-devel zlib-devel-static \
rpm-build rdma-core-devel gcc-c++ docker && \
rpm-build rdma-core-devel gcc-c++ docker open-iscsi && \
rm -rf /var/cache/zypp/*

# needed for ${!var} substitution
Expand Down Expand Up @@ -118,7 +118,8 @@ RUN cd /go/src/github.com/longhorn && \
git clone https://github.com/longhorn/longhorn-instance-manager.git && \
cd longhorn-instance-manager && \
go build -o ./longhorn-instance-manager -tags netgo -ldflags "-linkmode external -extldflags -static" && \
install longhorn-instance-manager /usr/local/bin
install longhorn-instance-manager /usr/local/bin \
cp longhorn-instance-manager ./bin

VOLUME /tmp
ENV TMPDIR /tmp
Expand Down
3 changes: 2 additions & 1 deletion package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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/

Expand Down
1 change: 1 addition & 0 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff364a3

Please sign in to comment.