Skip to content

Commit

Permalink
Signed-off-by: fengzixu <[email protected]>
Browse files Browse the repository at this point in the history
refactor: unified development and test environment

1. refactor Makefile of Dragonfly.
2. use docker to build Dragonfly other than local environment.
3. update CONTRIBUTING.md with the developing environment info.
4. update the config of travis and circleci.
  • Loading branch information
fengzixu committed Dec 24, 2018
1 parent 01993c9 commit 78a2a1d
Show file tree
Hide file tree
Showing 18 changed files with 293 additions and 539 deletions.
15 changes: 9 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,29 @@ jobs:
name: detect deadcode without test folder
command: |
gometalinter --disable-all --skip vendor --skip test -E deadcode ./...
unit-test-golang:
docker:
- image: circleci/golang:1.10.4
working_directory: /go/src/github.com/dragonflyoss/Dragonfly
steps:
- checkout
- run:
name: build client
command: |
cd cmd
cd dfget && go build
cd ..
cd dfdaemon && go build
- run:
name: unit test
command: (cd ./build/client && ./configure && make unit-test)
command: make unit-test
- run:
name: upload code coverage report
command: bash <(curl -s https://codecov.io/bash)
- run:
name: rm coverage.txt
command: rm coverage.txt
- run:
name: build client
command: ./build/build.sh client


api-integration-test:
docker:
- image: circleci/golang:1.10.4
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ target
**/.DS_Store
*.swo
*.swp
.cache/
.go/
release/

#df-daemon

Expand Down
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ language: java
jdk:
- oraclejdk8
script:
- export LOG_HOME=/tmp/supernode && ./build/build.sh supernode
- ./hack/check-supernode.sh
- ./hack/compile-supernode.sh
- ./hack/build-supernode-image.sh
# - (cd ./build/client && ./configure && make unit-test) && export LOG_HOME=/tmp/supernode && ./build/build.sh

# after_success:
Expand Down
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Since you are ready to improve Dragonfly with a PR, we suggest you could take a
* [Branch Definition](#branch-definition)
* [Commit Rules](#commit-rules)
* [PR Description](#pr-description)
* [Developing Environment](#developing-environment)

### Workspace Preparation

Expand Down Expand Up @@ -139,6 +140,20 @@ No matter commit message, or commit content, we do take more emphasis on code re

PR is the only way to make change to Dragonfly project files. To help reviewers better get your purpose, PR description could not be too detailed. We encourage contributors to follow the [PR template](./.github/PULL_REQUEST_TEMPLATE.md) to finish the pull request.

### Developing Environment

As a contributor, if you want to make any contribution to Dragonfly project, we should reach an agreement on the version of tools used in the development environment.
Here are some dependents with specific version:

* golang : v1.10.4
* swagger : 0.17.1
* markdownlint : v0.5.0
* misspell : latest
* shellCheck : latest
* docker: latest

When you develop the Dragonfly project at the local environment, you should use subcommands of Makefile to help yourself to check and build the latest version of Dragonfly. For the convenience of developers, we use the docker to build Dragonfly. It can reduce problems of the developing environment.

## Engage to help anything

We choose GitHub as the primary place for Dragonfly to collaborate. So the latest updates of Dragonfly are always here. Although contributions via PR is an explicit way to help, we still call for any other ways.
Expand Down
107 changes: 107 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Copyright The Dragonfly Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PKG := github.com/dragonflyoss/Dragonfly
SUPERNODE_SOURCE_HOME="${curDir}/../../src/supernode"
BUILD_IMAGE ?= golang:1.10.4
GOARCH := $(shell go env GOARCH)
GOOS := $(shell go env GOOS)
BUILD := $(shell git rev-parse HEAD)
BUILD_PATH := release/${GOOS}_${GOARCH}

LDFLAGS_DFGET = -ldflags "-X ${PKG}/cmd/dfget/app.Build=${BUILD}"
LDFLAGS_DFDAEMON = -ldflags "-X ${PKG}/cmd/dfdaemon/app.Build=${BUILD}"

ifeq ($(GOOS),darwin)
BUILD_PATH := release
endif

clean:
@echo "Begin to clean redundant files."
@rm -rf ./release
.PHONY: clean

check-client:
@echo "Begin to check client code formats."
./hack/check-client.sh
.PHONY: check

check-supernode:
@echo "Begin to check supernode code formats."
./hack/check-supernode.sh

build-dirs:
@mkdir -p .go/src/$(PKG) .go/bin .cache
@mkdir -p $(BUILD_PATH)
.PHONY: build-dirs

build-dfget: build-dirs
@echo "Begin to build dfget."
@docker run \
--rm \
-ti \
-u $$(id -u):$$(id -g) \
-v $$(pwd)/.go:/go \
-v $$(pwd):/go/src/$(PKG) \
-v $$(pwd)/$(BUILD_PATH):/go/bin \
-v $$(pwd)/.cache:/.cache \
-e GOOS=$(GOOS) \
-e GOARCH=$(GOARCH) \
-e CGO_ENABLED=0 \
-w /go/src/$(PKG) \
$(BUILD_IMAGE) \
go install -v -pkgdir /go/pkg $(LDFLAGS_DFGET) ./cmd/dfget
.PHONY: build-dfget

build-dfdaemon: build-dirs
@echo "Begin to build dfdaemon."
@docker run \
--rm \
-ti \
-u $$(id -u):$$(id -g) \
-v $$(pwd)/.go:/go \
-v $$(pwd):/go/src/$(PKG) \
-v $$(pwd)/$(BUILD_PATH):/go/bin \
-v $$(pwd)/.cache:/.cache \
-e GOOS=$(GOOS) \
-e GOARCH=$(GOARCH) \
-e CGO_ENABLED=0 \
-w /go/src/$(PKG) \
$(BUILD_IMAGE) \
go install -v -pkgdir /go/pkg $(LDFLAGS_DFDAEMON) ./cmd/dfdaemon
.PHONY: build-dfdaemon

build-supernode:
./hack/compile-supernode.sh
./hack/build-supernode-image.sh
.PHONY: build-supernode

unit-test: build-dirs
./hack/unit-test.sh
.PHONY: unit-test

install:
@echo "Begin to install dfget and dfdaemon."
./hack/install-client.sh install
.PHONY: install

uninstall:
@echo "Begin to uninstall dfget and dfdaemon."
./hack/install-client.sh uninstall
.PHONY: uninstall

build-client: check-client build-dfget build-dfdaemon
.PHONY: build-client

build: check-client build-dfget build-dfdaemon check-supernode build-supernode
88 changes: 0 additions & 88 deletions build/build.sh

This file was deleted.

64 changes: 0 additions & 64 deletions build/client/Makefile

This file was deleted.

Loading

0 comments on commit 78a2a1d

Please sign in to comment.