add conformance test to CI

1, add a specrate git action for conformance test
2, use the OCI testing code to test Harbor master code on push

Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
wang yan 2020-04-29 11:42:23 +08:00
parent 198632b581
commit d9773248e2
3 changed files with 100 additions and 2 deletions

75
.github/workflows/conformance_test.yml vendored Normal file
View File

@ -0,0 +1,75 @@
name: CONFORMANCE_TEST
env:
DOCKER_COMPOSE_VERSION: 1.23.0
on:
repository_dispatch:
types:
- manual-trigger-conformance
schedule:
- cron: '0 6 * * *'
jobs:
CONFORMANCE_TEST:
env:
CONFORMANCE_TEST: true
runs-on:
#- self-hosted
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '285.0.0'
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- run: gcloud info
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13.8
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: before_install
run: |
set -x
cd src/github.com/goharbor/harbor
pwd
env
df -h
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 "::set-env name=IP::$IP"
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/api_common_install.sh $IP DB
- name: script
run: |
echo IP: $IP
df -h
cd src/github.com/goharbor/harbor
bash ./tests/showtime.sh ./tests/ci/conformance_test.sh $IP
df -h
- name: upload test result to gs
run: |
gsutil cp report.html gs://harbor-conformance-test/report.html
gsutil acl ch -u AllUsers:R gs://harbor-conformance-test/report.html
if: always()

View File

@ -1,12 +1,12 @@
# Harbor
[![CI](https://github.com/goharbor/harbor/workflows/CI/badge.svg?branch=master&event=push)](https:///github.com/goharbor/harbor/actions?query=event%3Apush+branch%3Amaster+workflow%3ACI+)
[![CI](https://github.com/goharbor/harbor/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/goharbor/harbor/actions?query=event%3Apush+branch%3Amaster+workflow%3ACI+)
[![Coverage Status](https://codecov.io/gh/goharbor/harbor/branch/master/graph/badge.svg)](https://codecov.io/gh/goharbor/harbor)
[![Go Report Card](https://goreportcard.com/badge/github.com/goharbor/harbor)](https://goreportcard.com/report/github.com/goharbor/harbor)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/2095/badge)](https://bestpractices.coreinfrastructure.org/projects/2095)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c8d726c9cfd047ffaf681449d673f246)](https://www.codacy.com/app/goharbor/harbor?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=goharbor/harbor&amp;utm_campaign=Badge_Grade)
[![Nightly Status](https://us-central1-eminent-nation-87317.cloudfunctions.net/harbor-nightly-result)](https://www.googleapis.com/storage/v1/b/harbor-nightly/o)
[![Conformance Status](https://github.com/goharbor/harbor/workflows/conformance_test/badge.svg)](https://github.com/goharbor/harbor/actions?query=workflow%3Aconformance_test)
</br>
|![notification](docs/img/bell-outline-badged.svg)Community Meeting|

23
tests/ci/conformance_test.sh Executable file
View File

@ -0,0 +1,23 @@
set -e
echo "get the conformance testing code..."
git clone https://github.com/opencontainers/distribution-spec.git
echo "create testing project"
STATUS=$(curl -w '%{http_code}' -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST -u "admin:Harbor12345" -s --insecure "https://$IP/api/v2.0/projects" --data '{"project_name":"conformance","metadata":{"public":"false"},"storage_limit":-1}')
if [ $STATUS -ne 201 ]; then
exit 1
fi
echo "run conformance test..."
export OCI_ROOT_URL="https://$1"
export OCI_NAMESPACE="conformance/testrepo"
export OCI_USERNAME="admin"
export OCI_PASSWORD="Harbor12345"
export OCI_DEBUG="true"
## will add more test, so far only cover pull & push
export OCI_TEST_PUSH=1
export OCI_TEST_PULL=1
cd ./distribution-spec/conformance
go test .