Merge pull request #5753 from wy65701436/clean-up-travis

Revise and cleanup travis script, and misspell/gofmt to makefile
This commit is contained in:
Daniel Jiang 2018-08-29 17:06:06 +08:00 committed by GitHub
commit ee7dfaf4e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 57 deletions

View File

@ -21,89 +21,59 @@ env:
ADMINSERVER_URL: http://127.0.0.1:8888 ADMINSERVER_URL: http://127.0.0.1:8888
DOCKER_COMPOSE_VERSION: 1.7.1 DOCKER_COMPOSE_VERSION: 1.7.1
HARBOR_ADMIN: admin HARBOR_ADMIN: admin
HARBOR_ADMIN_PASSWD: Harbor12345 HARBOR_ADMIN_PASSWD: Harbor12345
UI_SECRET: tempString UI_SECRET: tempString
MAX_JOB_WORKERS: 3
AUTH_MODE: db_auth
SELF_REGISTRATION: on
KEY_PATH: /data/secretkey KEY_PATH: /data/secretkey
REDIS_HOST: localhost REDIS_HOST: localhost
REG_VERSION: v2.6.2
UI_BUILDER_VERSION: 1.6.0
before_install: before_install:
- sudo ./tests/hostcfg.sh - sudo ./tests/hostcfg.sh
- sudo ./tests/generateCerts.sh - sudo ./tests/generateCerts.sh
- sudo ./make/prepare - sudo ./make/prepare
- sudo mkdir -p "/data/redis" - sudo mkdir -p "/data/redis"
- sudo mkdir -p /etc/ui/ca/ && sudo mv ./tests/ca.crt /etc/ui/ca/
- sudo mkdir -p /harbor && sudo mv ./VERSION /harbor/UIVERSION
- sudo ./tests/testprepare.sh
install: install:
- sudo apt-get update && sudo apt-get install -y libldap2-dev - sudo apt-get update && sudo apt-get install -y libldap2-dev
- sudo apt-get install -y sqlite3
# - sudo apt-get remove -y mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5
# - sudo apt-get autoremove -y
# - sudo apt-get install -y libaio1
# - wget -O mysql-5.6.14.deb http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14-debian6.0-x86_64.deb/from/http://cdn.mysql.com/
# - sudo dpkg -i mysql-5.6.14.deb
# - sudo cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/mysql.server
# - sudo ln -s /opt/mysql/server-5.6/bin/* /usr/bin/
# - sudo sed -i'' 's/table_cache/table_open_cache/' /etc/mysql/my.cnf
# - sudo sed -i'' 's/log_slow_queries/slow_query_log/' /etc/mysql/my.cnf
# - sudo sed -i'' 's/basedir[^=]\+=.*$/basedir = \/opt\/mysql\/server-5.6/' /etc/mysql/my.cnf
# - sudo /etc/init.d/mysql.server start
# - mysql --version
- go get -d github.com/docker/distribution - go get -d github.com/docker/distribution
- go get -d github.com/docker/libtrust - go get -d github.com/docker/libtrust
- go get -d github.com/lib/pq - go get -d github.com/lib/pq
- go get github.com/golang/lint/golint - go get github.com/golang/lint/golint
- go get github.com/GeertJohan/fgt - go get github.com/GeertJohan/fgt
- go get github.com/dghubble/sling
# - sudo rm /usr/local/bin/docker-compose - go get github.com/stretchr/testify
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
- go get -u github.com/client9/misspell/cmd/misspell
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose - chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin - sudo mv docker-compose /usr/local/bin
- IP=`ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'` - IP=`ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'`
- sudo sed -i '$a DOCKER_OPTS=\"--insecure-registry '$IP':5000\"' /etc/default/docker - sudo sed -i '$a DOCKER_OPTS=\"--insecure-registry '$IP':5000\"' /etc/default/docker
- sudo service docker restart - sudo service docker restart
- go get github.com/dghubble/sling
- go get github.com/stretchr/testify
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
before_script:
# create tables and load data
# - mysql < ./make/db/registry.sql -uroot --verbose
# - sudo chmod 777 /tmp/registry.db
script:
- sudo mkdir -p /etc/ui/ca/
- sudo mv ./tests/ca.crt /etc/ui/ca/
- sudo mkdir -p /harbor
- sudo mv ./VERSION /harbor/UIVERSION
- sudo service postgresql stop - sudo service postgresql stop
- sudo make run_clarity_ut CLARITYIMAGE=goharbor/harbor-clarity-ui-builder:1.6.0
- cat ./src/ui_ng/npm-ut-test-results before_script:
- sudo ./tests/testprepare.sh
- sudo make -f make/photon/Makefile _build_db _build_registry -e VERSIONTAG=dev -e CLAIRDBVERSION=dev -e REGISTRYVERSION=v2.6.2
- sudo sed -i 's/__reg_version__/v2.6.2-dev/g' ./make/docker-compose.test.yml
- sudo sed -i 's/__version__/dev/g' ./make/docker-compose.test.yml
- sudo mkdir -p ./make/common/config/registry/
- sudo mv ./tests/reg_config.yml ./make/common/config/registry/config.yml
- sudo docker-compose -f ./make/docker-compose.test.yml up -d
- go list ./... | grep -v -E 'vendor|tests|test' | xargs -L1 fgt golint
- go list ./... | grep -v -E 'vendor|tests|test' | xargs -L1 go vet
- export POSTGRESQL_HOST=$IP - export POSTGRESQL_HOST=$IP
- export REGISTRY_URL=$IP:5000 - export REGISTRY_URL=$IP:5000
- echo $REGISTRY_URL - echo $REGISTRY_URL
- cd tests && sudo ./ldapprepare.sh && cd ..
- sudo ./tests/admiral.sh
- sudo make -f make/photon/Makefile _build_db _build_registry -e VERSIONTAG=dev -e CLAIRDBVERSION=dev -e REGISTRYVERSION=${REG_VERSION}
- sudo sed -i 's/__reg_version__/${REG_VERSION}-dev/g' ./make/docker-compose.test.yml
- sudo sed -i 's/__version__/dev/g' ./make/docker-compose.test.yml
- sudo mkdir -p ./make/common/config/registry/ && sudo mv ./tests/reg_config.yml ./make/common/config/registry/config.yml
script:
- sudo make run_clarity_ut CLARITYIMAGE=goharbor/harbor-clarity-ui-builder:${UI_BUILDER_VERSION}
- cat ./src/ui_ng/npm-ut-test-results
- sudo docker-compose -f ./make/docker-compose.test.yml up -d
- make go_check
- ./tests/pushimage.sh - ./tests/pushimage.sh
- cd tests
- sudo ./ldapprepare.sh
- sudo ./admiral.sh
- cd ..
- go test -race -i ./src/ui ./src/adminserver ./src/jobservice - go test -race -i ./src/ui ./src/adminserver ./src/jobservice
- sudo -E env "PATH=$PATH" "POSTGRES_MIGRATION_SCRIPTS_PATH=/home/travis/gopath/src/github.com/goharbor/harbor/make/migrations/postgresql/" ./tests/coverage4gotest.sh - sudo -E env "PATH=$PATH" "POSTGRES_MIGRATION_SCRIPTS_PATH=/home/travis/gopath/src/github.com/goharbor/harbor/make/migrations/postgresql/" ./tests/coverage4gotest.sh
- goveralls -coverprofile=profile.cov -service=travis-ci - goveralls -coverprofile=profile.cov -service=travis-ci
- docker-compose -f make/docker-compose.test.yml down
- ls /data/cert
- ./tests/swaggerchecker.sh
# - sudo ./tests/testprepare.sh
# - go test -v ./tests/apitests

View File

@ -414,6 +414,29 @@ gosec:
$(GOPATH)/bin/gosec -fmt=json -out=harbor_gas_output.json -quiet ./... | true ; \ $(GOPATH)/bin/gosec -fmt=json -out=harbor_gas_output.json -quiet ./... | true ; \
fi fi
go_check: misspell golint govet gofmt
gofmt:
@echo checking gofmt...
@res=$$(gofmt -d -e -s $$(find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print)); \
if [ -n "$${res}" ]; then \
echo checking gofmt fail... ; \
echo "$${res}"; \
exit 1; \
fi
misspell:
@echo checking misspell...
@find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print | xargs misspell -error
golint:
@echo checking golint...
@go list ./... | grep -v -E 'vendor|test' | xargs -L1 fgt golint
govet:
@echo checking govet...
@go list ./... | grep -v -E 'vendor|test' | xargs -L1 go vet
pushimage: pushimage:
@echo "pushing harbor images ..." @echo "pushing harbor images ..."
@$(DOCKERTAG) $(DOCKERIMAGENAME_ADMINSERVER):$(VERSIONTAG) $(REGISTRYSERVER)$(DOCKERIMAGENAME_ADMINSERVER):$(VERSIONTAG) @$(DOCKERTAG) $(DOCKERIMAGENAME_ADMINSERVER):$(VERSIONTAG) $(REGISTRYSERVER)$(DOCKERIMAGENAME_ADMINSERVER):$(VERSIONTAG)