From a4398b0a81e387d343b0cd29ea40cf48eb04bb94 Mon Sep 17 00:00:00 2001 From: Ying Chun Guo Date: Fri, 23 Aug 2024 16:33:46 +0800 Subject: [PATCH] improve cd workflows and add release document (#347) * add release document Signed-off-by: Yingchun Guo * improve cd workflows, add cd document Signed-off-by: Yingchun Guo --------- Signed-off-by: Yingchun Guo --- .github/workflows/_gmc-image-build.yaml | 15 ++++ .github/workflows/_helm-e2e.yaml | 6 +- .github/workflows/_infra-workflow.yaml | 66 +---------------- .github/workflows/manual-gmc-cd-workflow.yaml | 22 +----- .../workflows/manual-helm-cd-workflow.yaml | 11 +-- RELEASE_BRANCHES.md | 72 +++++++++++++++++++ 6 files changed, 94 insertions(+), 98 deletions(-) create mode 100644 RELEASE_BRANCHES.md diff --git a/.github/workflows/_gmc-image-build.yaml b/.github/workflows/_gmc-image-build.yaml index 65daad83..f41c296b 100644 --- a/.github/workflows/_gmc-image-build.yaml +++ b/.github/workflows/_gmc-image-build.yaml @@ -33,9 +33,24 @@ jobs: image_repo: ${{ steps.set_variables.outputs.IMAGE_REPO }} version: ${{ steps.set_variables.outputs.VERSION }} steps: + - name: Clean Up Working Directory + run: sudo rm -rf ${{github.workspace}}/* + + - name: Get checkout ref + id: get-checkout-ref + run: | + if [ "${{ github.event_name }}" == "pull_request" ] || [ "${{ github.event_name }}" == "pull_request_target" ]; then + CHECKOUT_REF=refs/pull/${{ github.event.number }}/merge + else + CHECKOUT_REF=${{ github.ref }} + fi + echo "CHECKOUT_REF=${CHECKOUT_REF}" >> $GITHUB_OUTPUT + echo "checkout ref ${CHECKOUT_REF}" + - name: Checkout out Repo uses: actions/checkout@v4 with: + ref: ${{ steps.get-checkout-ref.outputs.CHECKOUT_REF }} fetch-depth: 0 - name: Set variables diff --git a/.github/workflows/_helm-e2e.yaml b/.github/workflows/_helm-e2e.yaml index 4e7f5d90..183d8148 100644 --- a/.github/workflows/_helm-e2e.yaml +++ b/.github/workflows/_helm-e2e.yaml @@ -15,10 +15,6 @@ on: default: "latest" required: false type: string - opea_branch: - default: "main" - required: false - type: string hardware: default: "xeon" required: true @@ -100,7 +96,6 @@ jobs: run: | set -xe echo "should_cleanup=true" >> $GITHUB_ENV - helm-charts/update_dependency.sh && helm dependency update ${{ env.CHART_FOLDER }} value_file="values.yaml" if [ "${{ inputs.hardware }}" == "gaudi" ]; then value_file="gaudi-values.yaml" @@ -111,6 +106,7 @@ jobs: echo "should_cleanup=false" >> $GITHUB_ENV exit 0 fi + helm-charts/update_dependency.sh && helm dependency update ${{ env.CHART_FOLDER }} if ! helm install --create-namespace --namespace $NAMESPACE --wait \ --timeout "$ROLLOUT_TIMEOUT_SECONDS" \ --set autodependency.enabled=true \ diff --git a/.github/workflows/_infra-workflow.yaml b/.github/workflows/_infra-workflow.yaml index 46f3d80a..1d72b81b 100644 --- a/.github/workflows/_infra-workflow.yaml +++ b/.github/workflows/_infra-workflow.yaml @@ -14,22 +14,11 @@ on: default: true required: false type: boolean - scan: - default: true - required: false - type: boolean test_gmc: default: true required: false type: boolean - publish: - default: false - required: false - type: boolean - publish_tags: - default: "latest" - required: false - type: string + jobs: #################################################################################################### # Image Build @@ -41,40 +30,6 @@ jobs: image_tag: ${{ inputs.tag }} runner_label: 'docker-build-xeon' -#################################################################################################### -# Trivy Scan -#################################################################################################### - scan-images: - needs: [image-build] - if: ${{ fromJSON(inputs.scan) }} - strategy: - matrix: - image: ["gmcmanager", "gmcrouter"] - runs-on: 'docker-build-xeon' - steps: - - name: Harden Runner - uses: step-security/harden-runner@v2.8.1 - with: - egress-policy: audit - - - name: Pull Image - run: docker pull ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }} - - - name: Scan Container - uses: opea-project/validation/actions/trivy-scan@main - with: - image-ref: ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }} - output: ${{ matrix.image }}-scan.txt - - - name: Cleanup - if: always() - run: docker rmi -f ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }} - - uses: actions/upload-artifact@v4.3.4 - with: - name: gmc-scan - path: ${{ matrix.image }}-scan.txt - overwrite: true - #################################################################################################### # GMC Test #################################################################################################### @@ -86,22 +41,3 @@ jobs: repo: ${{ needs.image-build.outputs.image_repo }} tag: ${{ needs.image-build.outputs.image_tag }} secrets: inherit - - -#################################################################################################### -# Publish -#################################################################################################### - publish: - needs: [image-build, scan-images, test-gmc] - if: ${{ fromJSON(inputs.publish) }} - strategy: - matrix: - image: ["gmcmanager", "gmcrouter"] - runs-on: "docker-build-xeon" - steps: - - name: Image Publish - uses: opea-project/validation/actions/image-publish@main - with: - local_image_ref: ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }} - image_name: opea/${{ matrix.image }} - publish_tags: ${{ inputs.publish_tags }} diff --git a/.github/workflows/manual-gmc-cd-workflow.yaml b/.github/workflows/manual-gmc-cd-workflow.yaml index e839c7fc..67580287 100644 --- a/.github/workflows/manual-gmc-cd-workflow.yaml +++ b/.github/workflows/manual-gmc-cd-workflow.yaml @@ -12,29 +12,14 @@ on: type: string build: default: true - description: 'Build test required images for Examples' - required: false - type: boolean - scan: - default: true - description: 'Scan all images with Trivy' + description: 'Whether to build test required images for GMC' required: false type: boolean test_gmc: default: true - description: 'Test GMC on Xeon KIND' + description: 'Whether to test GMC in KIND on Xeon' required: false type: boolean - publish: - default: false - description: 'Publish images to docker hub' - required: false - type: boolean - publish_tags: - default: "latest,v0.9" - description: 'Tag list apply to publish images' - required: false - type: string permissions: read-all jobs: @@ -43,8 +28,5 @@ jobs: with: tag: ${{ inputs.tag }} build: ${{ fromJSON(inputs.build) }} - scan: ${{ fromJSON(inputs.scan) }} test_gmc: ${{ fromJSON(inputs.test_gmc) }} - publish: ${{ fromJSON(inputs.publish) }} - publish_tags: ${{ fromJSON(inputs.publish_tags) }} secrets: inherit diff --git a/.github/workflows/manual-helm-cd-workflow.yaml b/.github/workflows/manual-helm-cd-workflow.yaml index 16fad9e2..d4eed4cc 100644 --- a/.github/workflows/manual-helm-cd-workflow.yaml +++ b/.github/workflows/manual-helm-cd-workflow.yaml @@ -12,18 +12,14 @@ on: description: "workloads to test, empty for testing all helm charts" tag: default: "latest" - description: "Tag to apply to images" + description: "Image tag to be tested" required: true type: string - infra_branch: - default: latest - description: 'Build test required images for Examples' - required: false - type: string nodes: default: "xeon,gaudi" required: true type: string + description: 'Hardwares used to run tests' env: CHARTS_DIR: "helm-charts" @@ -58,7 +54,7 @@ jobs: nodes=$(printf '%s\n' "${node_list[@]}" | sort -u | jq -R '.' | jq -sc '.') echo "nodes=$nodes" >> $GITHUB_OUTPUT - gmc-release: + helm-release: needs: get-build-matrix strategy: matrix: @@ -69,5 +65,4 @@ jobs: tag: ${{ inputs.tag }} workload: ${{ matrix.workload }} hardware: ${{ matrix.node }} - opea_branch: ${{ inputs.infra_branch }} secrets: inherit diff --git a/RELEASE_BRANCHES.md b/RELEASE_BRANCHES.md new file mode 100644 index 00000000..fbf97ca4 --- /dev/null +++ b/RELEASE_BRANCHES.md @@ -0,0 +1,72 @@ +# Release Branches + +Release branches have a name of `v#.#` like `v0.9`. The branch with `v#.#rc` is the release candidate branch. This document describe how a release branch is created and how a release is made. All these steps have to be executed by release manager who has write permission. + +## 1. Create release candidate branch + +On the feature freeze day, a release candidate branch will be created. + +``` +git clone https://github.com/opea-project/GenAIInfra.git +cd GenAIInfra +git checkout -b v0.9rc +git push origin v0.9rc +``` + +## 2. Create images with release tag + +This step is being executed under `GenAIExamples`. + +In the [Actions](https://github.com/opea-project/GenAIExamples/actions), select the workflow "Examples CD workflow on manual event", and manually trigger this workflow. (Refer to [github website](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow) to get how to manually run a workflow.) + +There will be a window promoted for your input. The inputs to the workflow are: +| Description | Value | +|-----------------------------|------------| +|Use workflow from|Branch: v0.9rc| +|Hardware to run test|"gaudi,xeon"| +|List of examples to test|"AudioQnA,ChatQnA,CodeGen,CodeTrans,DocSum,FaqGen,SearchQnA,Translation"| +|Tag to apply to images|"v0.9rc"| +|Whether to deploy gmc|false| +|Build test required images for Examples|true| +|Scan all images with Trivy|false| +|Test examples with docker compose|false| +|Test examples with k8s|false| +|Test examples with gmc|false| +|OPEA branch for image build|"v0.9rc"| + +After this workflow executed, the images for GenAIExamples and GenAIComps with `v0.9` tag will be created and pushed to CI local image registries both in Gaudi and Xeon environment. + +## 3. Test helm charts + +This step is being executed under `GenAIInfra`. + +In the [Actions](https://github.com/opea-project/GenAIInfra/actions), select the workflow "GenAIInfra Helm CD workflow on manual event", and manually trigger this workflow. There will be a window promoted for your input. + +The inputs to the workflow are: +| Description | Value | +|-----------------------------|------------| +|Use workflow from|Branch: v0.9rc| +|workloads to test, empty for testing all helm charts|""| +|Image tag to be tested|"v0.9"| +|Hardwares used to run tests|"xeon,gaudi"| + +All the helm charts will be tested. Green ticks show helm charts pass the tests. + +## 4. Test GMC + +This step is being executed under `GenAIInfra`. The test will be executed in GMC CI K8s cluster, which is a KIND cluster for now. + +In the [Actions](https://github.com/opea-project/GenAIInfra/actions), select the workflow "GenAIInfra GMC CD workflow on manual event", and manually trigger this workflow. There will be a window promoted for your input. + +The inputs to the workflow are: +| Description | Value | +|-----------------------------|------------| +|Use workflow from|Branch: v0.9rc| +|Tag to apply to images|"v0.9"| +|Whether to build test required images for GMC|true| + +GMC images will be built with v0.9rc branch. GMC test cases will be tested in KIND cluster on Xeon. Green ticks show helm charts pass the tests. + +## 5. Publish images + +The image pass action will be executed under `GenAIExamples` repo. After all previous tests pass and GenAIExamples release tests also pass, the images will be pushed through GenAIExample workflow [Examples publish docker image on manual event](https://github.com/opea-project/GenAIExamples/actions/workflows/manual-docker-publish.yml).