Nightly K8s Matrix #208
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nightly K8s Matrix | |
permissions: write-all | |
env: | |
CLUSTER_NAME: spider | |
E2E_TIME_OUT: 60m | |
on: | |
schedule: | |
- cron: "0 20 * * *" | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'sha, tag, branch' | |
required: true | |
default: main | |
k8s_version: | |
description: 'It should be the released version, for example: v1.25.2; if not set, the default version set will be run.' | |
required: false | |
type: string | |
e2e_enabled: | |
description: 'run e2e test' | |
required: false | |
type: choice | |
default: "false" | |
options: | |
- "true" | |
- "false" | |
e2e_labels: | |
description: 'e2e labels(if not set, ginkgo will run all test, multi labels separated by commas)' | |
required: false | |
type: string | |
jobs: | |
get_ref: | |
runs-on: ubuntu-latest | |
outputs: | |
ref: ${{ env.RUN_REF }} | |
run_push: ${{ env.RUN_PUSH }} | |
e2e_enabled: ${{ env.RUN_E2E_ENABLED }} | |
inputs_k8s_version: ${{ env.INPUTS_K8S_VERSION }} | |
default_k8s_version: ${{ env.DEFAULT_K8S_VERSION }} | |
steps: | |
- name: Get Ref | |
id: get_ref | |
run: | | |
if ${{ github.event_name == 'workflow_dispatch' }} ; then | |
echo "call by self workflow_dispatch" | |
echo "RUN_TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV | |
if ${{ github.event.inputs.k8s_version == '' }}; then | |
echo "INPUTS_K8S_VERSION=false" >> $GITHUB_ENV | |
echo "DEFAULT_K8S_VERSION=true" >> $GITHUB_ENV | |
else | |
echo "A custom version of k8s will be run: ${{ github.event.inputs.k8s_version }} " | |
echo "INPUTS_K8S_VERSION=true" >> $GITHUB_ENV | |
echo "DEFAULT_K8S_VERSION=false" >> $GITHUB_ENV | |
fi | |
if ${{ github.event.inputs.e2e_enabled == 'true' }}; then | |
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV | |
else | |
echo "RUN_E2E_ENABLED=false" >> $GITHUB_ENV | |
fi | |
else | |
# schedule event | |
# use main sha for ci image tag | |
echo "trigger by schedule" | |
echo "RUN_TAG=main" >> $GITHUB_ENV | |
echo "RUN_PUSH=false" >> $GITHUB_ENV | |
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV | |
echo "INPUTS_K8S_VERSION=false" >> $GITHUB_ENV | |
echo "DEFAULT_K8S_VERSION=true" >> $GITHUB_ENV | |
fi | |
# some event, the tag is not sha, so checkout it and get sha | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
ref: ${{ env.RUN_TAG }} | |
- name: Result Ref | |
id: result | |
run: | | |
ref=$( git show -s --format='format:%H') | |
echo "RUN_REF=${ref}" >> $GITHUB_ENV | |
call_build_ci_image: | |
needs: [get_ref] | |
uses: ./.github/workflows/build-image-ci.yaml | |
with: | |
ref: ${{ needs.get_ref.outputs.ref }} | |
push: false | |
secrets: inherit | |
lint_chart_against_release_image: | |
needs: get_ref | |
uses: ./.github/workflows/call-lint-chart.yaml | |
with: | |
ref: ${{ needs.get_ref.outputs.ref }} | |
secrets: inherit | |
call_release_chart: | |
needs: [get_ref] | |
uses: ./.github/workflows/call-release-chart.yaml | |
with: | |
ref: ${{ needs.get_ref.outputs.ref }} | |
submit: false | |
secrets: inherit | |
call_k8s_matrix: | |
# k8s versions | |
strategy: | |
fail-fast: false | |
matrix: | |
# Synchronise with the latest releases of each version | |
version: [v1.22.7, v1.23.5, v1.24.4, v1.25.3, v1.26.2, v1.27.1, v1.28.0] | |
needs: [call_build_ci_image, get_ref, call_release_chart] | |
uses: ./.github/workflows/e2e-init.yaml | |
with: | |
ip_family: dual | |
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }} | |
ref: ${{ needs.get_ref.outputs.ref }} | |
k8s_version: ${{ matrix.version }} | |
run_e2e: ${{ needs.get_ref.outputs.e2e_enabled }} | |
e2e_labels: ${{ inputs.e2e_labels }} | |
secrets: inherit | |
creat_issue: | |
runs-on: ubuntu-latest | |
needs: [call_k8s_matrix, lint_chart_against_release_image] | |
if: ${{ always() && needs.call_k8s_matrix.result == 'failure' || needs.lint_chart_against_release_image.result == 'failure' }} | |
steps: | |
- name: echo | |
run: | | |
echo ${{ github.repository }} | |
echo ${{ github.repository_owner }} | |
echo "TIMESTAMP=`date +%Y-%m-%d`" >> $GITHUB_ENV | |
- name: create an issue | |
uses: dacbd/[email protected] | |
with: | |
token: ${{ secrets.WELAN_PAT }} | |
title: "Nightly K8s Matrix CI ${{ ENV.TIMESTAMP }}: Failed" | |
body: | | |
action url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
labels: "kind/ci-bug" | |
assignees: "Icarus9913,ty-dc" | |
call_inputs_k8s: | |
# workflow_dispatch event flow triggered by running the input k8s version | |
needs: [call_build_ci_image, get_ref, call_release_chart] | |
if: ${{ needs.get_ref.outputs.default_k8s_version == 'false' && needs.get_ref.outputs.inputs_k8s_version == 'true' }} | |
uses: ./.github/workflows/e2e-init.yaml | |
with: | |
ip_family: dual | |
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }} | |
ref: ${{ needs.get_ref.outputs.ref }} | |
k8s_version: ${{ inputs.k8s_version }} | |
run_e2e: ${{ needs.get_ref.outputs.e2e_enabled }} | |
e2e_labels: ${{ inputs.e2e_labels }} | |
secrets: inherit |