From 0f48e10d0e22d963f0ab60ebb5914b3e94ed4526 Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Tue, 7 May 2024 09:52:15 +0800 Subject: [PATCH] ci: change to use GitHub actions Signed-off-by: PoAn Yang --- .github/workflows/build.yml | 50 +++++++++++++++++++++++++++++++++++++ Dockerfile.dapper | 7 ++++-- pkg/spdk/spdk_test.go | 9 +++++++ scripts/test | 11 +++++++- 4 files changed, 74 insertions(+), 3 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 00000000..a3e981ae --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: build +on: + push: + branches: + - main + pull_request: +jobs: + build-amd64: + name: Build AMD64 binaries + runs-on: longhorn-infra-amd64-runners + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install make curl kmod + run: | + sudo apt update + sudo apt-get -y install make curl kmod + + # Build binaries + - name: Run ci + run: make ci + + - uses: codecov/codecov-action@v4 + with: + files: ./coverage.out + flags: unittests + token: ${{ secrets.CODECOV_TOKEN }} + + build-arm64: + name: Build ARM64 binaries + runs-on: longhorn-infra-arm64-runners + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install make curl kmod + run: | + sudo apt update + sudo apt-get -y install make curl kmod + + # Build binaries + - name: Run ci + run: make ci + + - uses: codecov/codecov-action@v4 + with: + files: ./coverage.out + flags: unittests + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/Dockerfile.dapper b/Dockerfile.dapper index d405c8b1..1da37e02 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} @@ -30,8 +30,9 @@ ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm64=arm64 GOLANG_ARCH_s390x=s390x GOLA RUN wget -O - https://storage.googleapis.com/golang/go1.22.2.linux-${!GOLANG_ARCH}.tar.gz | tar -xzf - -C /usr/local RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 - # Build SPDK +ENV HUGEMEM=1024 +RUN echo "vm.nr_hugepages=$((HUGEMEM/2))" >> /etc/sysctl.conf ENV SPDK_DIR /usr/src/spdk ENV SPDK_COMMIT_ID 62a8f8a9c5ac99f6e63d654f6fc6c427c5d8815b RUN git clone https://github.com/longhorn/spdk.git ${SPDK_DIR} --recursive && \ @@ -74,6 +75,8 @@ RUN git clone https://github.com/linux-nvme/nvme-cli.git ${NVME_CLI_DIR} && \ meson compile -C .build && \ meson install -C .build +RUN ldconfig + VOLUME /tmp ENV TMPDIR /tmp ENTRYPOINT ["./scripts/entry"] diff --git a/pkg/spdk/spdk_test.go b/pkg/spdk/spdk_test.go index 4fefc502..202ad15d 100644 --- a/pkg/spdk/spdk_test.go +++ b/pkg/spdk/spdk_test.go @@ -12,6 +12,7 @@ import ( . "gopkg.in/check.v1" commonTypes "github.com/longhorn/go-common-libs/types" + "github.com/sirupsen/logrus" "github.com/longhorn/go-spdk-helper/pkg/jsonrpc" "github.com/longhorn/go-spdk-helper/pkg/nvme" @@ -52,7 +53,11 @@ func LaunchTestSPDKTarget(c *C, execute func(envs []string, binary string, args if spdkCli, err := client.NewClient(context.Background()); err == nil { if _, err := spdkCli.BdevGetBdevs("", 0); err == nil { targetReady = true + } else { + logrus.Warnf("Failed to get SPDK bdevs: %v", err) } + } else { + logrus.Warnf("Failed to create SPDK client: %v", err) } if !targetReady { @@ -66,7 +71,11 @@ func LaunchTestSPDKTarget(c *C, execute func(envs []string, binary string, args if _, err := spdkCli.BdevGetBdevs("", 0); err == nil { targetReady = true break + } else { + logrus.Warnf("Failed to get SPDK bdevs: %v", err) } + } else { + logrus.Warnf("Failed to create SPDK client: %v", err) } time.Sleep(time.Second) } diff --git a/scripts/test b/scripts/test index 62cda39e..dbe8e144 100755 --- a/scripts/test +++ b/scripts/test @@ -14,11 +14,20 @@ then fi echo "Hugepages configured: $hugepages" +modules=("uio_pci_generic" "nvme-tcp") + +for module in "${modules[@]}" +do + if ! modprobe "$module"; then + echo "Failed to load $module module" + exit 1 + fi +done + mount --rbind /host/dev /dev mount --rbind /host/sys /sys trap "umount /dev && umount /sys" EXIT - PACKAGES="$(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')" go test -v -race -cover ${PACKAGES}