Skip to content

Auto Nightly E2E CI #3935

Auto Nightly E2E CI

Auto Nightly E2E CI #3935

name: Auto Nightly E2E CI
permissions: write-all
on:
schedule:
# each day
- cron: "0 20 * * *"
push:
branches:
- main
- release-*
jobs:
get_ref:
runs-on: ubuntu-latest
outputs:
ref: ${{ env.RUN_REF }}
e2e_labels: ${{ env.RUN_E2E_LABELS }}
unittest_enabled: ${{ env.RUN_UNITTEST_ENABLED }}
run_push: ${{ env.RUN_PUSH}}
e2e_enabled: ${{ env.RUN_E2E_ENABLED }}
ipfamily_ipv4only_e2e: ${{ env.RUN_E2E_IPV4_ONLY }}
ipfamily_ipv6only_e2e: ${{ env.RUN_E2E_IPV6_ONLY }}
ipfamily_dual_e2e: ${{ env.RUN_E2E_DUAL_STACK }}
steps:
- name: Check Code Changes
uses: dorny/[email protected]
if: ${{ github.event_name == 'pull_request_target' }}
id: filter_pr
with:
base: ${{ github.event.pull_request.base.sha }}
ref: ${{ github.event.pull_request.head.sha }}
filters: |
run_e2e:
- '**/*.sh'
- '**/*.go'
- 'go.mod'
- 'go.sum'
- 'charts/**'
- 'Makefile*'
- '**/Makefile*'
all_e2e:
- 'test/**'
- 'vendor/github.com/spidernet-io/**/*.go'
- name: Get Ref
id: get_ref
run: |
if ${{ github.event_name == 'push' }} ; then
echo "trigger by push"
echo "RUN_TAG=${{ github.sha }}" >> $GITHUB_ENV
echo "RUN_PUSH=false" >> $GITHUB_ENV
echo "RUN_E2E_LABELS=smoke" >> $GITHUB_ENV
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
# do it in another workflow
echo "RUN_UNITTEST_ENABLED=false" >> $GITHUB_ENV
echo "RUN_E2E_IPV4_ONLY=false" >> $GITHUB_ENV
echo "RUN_E2E_IPV6_ONLY=false" >> $GITHUB_ENV
echo "RUN_E2E_DUAL_STACK=true" >> $GITHUB_ENV
elif ${{ github.event_name == 'pull_request_target' }} ; then
echo "trigger by pull_request_target"
echo "RUN_TAG=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "RUN_PUSH=false" >> $GITHUB_ENV
if ${{ steps.filter_pr.outputs.all_e2e == 'true' }} ; then
# run all e2e
echo "RUN_E2E_LABEL=" >> $GITHUB_ENV
echo "RUN_E2E_IPV4_ONLY=true" >> $GITHUB_ENV
echo "RUN_E2E_IPV6_ONLY=true" >> $GITHUB_ENV
echo "RUN_E2E_DUAL_STACK=true" >> $GITHUB_ENV
else
echo "RUN_E2E_LABEL=smoke" >> $GITHUB_ENV
echo "RUN_E2E_IPV4_ONLY=true" >> $GITHUB_ENV
echo "RUN_E2E_IPV6_ONLY=true" >> $GITHUB_ENV
echo "RUN_E2E_DUAL_STACK=true" >> $GITHUB_ENV
fi
echo "RUN_E2E_ENABLED=${{ steps.filter_pr.outputs.run_e2e }}" >> $GITHUB_ENV
# do it in another workflow
echo "RUN_UNITTEST_ENABLED=false" >> $GITHUB_ENV
else
# schedule event
# use main sha for ci image tag
echo "trigger by workflow_call"
echo "RUN_TAG=main" >> $GITHUB_ENV
echo "RUN_PUSH=false" >> $GITHUB_ENV
# nightly ci, run all e2e
echo "RUN_E2E_LABEL=" >> $GITHUB_ENV
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
echo "RUN_UNITTEST_ENABLED=true" >> $GITHUB_ENV
echo "RUN_E2E_IPV4_ONLY=true" >> $GITHUB_ENV
echo "RUN_E2E_IPV6_ONLY=true" >> $GITHUB_ENV
echo "RUN_E2E_DUAL_STACK=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_unittest:
needs: get_ref
if: ${{ needs.get_ref.outputs.unittest_enabled == 'true' }}
# forbid to specify version for local workflow, GITHUB_REF Same as the caller workflow
uses: ./.github/workflows/lint-golang.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
secrets: inherit
call_build_ci_image:
needs: [get_ref]
if: ${{ needs.get_ref.outputs.e2e_enabled == 'true' }}
# get image:${{ needs.get_ref.outputs.ref }} and image-ci:${{ needs.get_ref.outputs.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
if: ${{ needs.get_ref.outputs.e2e_enabled == 'true' }}
# forbid to specify version for local workflow, GITHUB_REF Same as the caller workflow
uses: ./.github/workflows/call-lint-chart.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
secrets: inherit
call_release_chart:
needs: [get_ref]
if: ${{ needs.get_ref.outputs.e2e_enabled == 'true' }}
uses: ./.github/workflows/call-release-chart.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
submit: false
secrets: inherit
call_e2e_dual:
needs: [call_build_ci_image, get_ref, call_release_chart]
if: ${{ needs.get_ref.outputs.e2e_enabled == 'true' && needs.get_ref.outputs.ipfamily_dual_e2e == '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 }}
e2e_labels: ${{ needs.get_ref.outputs.e2e_labels }}
secrets: inherit
call_e2e_ipv4:
needs: [call_build_ci_image, get_ref, call_release_chart]
if: ${{ needs.get_ref.outputs.e2e_enabled == 'true' && needs.get_ref.outputs.ipfamily_ipv4only_e2e == 'true' }}
uses: ./.github/workflows/e2e-init.yaml
with:
ip_family: ipv4
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }}
ref: ${{ needs.get_ref.outputs.ref }}
e2e_labels: ${{ needs.get_ref.outputs.e2e_labels }}
secrets: inherit
call_e2e_ipv6:
needs: [call_build_ci_image, get_ref, call_release_chart]
if: ${{ needs.get_ref.outputs.e2e_enabled == 'true' && needs.get_ref.outputs.ipfamily_ipv6only_e2e == 'true' }}
uses: ./.github/workflows/e2e-init.yaml
with:
ip_family: ipv6
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }}
ref: ${{ needs.get_ref.outputs.ref }}
e2e_labels: ${{ needs.get_ref.outputs.e2e_labels }}
secrets: inherit
call_low_kernel:
needs: [call_build_ci_image, get_ref, call_release_chart]
if: ${{ needs.get_ref.outputs.e2e_enabled == 'true' && needs.get_ref.outputs.ipfamily_dual_e2e == 'true' }}
uses: ./.github/workflows/e2e-init.yaml
with:
os: ubuntu-20.04
ip_family: dual
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }}
ref: ${{ needs.get_ref.outputs.ref }}
e2e_labels: ${{ needs.get_ref.outputs.e2e_labels }}
secrets: inherit
creat_issue:
runs-on: ubuntu-latest
needs: [call_e2e_dual, call_e2e_ipv4, call_e2e_ipv6, call_unittest, lint_chart_against_release_image, call_low_kernel]
if: ${{ always() && needs.call_e2e_dual.result == 'failure' || needs.call_e2e_ipv4.result == 'failure' || needs.call_e2e_ipv6.result == 'failure' || needs.call_unittest.result == 'failure' || needs.lint_chart_against_release_image.result == 'failure' || needs.call_low_kernel.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.GITHUB_TOKEN }}
title: "Night CI ${{ ENV.TIMESTAMP }}: Failed"
body: |
action url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
labels: "kind/ci-bug"
assignees: "ty-dc"