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 <[email protected]>
  • Loading branch information
FrankYang0529 committed Apr 30, 2024
1 parent e9439c0 commit 58e1301
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build
on:
push:
branches:
- master
- v*
tags:
- v*
pull_request:
jobs:
build:
name: Build binaries
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

# Build binaries
- name: Run ci
run: make ci

- uses: codecov/codecov-action@v4
with:
files: ./coverage.out
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
33 changes: 20 additions & 13 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM registry.suse.com/bci/bci-base:15.6

ARG DAPPER_HOST_ARCH=amd64
ARG http_proxy
Expand All @@ -15,10 +15,16 @@ ENV DAPPER_SOURCE /go/src/github.com/longhorn/go-iscsi-helper
WORKDIR ${DAPPER_SOURCE}

# Install packages
RUN apt-get update && \
apt-get install -y cmake wget curl git \
devscripts debhelper bash-completion librdmacm-dev libibverbs-dev xsltproc docbook-xsl \
libconfig-general-perl libaio-dev libc6-dev iptables libltdl7
RUN zypper -n addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/SLE_15/system:snappy.repo && \
zypper --gpg-auto-import-keys ref

RUN zypper -n install cmake wget curl git less file gcc open-iscsi \
libkmod-devel libnl3-devel linux-glibc-devel pkg-config psmisc qemu-tools fuse \
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 && \
rm -rf /var/cache/zypp/*

# needed for ${!var} substitution
RUN rm -f /bin/sh && ln -s /bin/bash /bin/sh
Expand All @@ -29,20 +35,21 @@ ENV GOLANG_ARCH_amd64=amd64 GOLANG_ARCH_arm64=arm64 GOLANG_ARCH=GOLANG_ARCH_${AR
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

# Docker
ENV DOCKER_URL_amd64=https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_17.03.3~ce-0~ubuntu-xenial_amd64.deb \
DOCKER_URL_arm64=https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/arm64/docker-ce_18.06.1~ce~3-0~ubuntu_arm64.deb \
DOCKER_URL=DOCKER_URL_${ARCH}

RUN wget ${!DOCKER_URL} -O docker_ce_${ARCH} && dpkg -i docker_ce_${ARCH}
# Build liblonghorn
RUN cd /usr/src && \
git clone https://github.com/rancher/liblonghorn.git && \
cd liblonghorn && \
git checkout 53d1c063b95efc8d949b095bd4bf04637230265f && \
make; \
make install

# Build TGT
RUN cd /usr/src && \
git clone https://github.com/rancher/tgt.git && \
cd tgt && \
git checkout 3a8bc4823b5390e046f7aa8231ed262c0365c42c && \
./scripts/build-pkg.sh deb && \
dpkg -i ./pkg/tgt_*.deb
make; \
make install

VOLUME /tmp
ENV TMPDIR /tmp
Expand Down
12 changes: 11 additions & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ echo Running tests

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}
modules=("iscsi_tcp")

for module in "${modules[@]}"
do
if ! modprobe "$module"; then
echo "Failed to load $module module"
exit 1
fi
done

go test -v -race -cover ${PACKAGES} -coverprofile=coverage.out

0 comments on commit 58e1301

Please sign in to comment.