Skip to content

Commit

Permalink
Misc: adjust makefile for nydusify ut testing
Browse files Browse the repository at this point in the history
Unit test failed in `contrib/nydusify/pkg/nydusify` with error:

```
Received unexpected error:
  lchown /tmp/nydus-converter-021891868/source/dir-1: operation not permitted
  apply with convert whiteout
```

Add sudo prefix for go test command and pass `NYDUS_BUILDER` and
`NYDUS_NYDUSD` env as UT required.

Signed-off-by: Yan Song <[email protected]>
  • Loading branch information
imeoer committed Mar 25, 2022
1 parent c01190c commit 90799d1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/contrib/nydusify/go.sum', '**/contrib/ctr-remote/go.sum', '**/contrib/docker-nydus-graphdriver/go.sum', '**/contrib/nydus-overlayfs/go.sum') }}
restore-keys: |
${{ runner.os }}-go
- name: Cache Nydus
uses: Swatinem/rust-cache@v1
with:
key: ${{ runner.os }}
target-dir: ./target-fusedev
cache-on-failure: true
- name: test contrib UT
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0
Expand All @@ -44,6 +50,7 @@ jobs:
- name: Cache Nydus
uses: Swatinem/rust-cache@v1
with:
key: ${{ runner.os }}
target-dir: ./target-fusedev
cache-on-failure: true
- name: Cache Docker Layers
Expand Down
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ VIRIOFS_COMMON = --target-dir target-virtiofs --features=virtiofs --release
define build_golang
echo "Building target $@ by invoking: $(2)"
if [ $(DOCKER) = "true" ]; then
docker run --rm -v ${go_path}:/go -v ${current_dir}:/nydus-rs --workdir /nydus-rs/$(1) golang:1.17 $(2)
docker run --rm -v ${go_path}:/go -v ${current_dir}:/nydus-rs -e WORKDIR=/nydus-rs --workdir /nydus-rs/$(1) golang:1.17 $(2)
else
export WORKDIR=${current_dir}
$(2) -C $(1)
fi
endef
Expand All @@ -49,18 +50,22 @@ endef
.release_version:
$(eval CARGO_BUILD_FLAGS += --release)

.rust_component:
rustup component add rustfmt
rustup component add clippy

.format:
cargo fmt -- --check

.musl_target:
$(eval CARGO_BUILD_FLAGS += --target ${ARCH}-unknown-linux-musl)

# Targets that are exposed to developers and users.
build: .format fusedev virtiofs
release: .format .release_version fusedev virtiofs
static-release: .musl_target .format .release_version fusedev virtiofs
fusedev-release: .format .release_version fusedev
virtiofs-release: .format .release_version virtiofs
build: .rust_component .format fusedev virtiofs
release: .rust_component .format .release_version fusedev virtiofs
static-release: .rust_component .musl_target .format .release_version fusedev virtiofs
fusedev-release: .rust_component .format .release_version fusedev
virtiofs-release: .rust_component .format .release_version virtiofs

virtiofs:
# TODO: switch to --out-dir when it moves to stable
Expand Down Expand Up @@ -137,7 +142,7 @@ docker-smoke: docker-nydus-smoke docker-nydusify-smoke
nydusify:
$(call build_golang,${NYDUSIFY_PATH},make)

nydusify-test:
nydusify-test: fusedev-release
$(call build_golang,${NYDUSIFY_PATH},make test)

nydusify-static:
Expand Down
7 changes: 6 additions & 1 deletion contrib/nydusify/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ GIT_COMMIT := $(shell git rev-list -1 HEAD)
BUILD_TIME := $(shell date -u +%Y%m%d.%H%M)
CURRENT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
SUDO = $(shell which sudo)
GO_EXECUTABLE_PATH ?= $(shell which go)
NYDUS_BUILDER ?= ${WORKDIR}/target-fusedev/release/nydus-image
NYDUS_NYDUSD ?= ${WORKDIR}/target-fusedev/release/nydusd
#GOPROXY ?= https://goproxy.io

ifdef GOPROXY
Expand All @@ -20,7 +24,8 @@ static-release:
test: build build-smoke
@go vet $(PACKAGES)
golangci-lint run
@go test -count=1 -v -timeout 20m -race ./pkg/...
echo $(WORKDIR)
@$(SUDO) NYDUS_BUILDER=${NYDUS_BUILDER} NYDUS_NYDUSD=${NYDUS_NYDUSD} ${GO_EXECUTABLE_PATH} test -count=1 -v -timeout 20m -race ./pkg/...

build-smoke:
${PROXY} GOOS=linux go test -race -v -c -o ./nydusify-smoke ./tests

0 comments on commit 90799d1

Please sign in to comment.