mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
fix(ci): add cache cleaning step to prevent 'no space left on device' errors (#4513)
修复ci runner免费的磁盘空间不足导致无法完成单元测试的问题 1. 移动example单测到ci sub中 2. 使用go clean -cache清理避免短期内再次出现空间不足的问题
This commit is contained in:
14
.github/workflows/ci-main.yml
vendored
14
.github/workflows/ci-main.yml
vendored
@ -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
|
||||
|
||||
|
||||
29
.github/workflows/scripts/ci-main.sh
vendored
29
.github/workflows/scripts/ci-main.sh
vendored
@ -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 ./...
|
||||
|
||||
20
.github/workflows/scripts/ci-sub.sh
vendored
20
.github/workflows/scripts/ci-sub.sh
vendored
@ -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
|
||||
|
||||
Reference in New Issue
Block a user