From 6aae3ecc91e122fcf2ddeafdd907d3eda2b37428 Mon Sep 17 00:00:00 2001 From: Tong Li Date: Fri, 1 May 2020 01:14:53 +0000 Subject: [PATCH] Move onto Azure DevOps Currently we build images on Docker Hub and test on Azure DevOps, we need to move everything over to Azure DevOps environment and make sure we take advantages of the parallel build to speed up the entire process. Signed-off-by: Tong Li --- azure-pipelines.yml | 44 ++++++++++++++++--- .../docker/agent/ansible/Dockerfile.in | 4 +- .../docker/common/dashboard/Dockerfile.in | 8 ++-- ci/check-license-and-docs.yml | 10 +++++ ci/dashandapi_post.yml | 12 +++++ ci/{check.yml => dashandapi_pre.yml} | 5 ++- ci/process-components.yml | 23 ++++++++++ 7 files changed, 90 insertions(+), 16 deletions(-) mode change 100755 => 100644 build_image/docker/agent/ansible/Dockerfile.in create mode 100644 ci/check-license-and-docs.yml create mode 100644 ci/dashandapi_post.yml rename ci/{check.yml => dashandapi_pre.yml} (75%) create mode 100644 ci/process-components.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4a4b486ed..8c09efcbb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -6,11 +6,41 @@ trigger: - master -jobs: - - job: check - displayName: Check code - pool: - vmImage: ubuntu-latest +pool: + vmImage: 'ubuntu-18.04' + +variables: + - group: credentials + +stages: +- stage: PreCheck + displayName: Check license and documents + jobs: + - job: CheckLicenseAndDocs steps: - - template: ci/check.yml - condition: and(always(), eq(variables['Build.Reason'], 'PullRequest')) + - template: ci/check-license-and-docs.yml + +- stage: ProcessComponents + displayName: ProcessComponents + jobs: + - template: ci/process-components.yml + parameters: + param: + - name: dashandapi + pretest: "dashandapi_pre.yml" + posttest: "dashandapi_post.yml" + images: + - imagename: "hyperledger/cello-api-engine" + dockerfile: "build_image/docker/common/api-engine/Dockerfile.in" + - imagename: "hyperledger/cello-nginx" + dockerfile: "build_image/docker/common/nginx/Dockerfile.in" + - imagename: "hyperledger/cello-dashboard" + dockerfile: "build_image/docker/common/dashboard/Dockerfile.in" + - name: ansibleagent + images: + - imagename: "hyperledger/cello-ansible-agent" + dockerfile: "build_image/docker/agent/ansible/Dockerfile.in" + - name: fabricoperator + images: + - imagename: "hyperledger/cello-fabric-operator" + dockerfile: "build_image/docker/agent/fabric-operator/Dockerfile.in" diff --git a/build_image/docker/agent/ansible/Dockerfile.in b/build_image/docker/agent/ansible/Dockerfile.in old mode 100755 new mode 100644 index 0ef35c8b3..dc55a7e15 --- a/build_image/docker/agent/ansible/Dockerfile.in +++ b/build_image/docker/agent/ansible/Dockerfile.in @@ -2,8 +2,8 @@ # # @see https://github.com/hyperledger/cello/blob/master/docs/worker_ansible_howto.md # -FROM _DOCKER_BASE_ -MAINTAINER Tong Li +FROM python:3.6 +MAINTAINER Hyperledger Cello Team ARG user=ubuntu ARG uid=1000 diff --git a/build_image/docker/common/dashboard/Dockerfile.in b/build_image/docker/common/dashboard/Dockerfile.in index aacbd1157..7e7ec5a01 100644 --- a/build_image/docker/common/dashboard/Dockerfile.in +++ b/build_image/docker/common/dashboard/Dockerfile.in @@ -2,13 +2,11 @@ FROM circleci/node:latest-browsers WORKDIR /usr/src/app/ USER root -COPY src/dashboard/package.json ./ -RUN yarn -COPY src/dashboard ./ -RUN npm run build +RUN mkdir -p /usr/src/app && cd /usr/src/app +COPY src/dashboard /usr/src/app +RUN yarn --network-timeout 600000 && yarn run build FROM nginx:1.15.12 - COPY --from=0 /usr/src/app/dist /usr/share/nginx/html COPY build_image/docker/common/dashboard/config-nginx.sh / RUN chmod +x /config-nginx.sh diff --git a/ci/check-license-and-docs.yml b/ci/check-license-and-docs.yml new file mode 100644 index 000000000..d386ba175 --- /dev/null +++ b/ci/check-license-and-docs.yml @@ -0,0 +1,10 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# + +steps: + - script: | + set -eu -o pipefail + make license + find ./docs -type f -name "*.md" -exec egrep -l " +$$" {} \; + displayName: 'License and document checks' diff --git a/ci/dashandapi_post.yml b/ci/dashandapi_post.yml new file mode 100644 index 000000000..5ad1a0cf2 --- /dev/null +++ b/ci/dashandapi_post.yml @@ -0,0 +1,12 @@ +# +# SPDX-License-Identifier: Apache-2.0 +# + +steps: +- script: | + MODE=dev make start + sleep 10 + make test-api + MODE=dev make stop + make check-dashboard + displayName: 'Run API and Dashboard tests' diff --git a/ci/check.yml b/ci/dashandapi_pre.yml similarity index 75% rename from ci/check.yml rename to ci/dashandapi_pre.yml index 08fcd4354..bcd0cf529 100644 --- a/ci/check.yml +++ b/ci/dashandapi_pre.yml @@ -8,5 +8,6 @@ steps: sudo pip install --upgrade pip sudo pip install wheel sudo pip install tox - make check - displayName: 'make check' + cd src/api-engine + tox + displayName: 'Run tox' diff --git a/ci/process-components.yml b/ci/process-components.yml new file mode 100644 index 000000000..98bb41526 --- /dev/null +++ b/ci/process-components.yml @@ -0,0 +1,23 @@ +parameters: + param: [] + +jobs: +- ${{ each component in parameters.param }}: + - job: ${{ component.name }} + steps: + - ${{ if component.pretest }}: + - template: ${{ component.pretest }} + - ${{ each image in component.images }}: + - script: | + docker build -t ${{ image.imagename }} -f ${{ image.dockerfile }} . + displayName: Build ${{ image.imagename }} docker image + - script: docker images + displayName: 'List available images' + - ${{ if component.posttest }}: + - template: ${{ component.posttest }} + - ${{ each image in component.images }}: + - script: | + docker login --username $(DockerHub-Username) --password $(DockerHub-Password) + docker push ${{ image.imagename }} + displayName: Publish docker image ${{ image.imagename }} + condition: eq(variables['Build.Reason'], 'IndividualCI')