Skip to content

Commit d68be05

Browse files
authored
add composible manifest e2e for cd workflow (opea-project#588)
Signed-off-by: Yingchun Guo <yingchun.guo@intel.com>
1 parent 45cf553 commit d68be05

File tree

3 files changed

+25
-76
lines changed

3 files changed

+25
-76
lines changed

.github/workflows/_example-workflow.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,19 @@ jobs:
142142
####################################################################################################
143143
# K8S Test
144144
####################################################################################################
145-
# TODO
145+
test-k8s-manifest:
146+
needs: [build-images]
147+
if: ${{ fromJSON(inputs.test_k8s) }}
148+
strategy:
149+
matrix:
150+
hardware: ["xeon", "gaudi"]
151+
fail-fast: false
152+
uses: ./.github/workflows/_manifest-e2e.yml
153+
with:
154+
example: ${{ inputs.example }}
155+
hardware: ${{ matrix.hardware }}
156+
tag: ${{ inputs.tag }}
157+
secrets: inherit
146158

147159

148160
####################################################################################################

.github/workflows/_manifest-e2e.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
description: "The example to test on K8s"
1111
required: true
1212
type: string
13-
node:
13+
hardware:
1414
default: "xeon"
1515
description: "Nodes to run the test, xeon or gaudi"
1616
required: true
@@ -23,7 +23,7 @@ on:
2323

2424
jobs:
2525
manifest-test:
26-
runs-on: "k8s-${{ inputs.node }}"
26+
runs-on: "k8s-${{ inputs.hardware }}"
2727
continue-on-error: true
2828
steps:
2929
- name: Clean Up Working Directory
@@ -60,14 +60,14 @@ jobs:
6060
- name: Kubectl install
6161
id: install
6262
run: |
63-
if [[ ! -f ${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.node }}.sh ]]; then
63+
if [[ ! -f ${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.hardware }}.sh ]]; then
6464
echo "No test script found, exist test!"
6565
exit 0
6666
else
67-
${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.node }}.sh init_${{ inputs.example }}
67+
${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.hardware }}.sh init_${{ inputs.example }}
6868
echo "should_cleanup=true" >> $GITHUB_ENV
6969
kubectl create ns $NAMESPACE
70-
${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.node }}.sh install_${{ inputs.example }} $NAMESPACE
70+
${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.hardware }}.sh install_${{ inputs.example }} $NAMESPACE
7171
echo "Testing ${{ inputs.example }}, waiting for pod ready..."
7272
if kubectl rollout status deployment --namespace "$NAMESPACE" --timeout "$ROLLOUT_TIMEOUT_SECONDS"; then
7373
echo "Testing manifests ${{ inputs.example }}, waiting for pod ready done!"
@@ -85,7 +85,7 @@ jobs:
8585
if $skip_validate; then
8686
echo "Skip validate"
8787
else
88-
${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.node }}.sh validate_${{ inputs.example }} $NAMESPACE
88+
${{ github.workspace }}/${{ inputs.example }}/tests/test_manifest_on_${{ inputs.hardware }}.sh validate_${{ inputs.example }} $NAMESPACE
8989
fi
9090
9191
- name: Kubectl uninstall

.github/workflows/pr-manifest-e2e.yml

Lines changed: 6 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -40,72 +40,9 @@ jobs:
4040
needs: [job1, mega-image-build]
4141
strategy:
4242
matrix: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
43-
runs-on: "k8s-${{ matrix.hardware }}"
44-
continue-on-error: true
45-
steps:
46-
- name: E2e test manifest
47-
run: |
48-
echo "Matrix - manifest: ${{ matrix.example }}"
49-
50-
- name: Clean Up Working Directory
51-
run: sudo rm -rf ${{github.workspace}}/*
52-
53-
- name: Checkout out Repo
54-
uses: actions/checkout@v4
55-
with:
56-
fetch-depth: 0
57-
58-
- name: Set variables
59-
run: |
60-
if [ ${{ matrix.hardware }} == "gaudi" ]; then IMAGE_REPO=${{ vars.IMAGE_REPO_GAUDI }}; else IMAGE_REPO=${{ vars.IMAGE_REPO_XEON }}; fi
61-
echo "IMAGE_REPO=$OPEA_IMAGE_REPO" >> $GITHUB_ENV
62-
echo "IMAGE_TAG=${{needs.mega-image-build.outputs.image_tag}}" >> $GITHUB_ENV
63-
lower_example=$(echo "${{ matrix.example }}" | tr '[:upper:]' '[:lower:]')
64-
echo "NAMESPACE=$lower_example-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
65-
echo "ROLLOUT_TIMEOUT_SECONDS=1800s" >> $GITHUB_ENV
66-
echo "KUBECTL_TIMEOUT_SECONDS=60s" >> $GITHUB_ENV
67-
echo "continue_test=true" >> $GITHUB_ENV
68-
echo "should_cleanup=false" >> $GITHUB_ENV
69-
echo "skip_validate=true" >> $GITHUB_ENV
70-
echo "NAMESPACE=$NAMESPACE"
71-
72-
- name: Kubectl install
73-
id: install
74-
run: |
75-
if [[ ! -f ${{ github.workspace }}/${{ matrix.example }}/tests/test_manifest_on_${{ matrix.hardware }}.sh ]]; then
76-
echo "No test script found, exist test!"
77-
exit 0
78-
else
79-
${{ github.workspace }}/${{ matrix.example }}/tests/test_manifest_on_${{ matrix.hardware }}.sh init_${{ matrix.example }}
80-
echo "should_cleanup=true" >> $GITHUB_ENV
81-
kubectl create ns $NAMESPACE
82-
${{ github.workspace }}/${{ matrix.example }}/tests/test_manifest_on_${{ matrix.hardware }}.sh install_${{ matrix.example }} $NAMESPACE
83-
echo "Testing ${{ matrix.example }}, waiting for pod ready..."
84-
if kubectl rollout status deployment --namespace "$NAMESPACE" --timeout "$ROLLOUT_TIMEOUT_SECONDS"; then
85-
echo "Testing manifests ${{ matrix.example }}, waiting for pod ready done!"
86-
echo "skip_validate=false" >> $GITHUB_ENV
87-
else
88-
echo "Timeout waiting for pods in namespace $NAMESPACE to be ready!"
89-
exit 1
90-
fi
91-
sleep 60
92-
fi
93-
94-
- name: Validate e2e test
95-
if: always()
96-
run: |
97-
if $skip_validate; then
98-
echo "Skip validate"
99-
else
100-
${{ github.workspace }}/${{ matrix.example }}/tests/test_manifest_on_${{ matrix.hardware }}.sh validate_${{ matrix.example }} $NAMESPACE
101-
fi
102-
103-
- name: Kubectl uninstall
104-
if: always()
105-
run: |
106-
if $should_cleanup; then
107-
if ! kubectl delete ns $NAMESPACE --timeout=$KUBECTL_TIMEOUT_SECONDS; then
108-
kubectl delete pods --namespace $NAMESPACE --force --grace-period=0 --all
109-
kubectl delete ns $NAMESPACE --force --grace-period=0 --timeout=$KUBECTL_TIMEOUT_SECONDS
110-
fi
111-
fi
43+
uses: ./.github/workflows/_manifest-e2e.yml
44+
with:
45+
example: ${{ matrix.example }}
46+
hardware: ${{ matrix.hardware }}
47+
tag: ${{ needs.mega-image-build.outputs.image_tag }}
48+
secrets: inherit

0 commit comments

Comments
 (0)