diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 42f9700f415..e30b8175e51 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -20,6 +20,13 @@ on: - feature/** - enhance/** - fix/** + workflow_dispatch: + inputs: + debug: + type: boolean + description: 'Enable tmate Debug' + required: false + default: false # This allows a subsequently queued workflow run to interrupt previous runs concurrency: @@ -207,6 +214,13 @@ jobs: - name: Checkout Repository uses: actions/checkout@v5 + - name: Setup tmate Session + uses: mxschmitt/action-tmate@v3 + if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug }} + with: + detached: true + limit-access-to-actor: false + - name: Start Apollo Containers run: docker compose -f ".github/workflows/apollo/docker-compose.yml" up -d --build diff --git a/.github/workflows/scripts/ci-main.sh b/.github/workflows/scripts/ci-main.sh index 3f3d27a66bf..b24b2d9894c 100644 --- a/.github/workflows/scripts/ci-main.sh +++ b/.github/workflows/scripts/ci-main.sh @@ -2,12 +2,6 @@ coverage=$1 -# update code of submodules -git clone https://github.com/gogf/examples - -# update go.mod in examples directory to replace github.com/gogf/gf packages with local directory -bash .github/workflows/scripts/replace_examples_gomod.sh - # find all path that contains go.mod. for file in `find . -name go.mod`; do dirpath=$(dirname $file) @@ -24,22 +18,18 @@ for file in `find . -name go.mod`; do continue 1 fi - # Check if it's a contrib directory or examples directory - if [[ $dirpath =~ "/contrib/" ]] || [[ $dirpath =~ "/examples/" ]]; then + # examples directory was moved to sub ci procedure. + if [[ $dirpath =~ "/examples/" ]]; then + continue 1 + fi + + # Check if it's a contrib directory + if [[ $dirpath =~ "/contrib/" ]]; then # Check if go version meets the requirement if ! go version | grep -qE "go${LATEST_GO_VERSION}"; then echo "ignore path $dirpath as go version is not ${LATEST_GO_VERSION}: $(go version)" continue 1 fi - # If it's examples directory, only build without tests - if [[ $dirpath =~ "/examples/" ]]; then - echo "the examples directory only needs to be built, not unit tests and coverage tests." - cd $dirpath - go mod tidy - go build ./... - cd - - continue 1 - fi fi if [[ $file =~ "/testdata/" ]]; then @@ -47,6 +37,11 @@ for file in `find . -name go.mod`; do continue 1 fi + if [[ $dirpath = "." ]]; then + # No space left on device error sometimes occurs in CI pipelines, so clean the cache before tests. + go clean -cache + fi + cd $dirpath go mod tidy go build ./... diff --git a/.github/workflows/scripts/ci-sub.sh b/.github/workflows/scripts/ci-sub.sh index 70e1f13b519..9683b355e21 100644 --- a/.github/workflows/scripts/ci-sub.sh +++ b/.github/workflows/scripts/ci-sub.sh @@ -2,6 +2,12 @@ coverage=$1 +# update code of submodules +git clone https://github.com/gogf/examples + +# update go.mod in examples directory to replace github.com/gogf/gf packages with local directory +bash .github/workflows/scripts/replace_examples_gomod.sh + # Function to compare version numbers version_compare() { local ver1=$1 @@ -35,7 +41,19 @@ for file in `find . -name go.mod`; do dirpath=$(dirname $file) echo "Processing: $dirpath" - # Only process kubecm directory, skip others + # Only process examples and kubecm directories + + # Process examples directory (only build, no tests) + if [[ $dirpath =~ "/examples/" ]]; then + echo " the examples directory only needs to be built, not unit tests." + cd $dirpath + go mod tidy + go build ./... + cd - + continue 1 + fi + + # Process kubecm directory if [ "kubecm" != $(basename $dirpath) ]; then echo " Skipping: not kubecm directory" continue