From c566e5c9e386ad0d2b7605189374c71c6903030a Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Mon, 29 Apr 2024 15:04:32 +0800 Subject: [PATCH] ci: change to use GitHub actions Signed-off-by: PoAn Yang --- .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ Dockerfile.dapper | 6 +++--- scripts/test | 2 +- 3 files changed, 30 insertions(+), 4 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 0000000..83a57b5 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 }} diff --git a/Dockerfile.dapper b/Dockerfile.dapper index f2c7c68..6c68227 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -9,7 +9,7 @@ ENV HOST_ARCH=${DAPPER_HOST_ARCH} ARCH=${DAPPER_HOST_ARCH} 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 +ENV DAPPER_OUTPUT bin coverage.out ENV DAPPER_RUN_ARGS --privileged -v /dev:/host/dev -v /proc:/host/proc ENV DAPPER_SOURCE /go/src/github.com/longhorn/go-iscsi-helper WORKDIR ${DAPPER_SOURCE} @@ -41,8 +41,8 @@ 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 diff --git a/scripts/test b/scripts/test index 291d4b2..0e2a16e 100755 --- a/scripts/test +++ b/scripts/test @@ -7,4 +7,4 @@ 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} +go test -v -race -cover ${PACKAGES} -coverprofile=coverage.out