From ebc165a6aa3ac84ad30f08650bdcadad90e94add Mon Sep 17 00:00:00 2001 From: Ying Chun Guo Date: Thu, 8 Aug 2024 10:29:04 +0800 Subject: [PATCH] Rename github workflows (#554) Signed-off-by: Yingchun Guo --- ...t-test-matrix.yml => _get-test-matrix.yml} | 0 ...reuse-image-build.yml => _image-build.yml} | 0 .github/workflows/_manifest-e2e.yml | 99 +++++++++++++++++++ ...d-on-manual.yml => manual-image-build.yml} | 0 .../{trellix.yml => manual-trellix.yml} | 0 ...m_list_check.yml => pr-bum_list_check.yml} | 0 .../{code-scan.yml => pr-code-scan.yml} | 0 ...pose-e2e.yml => pr-docker-compose-e2e.yml} | 4 +- .../{gmc-e2e.yaml => pr-gmc-e2e.yaml} | 2 +- .../{manifest-e2e.yml => pr-manifest-e2e.yml} | 4 +- ...-validate.yml => pr-manifest-validate.yml} | 0 ...th_detection.yml => pr-path_detection.yml} | 0 ...build-on-push.yml => push-image-build.yml} | 4 +- ...ion.yml => push-images-path-detection.yml} | 0 ...tion.yml => push-infra-issue-creation.yml} | 0 15 files changed, 106 insertions(+), 7 deletions(-) rename .github/workflows/{reuse-get-test-matrix.yml => _get-test-matrix.yml} (100%) rename .github/workflows/{reuse-image-build.yml => _image-build.yml} (100%) create mode 100644 .github/workflows/_manifest-e2e.yml rename .github/workflows/{image-build-on-manual.yml => manual-image-build.yml} (100%) rename .github/workflows/{trellix.yml => manual-trellix.yml} (100%) rename .github/workflows/{bum_list_check.yml => pr-bum_list_check.yml} (100%) rename .github/workflows/{code-scan.yml => pr-code-scan.yml} (100%) rename .github/workflows/{docker-compose-e2e.yml => pr-docker-compose-e2e.yml} (96%) rename .github/workflows/{gmc-e2e.yaml => pr-gmc-e2e.yaml} (98%) rename .github/workflows/{manifest-e2e.yml => pr-manifest-e2e.yml} (97%) rename .github/workflows/{manifest-validate.yml => pr-manifest-validate.yml} (100%) rename .github/workflows/{path_detection.yml => pr-path_detection.yml} (100%) rename .github/workflows/{image-build-on-push.yml => push-image-build.yml} (94%) rename .github/workflows/{images_path_detection.yml => push-images-path-detection.yml} (100%) rename .github/workflows/{infra-issue-creation.yml => push-infra-issue-creation.yml} (100%) diff --git a/.github/workflows/reuse-get-test-matrix.yml b/.github/workflows/_get-test-matrix.yml similarity index 100% rename from .github/workflows/reuse-get-test-matrix.yml rename to .github/workflows/_get-test-matrix.yml diff --git a/.github/workflows/reuse-image-build.yml b/.github/workflows/_image-build.yml similarity index 100% rename from .github/workflows/reuse-image-build.yml rename to .github/workflows/_image-build.yml diff --git a/.github/workflows/_manifest-e2e.yml b/.github/workflows/_manifest-e2e.yml new file mode 100644 index 000000000..a0c3fc5e8 --- /dev/null +++ b/.github/workflows/_manifest-e2e.yml @@ -0,0 +1,99 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +name: Single Kubernetes Manifest E2e Test For Call +on: + workflow_call: + inputs: + example: + default: "ChatQnA" + description: "The example to test on K8s" + required: true + type: string + node: + default: "xeon" + description: "Nodes to run the test, xeon or gaudi" + required: true + type: string + tag: + default: "latest" + description: "Tag to apply to images, default is latest" + required: false + type: string + +jobs: + manifest-test: + runs-on: "k8s-${{ inputs.node }}" + continue-on-error: true + steps: + - name: Clean Up Working Directory + run: sudo rm -rf ${{github.workspace}}/* + + - name: Get checkout ref + run: | + if [ "${{ github.event_name }}" == "pull_request" ] || [ "${{ github.event_name }}" == "pull_request_target" ]; then + echo "CHECKOUT_REF=refs/pull/${{ github.event.number }}/merge" >> $GITHUB_ENV + else + echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV + fi + echo "checkout ref ${{ env.CHECKOUT_REF }}" + + - name: Checkout out Repo + uses: actions/checkout@v4 + with: + ref: ${{ env.CHECKOUT_REF }} + fetch-depth: 0 + + - name: Set variables + run: | + echo "IMAGE_REPO=$OPEA_IMAGE_REPO" >> $GITHUB_ENV + echo "IMAGE_TAG=${{ inputs.tag }}" >> $GITHUB_ENV + lower_example=$(echo "${{ inputs.example }}" | tr '[:upper:]' '[:lower:]') + echo "NAMESPACE=$lower_example-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV + echo "ROLLOUT_TIMEOUT_SECONDS=1800s" >> $GITHUB_ENV + echo "KUBECTL_TIMEOUT_SECONDS=60s" >> $GITHUB_ENV + echo "continue_test=true" >> $GITHUB_ENV + echo "should_cleanup=false" >> $GITHUB_ENV + echo "skip_validate=true" >> $GITHUB_ENV + echo "NAMESPACE=$NAMESPACE" + + - name: Kubectl install + id: install + run: | + if [[ ! -f ${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.node }}.sh ]]; then + echo "No test script found, exist test!" + exit 0 + else + ${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.node }}.sh init_${{ inputs.example }} + echo "should_cleanup=true" >> $GITHUB_ENV + kubectl create ns $NAMESPACE + ${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.node }}.sh install_${{ inputs.example }} $NAMESPACE + echo "Testing ${{ inputs.example }}, waiting for pod ready..." + if kubectl rollout status deployment --namespace "$NAMESPACE" --timeout "$ROLLOUT_TIMEOUT_SECONDS"; then + echo "Testing manifests ${{ inputs.example }}, waiting for pod ready done!" + echo "skip_validate=false" >> $GITHUB_ENV + else + echo "Timeout waiting for pods in namespace $NAMESPACE to be ready!" + exit 1 + fi + sleep 60 + fi + + - name: Validate e2e test + if: always() + run: | + if $skip_validate; then + echo "Skip validate" + else + ${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.node }}.sh validate_${{ inputs.example }} $NAMESPACE + fi + + - name: Kubectl uninstall + if: always() + run: | + if $should_cleanup; then + if ! kubectl delete ns $NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then + kubectl delete pods --namespace $NAMESPACE --force --grace-period=0 --all + kubectl delete ns $NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS + fi + fi diff --git a/.github/workflows/image-build-on-manual.yml b/.github/workflows/manual-image-build.yml similarity index 100% rename from .github/workflows/image-build-on-manual.yml rename to .github/workflows/manual-image-build.yml diff --git a/.github/workflows/trellix.yml b/.github/workflows/manual-trellix.yml similarity index 100% rename from .github/workflows/trellix.yml rename to .github/workflows/manual-trellix.yml diff --git a/.github/workflows/bum_list_check.yml b/.github/workflows/pr-bum_list_check.yml similarity index 100% rename from .github/workflows/bum_list_check.yml rename to .github/workflows/pr-bum_list_check.yml diff --git a/.github/workflows/code-scan.yml b/.github/workflows/pr-code-scan.yml similarity index 100% rename from .github/workflows/code-scan.yml rename to .github/workflows/pr-code-scan.yml diff --git a/.github/workflows/docker-compose-e2e.yml b/.github/workflows/pr-docker-compose-e2e.yml similarity index 96% rename from .github/workflows/docker-compose-e2e.yml rename to .github/workflows/pr-docker-compose-e2e.yml index fee4965e1..2ba04e027 100644 --- a/.github/workflows/docker-compose-e2e.yml +++ b/.github/workflows/pr-docker-compose-e2e.yml @@ -23,7 +23,7 @@ concurrency: jobs: job1: - uses: ./.github/workflows/reuse-get-test-matrix.yml + uses: ./.github/workflows/_get-test-matrix.yml with: diff_excluded_files: '.github|README.md|*.txt|deprecate|kubernetes|manifest|gmc|assets' @@ -31,7 +31,7 @@ jobs: needs: job1 strategy: matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }} - uses: ./.github/workflows/reuse-image-build.yml + uses: ./.github/workflows/_image-build.yml with: image_tag: ${{ github.event.pull_request.head.sha }} mega_service: "${{ matrix.example }}" diff --git a/.github/workflows/gmc-e2e.yaml b/.github/workflows/pr-gmc-e2e.yaml similarity index 98% rename from .github/workflows/gmc-e2e.yaml rename to .github/workflows/pr-gmc-e2e.yaml index 82fc1fcc6..235c2a555 100644 --- a/.github/workflows/gmc-e2e.yaml +++ b/.github/workflows/pr-gmc-e2e.yaml @@ -21,7 +21,7 @@ concurrency: jobs: job1: - uses: ./.github/workflows/reuse-get-test-matrix.yml + uses: ./.github/workflows/_get-test-matrix.yml with: diff_excluded_files: '.github|deprecated|docker|assets|*.md|*.txt' xeon_server_label: 'xeon' diff --git a/.github/workflows/manifest-e2e.yml b/.github/workflows/pr-manifest-e2e.yml similarity index 97% rename from .github/workflows/manifest-e2e.yml rename to .github/workflows/pr-manifest-e2e.yml index 291055b7c..a427971c3 100644 --- a/.github/workflows/manifest-e2e.yml +++ b/.github/workflows/pr-manifest-e2e.yml @@ -20,7 +20,7 @@ concurrency: jobs: job1: - uses: ./.github/workflows/reuse-get-test-matrix.yml + uses: ./.github/workflows/_get-test-matrix.yml with: diff_excluded_files: '.github|deprecated|docker|assets|*.md|*.txt' xeon_server_label: 'xeon' @@ -30,7 +30,7 @@ jobs: needs: job1 strategy: matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }} - uses: ./.github/workflows/reuse-image-build.yml + uses: ./.github/workflows/_image-build.yml with: image_tag: ${{ github.event.pull_request.head.sha }} mega_service: "${{ matrix.example }}" diff --git a/.github/workflows/manifest-validate.yml b/.github/workflows/pr-manifest-validate.yml similarity index 100% rename from .github/workflows/manifest-validate.yml rename to .github/workflows/pr-manifest-validate.yml diff --git a/.github/workflows/path_detection.yml b/.github/workflows/pr-path_detection.yml similarity index 100% rename from .github/workflows/path_detection.yml rename to .github/workflows/pr-path_detection.yml diff --git a/.github/workflows/image-build-on-push.yml b/.github/workflows/push-image-build.yml similarity index 94% rename from .github/workflows/image-build-on-push.yml rename to .github/workflows/push-image-build.yml index 76e160b90..3b3f22fa1 100644 --- a/.github/workflows/image-build-on-push.yml +++ b/.github/workflows/push-image-build.yml @@ -5,7 +5,7 @@ name: Build latest images on push event on: push: - branches: [ 'main','daisyonpush' ] + branches: [ 'main' ] paths: - "**/docker/*.py" - "**/docker/Dockerfile" @@ -18,7 +18,7 @@ concurrency: jobs: job1: - uses: ./.github/workflows/reuse-get-test-matrix.yml + uses: ./.github/workflows/_get-test-matrix.yml mega-image-build: needs: job1 diff --git a/.github/workflows/images_path_detection.yml b/.github/workflows/push-images-path-detection.yml similarity index 100% rename from .github/workflows/images_path_detection.yml rename to .github/workflows/push-images-path-detection.yml diff --git a/.github/workflows/infra-issue-creation.yml b/.github/workflows/push-infra-issue-creation.yml similarity index 100% rename from .github/workflows/infra-issue-creation.yml rename to .github/workflows/push-infra-issue-creation.yml