diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000..6c61239d5 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,290 @@ +name: CI +env: + POSTGRESQL_HOST: localhost + POSTGRESQL_PORT: 5432 + POSTGRESQL_USR: postgres + POSTGRESQL_PWD: root123 + POSTGRESQL_DATABASE: registry + DOCKER_COMPOSE_VERSION: 1.23.0 + HARBOR_ADMIN: admin + HARBOR_ADMIN_PASSWD: Harbor12345 + CORE_SECRET: tempString + KEY_PATH: "/data/secret/keys/secretkey" + REDIS_HOST: localhost + REG_VERSION: v2.7.1-patch-2819-2553 + UI_BUILDER_VERSION: 1.6.0 + +on: + pull_request: + push: + paths-ignore: + - 'docs/**' + +jobs: + UTTEST: + env: + UTTEST: true + runs-on: + #- self-hosted + - ubuntu-latest + timeout-minutes: 60 + steps: + - name: Set up Go 1.15 + uses: actions/setup-go@v1 + with: + go-version: 1.15.6 + id: go + - name: setup Docker + uses: docker-practice/actions-setup-docker@0.0.1 + with: + docker_version: 18.09 + docker_channel: stable + - uses: actions/checkout@v2 + with: + path: src/github.com/goharbor/harbor + - name: setup env + run: | + cd src/github.com/goharbor/harbor + pwd + go env + echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV + shell: bash + - name: before_install + run: | + set -x + cd src/github.com/goharbor/harbor + pwd + env + #sudo apt install -y xvfb + #xvfb-run ls + curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + chmod +x docker-compose + sudo mv docker-compose /usr/local/bin + IP=`hostname -I | awk '{print $1}'` + echo '{"insecure-registries" : ["'$IP':5000"]}' | sudo tee /etc/docker/daemon.json + echo "IP=$IP" >> $GITHUB_ENV + sudo cp ./tests/harbor_ca.crt /usr/local/share/ca-certificates/ + sudo update-ca-certificates + sudo service docker restart + - name: install + run: | + cd src/github.com/goharbor/harbor + env + df -h + bash ./tests/showtime.sh ./tests/ci/ut_install.sh + - name: script + run: | + echo IP: $IP + df -h + cd src/github.com/goharbor/harbor + bash ./tests/showtime.sh ./tests/ci/ut_run.sh $IP + df -h + - name: Codecov For BackEnd + uses: codecov/codecov-action@v1 + with: + file: ./src/github.com/goharbor/harbor/profile.cov + flags: unittests + + APITEST_DB: + env: + APITEST_DB: true + runs-on: + #- self-hosted + - ubuntu-latest + timeout-minutes: 60 + steps: + - name: Set up Go 1.15 + uses: actions/setup-go@v1 + with: + go-version: 1.15.6 + id: go + - name: setup Docker + uses: docker-practice/actions-setup-docker@0.0.1 + with: + docker_version: 18.09 + docker_channel: stable + - uses: actions/checkout@v2 + with: + path: src/github.com/goharbor/harbor + - name: setup env + run: | + cd src/github.com/goharbor/harbor + pwd + go env + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV + IP=`hostname -I | awk '{print $1}'` + echo "IP=$IP" >> $GITHUB_ENV + shell: bash + - name: before_install + run: | + set -x + cd src/github.com/goharbor/harbor + pwd + env + df -h + #sudo apt install -y xvfb + #xvfb-run ls + curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + chmod +x docker-compose + sudo mv docker-compose /usr/local/bin + - name: install + run: | + cd src/github.com/goharbor/harbor + env + df -h + docker system prune -a -f + bash ./tests/showtime.sh ./tests/ci/api_common_install.sh $IP DB + - name: script + run: | + cd src/github.com/goharbor/harbor + echo IP: $IP + df -h + bash ./tests/showtime.sh ./tests/ci/api_run.sh DB $IP + df -h + + APITEST_LDAP: + env: + APITEST_LDAP: true + runs-on: + #- self-hosted + - ubuntu-latest + timeout-minutes: 60 + steps: + - name: Set up Go 1.15 + uses: actions/setup-go@v1 + with: + go-version: 1.15.6 + id: go + - name: setup Docker + uses: docker-practice/actions-setup-docker@0.0.1 + with: + docker_version: 18.09 + docker_channel: stable + - uses: actions/checkout@v2 + with: + path: src/github.com/goharbor/harbor + - name: setup env + run: | + cd src/github.com/goharbor/harbor + pwd + go env + echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV + IP=`hostname -I | awk '{print $1}'` + echo "IP=$IP" >> $GITHUB_ENV + shell: bash + - name: before_install + run: | + set -x + cd src/github.com/goharbor/harbor + pwd + env + df -h + #sudo apt install -y xvfb + #xvfb-run ls + curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + chmod +x docker-compose + sudo mv docker-compose /usr/local/bin + - name: install + run: | + cd src/github.com/goharbor/harbor + env + df -h + bash ./tests/showtime.sh ./tests/ci/api_common_install.sh $IP LDAP + - name: script + run: | + echo IP: $IP + df -h + cd src/github.com/goharbor/harbor + bash ./tests/showtime.sh ./tests/ci/api_run.sh LDAP $IP + df -h + + OFFLINE: + env: + OFFLINE: true + runs-on: + #- self-hosted + - ubuntu-latest + timeout-minutes: 60 + steps: + - name: Set up Go 1.15 + uses: actions/setup-go@v1 + with: + go-version: 1.15.6 + id: go + - name: setup Docker + uses: docker-practice/actions-setup-docker@0.0.1 + with: + docker_version: 18.09 + docker_channel: stable + - uses: actions/checkout@v2 + with: + path: src/github.com/goharbor/harbor + - name: setup env + run: | + cd src/github.com/goharbor/harbor + pwd + docker version + go env + echo "GOPATH=$(go env GOPATH):$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + echo "TOKEN_PRIVATE_KEY_PATH=${GITHUB_WORKSPACE}/src/github.com/goharbor/harbor/tests/private_key.pem" >> $GITHUB_ENV + shell: bash + - name: before_install + run: | + set -x + cd src/github.com/goharbor/harbor + pwd + env + df -h + #sudo apt install -y xvfb + #xvfb-run ls + curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + chmod +x docker-compose + sudo mv docker-compose /usr/local/bin + IP=`hostname -I | awk '{print $1}'` + echo '{"insecure-registries" : ["'$IP':5000"]}' | sudo tee /etc/docker/daemon.json + echo "IP=$IP" >> $GITHUB_ENV + sudo cp ./tests/harbor_ca.crt /usr/local/share/ca-certificates/ + sudo update-ca-certificates + sudo service docker restart + - name: script + run: | + echo IP: $IP + df -h + cd src/github.com/goharbor/harbor + bash ./tests/showtime.sh ./tests/ci/distro_installer.sh + df -h + + UI_UT: + env: + UI_UT: true + runs-on: + #- self-hosted + - ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/setup-node@v1 + with: + node-version: '10.16.2' + - uses: actions/checkout@v2 + with: + path: src/github.com/goharbor/harbor + - name: script + run: | + echo IP: $IP + df -h + cd src/github.com/goharbor/harbor + bash ./tests/showtime.sh ./tests/ci/ui_ut_run.sh + df -h + - name: Codecov For UI + uses: codecov/codecov-action@v1 + with: + file: ./src/github.com/goharbor/harbor/src/portal/coverage/lcov.info + flags: unittests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3888aaf00..000000000 --- a/.travis.yml +++ /dev/null @@ -1,71 +0,0 @@ -sudo: true -language: go -go: -- 1.12.12 -go_import_path: github.com/goharbor/harbor -services: -- docker -dist: trusty -matrix: - include: - - go: 1.12.12 - env: - - UTTEST=true - - go: 1.12.12 - env: - - APITEST_DB=true - - go: 1.12.12 - env: - - APITEST_LDAP=true - - go: 1.12.12 - env: - - OFFLINE=true - - language: node_js - node_js: 10.16.2 - env: - - UI_UT=true -env: - global: - - POSTGRESQL_HOST: localhost - - POSTGRESQL_PORT: 5432 - - POSTGRESQL_USR: postgres - - POSTGRESQL_PWD: root123 - - POSTGRESQL_DATABASE: registry - - ADMINSERVER_URL: http://127.0.0.1:8888 - - DOCKER_COMPOSE_VERSION: 1.23.0 - - HARBOR_ADMIN: admin - - HARBOR_ADMIN_PASSWD: Harbor12345 - - CORE_SECRET: tempString - - KEY_PATH: "/data/secret/keys/secretkey" - - REDIS_HOST: localhost - - REG_VERSION: v2.7.1 - - UI_BUILDER_VERSION: 1.6.0 - - TOKEN_PRIVATE_KEY_PATH: "/home/travis/gopath/src/github.com/goharbor/harbor/tests/private_key.pem" -addons: -apt: - sources: - - google-chrome - packages: - - google-chrome-stable - - google-chrome-beta -before_install: -- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname - -s`-`uname -m` > docker-compose -- chmod +x docker-compose -- sudo mv docker-compose /usr/local/bin -- 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 -- export IP=$IP -- sudo service docker restart -install: -- if [ "$UTTEST" == true ]; then bash ./tests/travis/ut_install.sh ; fi -- if [ "$APITEST_DB" == true ]; then bash ./tests/travis/api_common_install.sh $IP - DB; fi -- if [ "$APITEST_LDAP" == true ]; then bash ./tests/travis/api_common_install.sh $IP - LDAP; fi -script: -- if [ "$UTTEST" == true ]; then bash ./tests/travis/ut_run.sh $IP; fi -- if [ "$APITEST_DB" == true ]; then bash ./tests/travis/api_run.sh DB $IP; fi -- if [ "$APITEST_LDAP" == true ]; then bash ./tests/travis/api_run.sh LDAP $IP; fi -- if [ "$OFFLINE" == true ]; then bash ./tests/travis/distro_installer.sh; fi -- if [ "$UI_UT" == true ]; then bash ./tests/travis/ui_ut_run.sh ; fi diff --git a/Makefile b/Makefile index 484109407..f97e07d70 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ # compile_golangimage: # compile from golang image # for example: make compile_golangimage -e GOBUILDIMAGE= \ -# golang:1.12.12 +# golang:1.15.6 # compile_core, compile_jobservice: compile specific binary # # build: build Harbor docker images from photon baseimage @@ -98,7 +98,7 @@ PREPARE_VERSION_NAME=versions #versions REGISTRYVERSION=v2.7.1-patch-2819-2553 NOTARYVERSION=v0.6.1 -CLAIRVERSION=v2.1.3 +CLAIRVERSION=v2.1.6 NOTARYMIGRATEVERSION=v3.5.4 CLAIRADAPTERVERSION=v1.0.1 @@ -135,7 +135,7 @@ GOINSTALL=$(GOCMD) install GOTEST=$(GOCMD) test GODEP=$(GOTEST) -i GOFMT=gofmt -w -GOBUILDIMAGE=golang:1.12.12 +GOBUILDIMAGE=golang:1.15.6 GOBUILDPATH=/harbor # go build diff --git a/docs/compile_guide.md b/docs/compile_guide.md index ab3832fe3..7df6e4372 100644 --- a/docs/compile_guide.md +++ b/docs/compile_guide.md @@ -43,25 +43,25 @@ You can compile the code by one of the three approaches: - Get official Golang image from docker hub: ```sh - $ docker pull golang:1.12.12 + $ docker pull golang:1.15.6 ``` - Build, install and bring up Harbor without Notary: ```sh - $ make install GOBUILDIMAGE=golang:1.12.12 COMPILETAG=compile_golangimage + $ make install GOBUILDIMAGE=golang:1.15.6 COMPILETAG=compile_golangimage ``` - Build, install and bring up Harbor with Notary: ```sh - $ make install GOBUILDIMAGE=golang:1.12.12 COMPILETAG=compile_golangimage NOTARYFLAG=true + $ make install GOBUILDIMAGE=golang:1.15.6 COMPILETAG=compile_golangimage NOTARYFLAG=true ``` - Build, install and bring up Harbor with Clair: ```sh - $ make install GOBUILDIMAGE=golang:1.12.12 COMPILETAG=compile_golangimage CLAIRFLAG=true + $ make install GOBUILDIMAGE=golang:1.15.6 COMPILETAG=compile_golangimage CLAIRFLAG=true ``` #### II. Compile code with your own Golang environment, then build Harbor diff --git a/docs/use_make.md b/docs/use_make.md index f6deb28e8..ed1cf94a3 100644 --- a/docs/use_make.md +++ b/docs/use_make.md @@ -36,10 +36,10 @@ version | set harbor version #### EXAMPLE: #### Build and run harbor from source code. -make install GOBUILDIMAGE=golang:1.12.12 COMPILETAG=compile_golangimage NOTARYFLAG=true +make install GOBUILDIMAGE=golang:1.15.6 COMPILETAG=compile_golangimage NOTARYFLAG=true ### Package offline installer -make package_offline GOBUILDIMAGE=golang:1.12.12 COMPILETAG=compile_golangimage NOTARYFLAG=true +make package_offline GOBUILDIMAGE=golang:1.15.6 COMPILETAG=compile_golangimage NOTARYFLAG=true ### Start harbor with notary make -e NOTARYFLAG=true start diff --git a/make/photon/clair-adapter/Dockerfile.binary b/make/photon/clair-adapter/Dockerfile.binary index a4c1f510b..63477c2f2 100644 --- a/make/photon/clair-adapter/Dockerfile.binary +++ b/make/photon/clair-adapter/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM golang:1.12.12 +FROM golang:1.15.6 ADD . /go/src/github.com/goharbor/harbor-scanner-clair/ WORKDIR /go/src/github.com/goharbor/harbor-scanner-clair/ diff --git a/make/photon/clair-adapter/builder b/make/photon/clair-adapter/builder index 50acd7c3b..ae6b07f25 100755 --- a/make/photon/clair-adapter/builder +++ b/make/photon/clair-adapter/builder @@ -23,7 +23,7 @@ TEMP=`mktemp -d ${TMPDIR-/tmp}/clair-adapter.XXXXXX` git clone https://github.com/goharbor/harbor-scanner-clair.git $TEMP cd $TEMP; git checkout $VERSION; cd - -echo 'build the clair adapter binary bases on the golang:1.12.12' +echo 'build the clair adapter binary bases on the golang:1.15.6' cp Dockerfile.binary $TEMP docker build -f $TEMP/Dockerfile.binary -t clair-adapter-golang $TEMP diff --git a/make/photon/clair/Dockerfile.binary b/make/photon/clair/Dockerfile.binary index 2a406229a..21e2571fb 100644 --- a/make/photon/clair/Dockerfile.binary +++ b/make/photon/clair/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM golang:1.12.12 +FROM golang:1.15.6 ADD . /go/src/github.com/quay/clair/ WORKDIR /go/src/github.com/quay/clair/ diff --git a/make/photon/clair/builder b/make/photon/clair/builder index c8dfeb3c7..01d6774fe 100755 --- a/make/photon/clair/builder +++ b/make/photon/clair/builder @@ -22,7 +22,7 @@ cur=$PWD TEMP=`mktemp -d /$TMPDIR/clair.XXXXXX` git clone -b $VERSION --single-branch https://github.com/quay/clair.git $TEMP -echo 'build the clair binary bases on the golang:1.12.12' +echo 'build the clair binary bases on the golang:1.15.6' cp Dockerfile.binary $TEMP docker build -f $TEMP/Dockerfile.binary -t clair-golang $TEMP diff --git a/make/photon/notary/binary.Dockerfile b/make/photon/notary/binary.Dockerfile index 7a4188fc1..ce991ebf5 100644 --- a/make/photon/notary/binary.Dockerfile +++ b/make/photon/notary/binary.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.12.12 +FROM golang:1.15.6 ARG NOTARY_VERSION ARG MIGRATE_VERSION diff --git a/make/photon/registry/Dockerfile.binary b/make/photon/registry/Dockerfile.binary index 5f6311cd8..e740df6d8 100644 --- a/make/photon/registry/Dockerfile.binary +++ b/make/photon/registry/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM golang:1.12.12 +FROM golang:1.15.6 ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution ENV BUILDTAGS include_oss include_gcs diff --git a/tests/apitests/python/test_robot_account.py b/tests/apitests/python/test_robot_account.py index c3f7fbedf..28695e9a7 100644 --- a/tests/apitests/python/test_robot_account.py +++ b/tests/apitests/python/test_robot_account.py @@ -117,10 +117,10 @@ class TestProjects(unittest.TestCase): self.project.disable_project_robot_account(TestProjects.project_ra_id_a, robot_id, True, **TestProjects.USER_RA_CLIENT) # "#13. Pull image(ImagePA) from project(PA) by robot account(RA), it must be not successful;" - pull_harbor_image(harbor_server, robot_account.name, robot_account.token, TestProjects.repo_name_in_project_a, tag_a, expected_login_error_message = "401 Client Error: Unauthorized") + pull_harbor_image(harbor_server, robot_account.name, robot_account.token, TestProjects.repo_name_in_project_a, tag_a, expected_login_error_message = "401 Client Error") # "#14. Push image(ImageRA) to project(PA) by robot account(RA), it must be not successful;" - push_image_to_project(project_ra_name_a, harbor_server, robot_account.name, robot_account.token, image_robot_account, tag, expected_login_error_message = "401 Client Error: Unauthorized") + push_image_to_project(project_ra_name_a, harbor_server, robot_account.name, robot_account.token, image_robot_account, tag, expected_login_error_message = "401 Client Error") # "#15. Delete robot account(RA), it must be not successful." self.project.delete_project_robot_account(TestProjects.project_ra_id_a, robot_id, **TestProjects.USER_RA_CLIENT) diff --git a/tests/travis/api_common_install.sh b/tests/ci/api_common_install.sh old mode 100644 new mode 100755 similarity index 73% rename from tests/travis/api_common_install.sh rename to tests/ci/api_common_install.sh index ada0a5540..dad983387 --- a/tests/travis/api_common_install.sh +++ b/tests/ci/api_common_install.sh @@ -3,6 +3,7 @@ set +e sudo rm -fr /data/* sudo mkdir -p /data +DIR="$(cd "$(dirname "$0")" && pwd)" set -e # prepare cert ... @@ -19,10 +20,10 @@ fi # prepare a chart file for API_DB test... -sudo curl -o /home/travis/gopath/src/github.com/goharbor/harbor/tests/apitests/python/mariadb-4.3.1.tgz https://storage.googleapis.com/harbor-builds/bin/charts/mariadb-4.3.1.tgz +sudo curl -o $DIR/../../tests/apitests/python/mariadb-4.3.1.tgz https://storage.googleapis.com/harbor-builds/bin/charts/mariadb-4.3.1.tgz sudo apt-get update && sudo apt-get install -y --no-install-recommends python-dev openjdk-7-jdk libssl-dev && sudo apt-get autoremove -y && sudo rm -rf /var/lib/apt/lists/* sudo wget https://bootstrap.pypa.io/get-pip.py && sudo python ./get-pip.py && sudo pip install --ignore-installed urllib3 chardet requests && sudo pip install robotframework==3.0.4 robotframework-httplibrary requests dbbot robotframework-pabot --upgrade sudo make swagger_client -sudo make install GOBUILDIMAGE=golang:1.12.12 COMPILETAG=compile_golangimage CLARITYIMAGE=goharbor/harbor-clarity-ui-builder:1.6.0 NOTARYFLAG=true CLAIRFLAG=true CHARTFLAG=true +sudo make install GOBUILDIMAGE=golang:1.15.6 COMPILETAG=compile_golangimage CLARITYIMAGE=goharbor/harbor-clarity-ui-builder:1.6.0 NOTARYFLAG=true CLAIRFLAG=true CHARTFLAG=true sleep 10 diff --git a/tests/travis/api_run.sh b/tests/ci/api_run.sh old mode 100644 new mode 100755 similarity index 75% rename from tests/travis/api_run.sh rename to tests/ci/api_run.sh index c6b34a760..753353fcc --- a/tests/travis/api_run.sh +++ b/tests/ci/api_run.sh @@ -6,8 +6,8 @@ sudo gsutil version -l harbor_logs_bucket="harbor-ci-logs" # GC credentials -#keyfile="/home/travis/harbor-ci-logs.key" -#botofile="/home/travis/.boto" +#keyfile="/home/ci/harbor-ci-logs.key" +#botofile="/home/ci/.boto" #echo -en $GS_PRIVATE_KEY > $keyfile #sudo chmod 400 $keyfile #echo "[Credentials]" >> $botofile @@ -16,6 +16,7 @@ harbor_logs_bucket="harbor-ci-logs" #echo "[GSUtil]" >> $botofile #echo "content_language = en" >> $botofile #echo "default_project_id = $GS_PROJECT_ID" >> $botofile +DIR="$(cd "$(dirname "$0")" && pwd)" # GS util function uploader { @@ -29,16 +30,16 @@ docker ps # run db auth api cases if [ "$1" = 'DB' ]; then - pybot -v ip:$2 -v HARBOR_PASSWORD:Harbor12345 /home/travis/gopath/src/github.com/goharbor/harbor/tests/robot-cases/Group0-BAT/API_DB.robot + pybot -v ip:$2 -v HARBOR_PASSWORD:Harbor12345 $DIR/../../tests/robot-cases/Group0-BAT/API_DB.robot elif [ "$1" = 'LDAP' ]; then # run ldap api cases - python /home/travis/gopath/src/github.com/goharbor/harbor/tests/configharbor.py -H $IP -u $HARBOR_ADMIN -p $HARBOR_ADMIN_PASSWD -c auth_mode=ldap_auth \ + python $DIR/../../tests/configharbor.py -H $IP -u $HARBOR_ADMIN -p $HARBOR_ADMIN_PASSWD -c auth_mode=ldap_auth \ ldap_url=ldap://$IP \ ldap_search_dn=cn=admin,dc=example,dc=com \ ldap_search_password=admin \ ldap_base_dn=dc=example,dc=com \ ldap_uid=cn - pybot -v ip:$2 -v HARBOR_PASSWORD:Harbor12345 /home/travis/gopath/src/github.com/goharbor/harbor/tests/robot-cases/Group0-BAT/API_LDAP.robot + pybot -v ip:$2 -v HARBOR_PASSWORD:Harbor12345 $DIR/../../tests/robot-cases/Group0-BAT/API_LDAP.robot else rc=999 fi diff --git a/tests/travis/distro_installer.sh b/tests/ci/distro_installer.sh similarity index 52% rename from tests/travis/distro_installer.sh rename to tests/ci/distro_installer.sh index c6baaf778..e8960aa70 100755 --- a/tests/travis/distro_installer.sh +++ b/tests/ci/distro_installer.sh @@ -2,5 +2,5 @@ set -e -sudo make package_online VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=golang:1.12.12 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true HTTPPROXY= -sudo make package_offline VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=golang:1.12.12 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true HTTPPROXY= +sudo make package_online VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=golang:1.15.6 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true HTTPPROXY= +sudo make package_offline VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=golang:1.15.6 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true HTTPPROXY= diff --git a/tests/travis/ui_ut_run.sh b/tests/ci/ui_ut_run.sh old mode 100644 new mode 100755 similarity index 82% rename from tests/travis/ui_ut_run.sh rename to tests/ci/ui_ut_run.sh index e44dd3f06..de9a66c7a --- a/tests/travis/ui_ut_run.sh +++ b/tests/ci/ui_ut_run.sh @@ -1,5 +1,5 @@ cd ./src/portal -npm install -g -q --no-progress angular-cli +npm install -g -q --no-progress @angular/cli npm install -g -q --no-progress karma npm install -q --no-progress npm run build_lib && npm run link_lib && cd ../.. diff --git a/tests/travis/ut_install.sh b/tests/ci/ut_install.sh old mode 100644 new mode 100755 similarity index 91% rename from tests/travis/ut_install.sh rename to tests/ci/ut_install.sh index 296f03ebd..67093945e --- a/tests/travis/ut_install.sh +++ b/tests/ci/ut_install.sh @@ -12,9 +12,10 @@ go get github.com/dghubble/sling go get golang.org/x/tools/cmd/cover go get github.com/mattn/goveralls go get -u github.com/client9/misspell/cmd/misspell -sudo service postgresql stop +sudo service postgresql stop || echo no postgresql need to be stopped sleep 2 +sudo rm -rf /data/* sudo -E env "PATH=$PATH" make go_check sudo ./tests/hostcfg.sh sudo ./tests/generateCerts.sh @@ -26,6 +27,8 @@ sudo mkdir -p /harbor && sudo mv ./VERSION /harbor/UIVERSION sudo ./tests/testprepare.sh cd tests && sudo ./ldapprepare.sh && sudo ./admiral.sh && cd .. +env +docker images 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 mkdir /storage && sudo chown 10000:10000 -R /storage diff --git a/tests/ci/ut_run.sh b/tests/ci/ut_run.sh new file mode 100755 index 000000000..583784edd --- /dev/null +++ b/tests/ci/ut_run.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -ex +export POSTGRESQL_HOST=$1 +export REGISTRY_URL=$1:5000 +export CHROME_BIN=chromium-browser +#export DISPLAY=:99.0 +#sh -e /etc/init.d/xvfb start + +sudo docker-compose -f ./make/docker-compose.test.yml up -d +sleep 10 +./tests/pushimage.sh +docker ps + +DIR="$(cd "$(dirname "$0")" && pwd)" +go test -race -i ./src/core ./src/jobservice +sudo -E env "PATH=$PATH" "POSTGRES_MIGRATION_SCRIPTS_PATH=$DIR/../../make/migrations/postgresql/" ./tests/coverage4gotest.sh +#goveralls -coverprofile=profile.cov -service=travis-ci || true \ No newline at end of file diff --git a/tests/coverage4gotest.sh b/tests/coverage4gotest.sh index f4c29ea25..e5feee238 100755 --- a/tests/coverage4gotest.sh +++ b/tests/coverage4gotest.sh @@ -27,7 +27,8 @@ do listDeps $package # echo "DEBUG: testing package $package" - go test -race -cover -coverprofile=profile.tmp -coverpkg "$deps" $package + echo go test -race -v -cover -coverprofile=profile.tmp -coverpkg "$deps" $package + go test -race -v -cover -coverprofile=profile.tmp -coverpkg "$deps" $package if [ -f profile.tmp ] then cat profile.tmp | tail -n +2 >> profile.cov diff --git a/tests/pushimage.sh b/tests/pushimage.sh index db409b275..1f5629a59 100755 --- a/tests/pushimage.sh +++ b/tests/pushimage.sh @@ -1,6 +1,6 @@ #!/bin/bash -IP=`ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'` +IP=$(hostname -I | awk '{print $1}') docker pull hello-world docker pull busybox docker login -u admin -p Harbor12345 $IP:5000 diff --git a/tests/showtime.sh b/tests/showtime.sh new file mode 100644 index 000000000..b77cf092e --- /dev/null +++ b/tests/showtime.sh @@ -0,0 +1,13 @@ +#/bin/env bash + +if [ ! -z "$*" ]; then + $@ 2>&1 | while read line;do + echo $(date +"%T") $line + done + exit ${PIPESTATUS[0]} +else + while read line;do + echo $(date +"%T") $line + done + echo ret $? +fi \ No newline at end of file diff --git a/tests/travis/ut_run.sh b/tests/travis/ut_run.sh deleted file mode 100755 index 90492d87f..000000000 --- a/tests/travis/ut_run.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -set -ex -export POSTGRESQL_HOST=$1 -export REGISTRY_URL=$1:5000 -export CHROME_BIN=chromium-browser -export DISPLAY=:99.0 -sh -e /etc/init.d/xvfb start - -sudo docker-compose -f ./make/docker-compose.test.yml up -d -sleep 10 -./tests/pushimage.sh -docker ps - -go test -race -i ./src/core ./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 -goveralls -coverprofile=profile.cov -service=travis-ci || true \ No newline at end of file