Skip to content

Commit

Permalink
ci: add .drone.yml and fix errors
Browse files Browse the repository at this point in the history
Longhorn 7509

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit authored and David Ko committed Jan 2, 2024
1 parent 5df1004 commit ca58ebb
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 17 deletions.
74 changes: 74 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
kind: pipeline
name: default-amd64

platform:
os: linux
arch: amd64

trigger:
branch:
- main

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
volumes:
- name: socket
path: /var/run/docker.sock

- name: codecov
image: robertstettner/drone-codecov
settings:
token:
from_secret: CODECOV_TOKEN
debug: true

volumes:
- name: socket
host:
path: /var/run/docker.sock

---
kind: pipeline
name: default-arm64

platform:
os: linux
arch: arm64

trigger:
branch:
- main

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
volumes:
- name: socket
path: /var/run/docker.sock

volumes:
- name: socket
host:
path: /var/run/docker.sock
58 changes: 41 additions & 17 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.suse.com/bci/bci-base:15.4
FROM registry.suse.com/bci/bci-base:15.5

ARG DAPPER_HOST_ARCH=amd64
ARG http_proxy
Expand All @@ -10,23 +10,19 @@ ENV PATH /go/bin:$PATH
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_ENV TAG REPO DRONE_REPO DRONE_PULL_REQUEST DRONE_COMMIT_REF
ENV DAPPER_OUTPUT bin coverage.out
ENV DAPPER_RUN_ARGS --privileged -v /dev:/host/dev -v /proc:/host/proc
ENV DAPPER_RUN_ARGS --privileged -v /dev:/host/dev -v /proc:/host/proc -v /sys:/host/sys
ENV DAPPER_SOURCE /go/src/github.com/longhorn/go-spdk-helper
WORKDIR ${DAPPER_SOURCE}

RUN zypper -n addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/SLE_15/system:snappy.repo && \
zypper -n addrepo --refresh https://download.opensuse.org/repositories/network:/utilities/SLE_15_SP4/network:utilities.repo && \
zypper -n addrepo --refresh https://download.opensuse.org/repositories/devel:libraries:c_c++/15.4/devel:libraries:c_c++.repo && \
zypper -n addrepo --refresh https://download.opensuse.org/repositories/devel:languages:python:Factory/15.4/devel:languages:python:Factory.repo && \
zypper -n addrepo --refresh https://download.opensuse.org/repositories/network:/utilities/SLE_15/network:utilities.repo && \
zypper -n addrepo --refresh https://download.opensuse.org/repositories/devel:libraries:c_c++/15.5/devel:libraries:c_c++.repo && \
zypper -n addrepo --refresh https://download.opensuse.org/repositories/devel:languages:python:Factory/15.5/devel:languages:python:Factory.repo && \
zypper -n addrepo --refresh https://download.opensuse.org/repositories/devel:languages:python:backports/SLE_15/devel:languages:python:backports.repo && \
zypper --gpg-auto-import-keys ref

RUN zypper -n install kmod curl fuse wget tar gzip git awk \
nfs-client nfs4-acl-tools cifs-utils \
libibverbs librdmacm1 rdma-core-devel perl-Config-General libaio-devel sg3_utils uuid-devel \
iputils telnet iproute2 qemu-tools \
e2fsprogs e2fsprogs-devel xfsprogs xfsprogs-devel util-linux-systemd python3

RUN zypper -n install cmake curl wget git gcc tar xsltproc docbook-xsl-stylesheets python3 meson ninja python3-pip \
e2fsprogs xfsprogs util-linux-systemd python3-pyelftools libcmocka-devel device-mapper

# Install Go & tools
ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm64=arm64 GOLANG_ARCH_s390x=s390x GOLANG_ARCH=GOLANG_ARCH_${ARCH} \
Expand All @@ -35,20 +31,48 @@ RUN wget -O - https://storage.googleapis.com/golang/go1.20.3.linux-${!GOLANG_ARC
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2


# longhorn/spdk
# Build SPDK
ENV SPDK_DIR /usr/src/spdk
ENV SPDK_COMMIT_ID 4542f9b14010fc7192d42e05adaafc2ae863bac5
ENV SPDK_COMMIT_ID 700b93962fba0dcd54091fd8f128a01bb0d86701
RUN git clone https://github.com/longhorn/spdk.git ${SPDK_DIR} --recursive && \
if [ ${ARCH} == "amd64" ]; then \
cd ${SPDK_DIR} && \
git checkout ${SPDK_COMMIT_ID} && \
git submodule update --init && \
./scripts/pkgdep.sh && \
./configure --target-arch=nehalem --disable-tests --disable-unit-tests --disable-examples && \
make -j$(nproc) && \
make install; \
if [ ${ARCH} = "amd64" ]; then \
./configure --target-arch=nehalem --disable-tests --disable-unit-tests --disable-examples && \
make -j$(nproc) && \
make install; \
elif [ ${ARCH} = "arm64" ]; then \
./configure --target-arch=native --disable-tests --disable-unit-tests --disable-examples && \
DPDKBUILD_FLAGS="-Dplatform=generic" make -j$(nproc) && \
make install; \
else \
echo "Unsupported architecture: ${ARCH}"; \
exit 1; \
fi

# Build libjson-c-devel
ENV LIBJSONC_COMMIT_ID b4c371fa0cbc4dcbaccc359ce9e957a22988fb34
RUN cd /usr/src && \
git clone https://github.com/json-c/json-c.git && \
cd json-c && \
git checkout ${LIBJSONC_COMMIT_ID} && \
mkdir .build && \
cd .build && \
cmake ../ && \
make && \
make install

# Build nvme-cli 2.5
ENV NVME_CLI_DIR /usr/src/nvme-cli
ENV NVME_CLI_COMMIT_ID d6c07e0de9be777009ebb9ab7475bee1ae3e0e95
RUN git clone https://github.com/linux-nvme/nvme-cli.git ${NVME_CLI_DIR} && \
cd ${NVME_CLI_DIR} && \
git checkout ${NVME_CLI_COMMIT_ID} && \
meson setup --force-fallback-for=libnvme .build && \
meson compile -C .build && \
meson install -C .build

VOLUME /tmp
ENV TMPDIR /tmp
Expand Down
2 changes: 2 additions & 0 deletions pkg/nvme/initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,14 @@ func (i *Initiator) suspendLinearDmDevice() error {
return util.DmsetupSuspend(i.Name, i.executor)
}

// nolint:unused
func (i *Initiator) resumeLinearDmDevice() error {
logrus.Infof("Resuming linear dm device %s", i.Name)

return util.DmsetupResume(i.Name, i.executor)
}

// nolint:unused
func (i *Initiator) reloadLinearDmDevice() error {
devPath := fmt.Sprintf("/dev/%s", i.dev.Nvme.Name)

Expand Down
6 changes: 6 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

cd "$(dirname $0)"/..

go build ./...
1 change: 1 addition & 0 deletions scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ set -e

cd $(dirname $0)

./build
./validate
./test
14 changes: 14 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ cd $(dirname $0)/..

echo Running tests

# Check if hugepages are configured
hugepages="$(grep HugePages_Total < /proc/meminfo | awk '{print $2}')"
if [ -z "$hugepages" ] || [ 1 -gt $hugepages ]
then
echo No hugepages configured on the host for the test
exit 1
fi
echo "Hugepages configured: $hugepages"

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}

0 comments on commit ca58ebb

Please sign in to comment.