Enhance CI Workflows and Makefile for Testing and Benchmarking
- Added additional failure checks in the Makefile for unit tests to improve error handling. - Updated GitHub Actions workflows to include a new benchmark and memory leak testing job, enhancing performance validation. - Modified environment setup in workflows to ensure correct database paths for SQLite, improving test reliability. - Streamlined the core test execution process by removing redundant commands, focusing on unit tests only.
This commit is contained in:
parent
4a47b92156
commit
4f417d4d6e
3 changed files with 240 additions and 12 deletions
140
.github/workflows/pr-test.yml
vendored
140
.github/workflows/pr-test.yml
vendored
|
|
@ -315,8 +315,9 @@ jobs:
|
||||||
|
|
||||||
- name: Setup ENV (SQLite)
|
- name: Setup ENV (SQLite)
|
||||||
run: |
|
run: |
|
||||||
|
mkdir -p ${{ github.WORKSPACE }}/../app/db
|
||||||
echo "YAO_DB_DRIVER=sqlite3" >> $GITHUB_ENV
|
echo "YAO_DB_DRIVER=sqlite3" >> $GITHUB_ENV
|
||||||
echo "YAO_DB_PRIMARY=$YAO_ROOT/db/yao.db" >> $GITHUB_ENV
|
echo "YAO_DB_PRIMARY=${{ github.WORKSPACE }}/../app/db/yao.db" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Run AI Tests (agent, aigc)
|
- name: Run AI Tests (agent, aigc)
|
||||||
run: make unit-test-ai
|
run: make unit-test-ai
|
||||||
|
|
@ -335,6 +336,136 @@ jobs:
|
||||||
body: '✅ AI Tests (agent, aigc) passed!'
|
body: '✅ AI Tests (agent, aigc) passed!'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Benchmark & Memory Leak Tests - Run with MySQL8.0 and SQLite3
|
||||||
|
# =============================================================================
|
||||||
|
PerfTest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
mcp-everything:
|
||||||
|
image: yaoapp/mcp-everything:latest
|
||||||
|
ports:
|
||||||
|
- "3021:3021"
|
||||||
|
- "3022:3022"
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go: [1.24]
|
||||||
|
db: [MySQL8.0, SQLite3]
|
||||||
|
if: >
|
||||||
|
${{ github.event.workflow_run.event == 'pull_request' &&
|
||||||
|
github.event.workflow_run.conclusion == 'success' }}
|
||||||
|
steps:
|
||||||
|
- name: "Download artifact"
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
run_id: ${{github.event.workflow_run.id }},
|
||||||
|
});
|
||||||
|
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
|
||||||
|
return artifact.name == "pr"
|
||||||
|
})[0];
|
||||||
|
var download = await github.rest.actions.downloadArtifact({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
artifact_id: matchArtifact.id,
|
||||||
|
archive_format: 'zip',
|
||||||
|
});
|
||||||
|
var fs = require('fs');
|
||||||
|
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
|
||||||
|
|
||||||
|
- name: "Read NR & SHA"
|
||||||
|
run: |
|
||||||
|
unzip pr.zip
|
||||||
|
cat NR
|
||||||
|
cat SHA
|
||||||
|
echo HEAD=$(cat SHA) >> $GITHUB_ENV
|
||||||
|
echo NR=$(cat NR) >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Checkout Kun
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: yaoapp/kun
|
||||||
|
path: kun
|
||||||
|
|
||||||
|
- name: Checkout Xun
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: yaoapp/xun
|
||||||
|
path: xun
|
||||||
|
|
||||||
|
- name: Checkout Gou
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: yaoapp/gou
|
||||||
|
path: gou
|
||||||
|
|
||||||
|
- name: Checkout V8Go
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: yaoapp/v8go
|
||||||
|
path: v8go
|
||||||
|
|
||||||
|
- name: Unzip libv8
|
||||||
|
run: |
|
||||||
|
files=$(find ./v8go -name "libv8*.zip")
|
||||||
|
for file in $files; do
|
||||||
|
dir=$(dirname "$file")
|
||||||
|
echo "Extracting $file to directory $dir"
|
||||||
|
unzip -o -d $dir $file
|
||||||
|
rm -rf $dir/__MACOSX
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Checkout Demo App
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: yaoapp/yao-dev-app
|
||||||
|
path: app
|
||||||
|
|
||||||
|
- name: Checkout Extension
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: yaoapp/yao-extensions-dev
|
||||||
|
path: extension
|
||||||
|
|
||||||
|
- name: Move Dependencies
|
||||||
|
run: |
|
||||||
|
mv kun ../
|
||||||
|
mv xun ../
|
||||||
|
mv gou ../
|
||||||
|
mv v8go ../
|
||||||
|
mv app ../
|
||||||
|
mv extension ../
|
||||||
|
|
||||||
|
- name: Checkout pull request HEAD commit
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ env.HEAD }}
|
||||||
|
|
||||||
|
- name: Setup Go ${{ matrix.go }}
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
|
- name: Setup Go Tools
|
||||||
|
run: make tools
|
||||||
|
|
||||||
|
- name: Setup ${{ matrix.db }}
|
||||||
|
uses: ./.github/actions/setup-db
|
||||||
|
with:
|
||||||
|
kind: "${{ matrix.db }}"
|
||||||
|
db: "xiang"
|
||||||
|
user: "xiang"
|
||||||
|
password: ${{ secrets.UNIT_PASS }}
|
||||||
|
|
||||||
|
- name: Run Benchmark & Memory Leak Tests
|
||||||
|
run: |
|
||||||
|
make benchmark
|
||||||
|
make memory-leak
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Core Tests - Run with DB matrix (MySQL/SQLite/Redis/Mongo combinations)
|
# Core Tests - Run with DB matrix (MySQL/SQLite/Redis/Mongo combinations)
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
@ -371,7 +502,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [1.24]
|
go: [1.24]
|
||||||
db: [MySQL8.0, MySQL5.7, SQLite3]
|
db: [MySQL8.0, SQLite3]
|
||||||
redis: [4, 5, 6]
|
redis: [4, 5, 6]
|
||||||
mongo: ["6.0"]
|
mongo: ["6.0"]
|
||||||
if: >
|
if: >
|
||||||
|
|
@ -586,10 +717,7 @@ jobs:
|
||||||
make misspell-check
|
make misspell-check
|
||||||
|
|
||||||
- name: Run Core Tests (exclude AI)
|
- name: Run Core Tests (exclude AI)
|
||||||
run: |
|
run: make unit-test-core
|
||||||
make unit-test-core
|
|
||||||
make benchmark
|
|
||||||
make memory-leak
|
|
||||||
|
|
||||||
- name: Codecov Report
|
- name: Codecov Report
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v4
|
||||||
|
|
|
||||||
106
.github/workflows/unit-test.yml
vendored
106
.github/workflows/unit-test.yml
vendored
|
|
@ -274,12 +274,109 @@ jobs:
|
||||||
|
|
||||||
- name: Setup ENV (SQLite)
|
- name: Setup ENV (SQLite)
|
||||||
run: |
|
run: |
|
||||||
|
mkdir -p ${{ github.WORKSPACE }}/../app/db
|
||||||
echo "YAO_DB_DRIVER=sqlite3" >> $GITHUB_ENV
|
echo "YAO_DB_DRIVER=sqlite3" >> $GITHUB_ENV
|
||||||
echo "YAO_DB_PRIMARY=$YAO_ROOT/db/yao.db" >> $GITHUB_ENV
|
echo "YAO_DB_PRIMARY=${{ github.WORKSPACE }}/../app/db/yao.db" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Run AI Tests (agent, aigc)
|
- name: Run AI Tests (agent, aigc)
|
||||||
run: make unit-test-ai
|
run: make unit-test-ai
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Benchmark & Memory Leak Tests - Run with MySQL8.0 and SQLite3
|
||||||
|
# =============================================================================
|
||||||
|
perf-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
mcp-everything:
|
||||||
|
image: yaoapp/mcp-everything:latest
|
||||||
|
ports:
|
||||||
|
- "3021:3021"
|
||||||
|
- "3022:3022"
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go: [1.24]
|
||||||
|
db: [MySQL8.0, SQLite3]
|
||||||
|
steps:
|
||||||
|
- name: Checkout Kun
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: ${{ env.REPO_KUN }}
|
||||||
|
path: kun
|
||||||
|
|
||||||
|
- name: Checkout Xun
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: ${{ env.REPO_XUN }}
|
||||||
|
path: xun
|
||||||
|
|
||||||
|
- name: Checkout Gou
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: ${{ env.REPO_GOU }}
|
||||||
|
path: gou
|
||||||
|
|
||||||
|
- name: Checkout V8Go
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: yaoapp/v8go
|
||||||
|
path: v8go
|
||||||
|
|
||||||
|
- name: Unzip libv8
|
||||||
|
run: |
|
||||||
|
files=$(find ./v8go -name "libv8*.zip")
|
||||||
|
for file in $files; do
|
||||||
|
dir=$(dirname "$file")
|
||||||
|
echo "Extracting $file to directory $dir"
|
||||||
|
unzip -o -d $dir $file
|
||||||
|
rm -rf $dir/__MACOSX
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Checkout Demo App
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: yaoapp/yao-dev-app
|
||||||
|
path: app
|
||||||
|
|
||||||
|
- name: Checkout Extension
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: yaoapp/yao-extensions-dev
|
||||||
|
path: extension
|
||||||
|
|
||||||
|
- name: Move Dependencies
|
||||||
|
run: |
|
||||||
|
mv kun ../
|
||||||
|
mv xun ../
|
||||||
|
mv gou ../
|
||||||
|
mv v8go ../
|
||||||
|
mv app ../
|
||||||
|
mv extension ../
|
||||||
|
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Go ${{ matrix.go }}
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
|
- name: Setup Go Tools
|
||||||
|
run: make tools
|
||||||
|
|
||||||
|
- name: Setup ${{ matrix.db }}
|
||||||
|
uses: ./.github/actions/setup-db
|
||||||
|
with:
|
||||||
|
kind: "${{ matrix.db }}"
|
||||||
|
db: "xiang"
|
||||||
|
user: "xiang"
|
||||||
|
password: ${{ secrets.UNIT_PASS }}
|
||||||
|
|
||||||
|
- name: Run Benchmark & Memory Leak Tests
|
||||||
|
run: |
|
||||||
|
make benchmark
|
||||||
|
make memory-leak
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Core Tests - Run with DB matrix (MySQL/SQLite/Redis/Mongo combinations)
|
# Core Tests - Run with DB matrix (MySQL/SQLite/Redis/Mongo combinations)
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
@ -315,7 +412,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [1.24]
|
go: [1.24]
|
||||||
db: [MySQL8.0, MySQL5.7, SQLite3]
|
db: [MySQL8.0, SQLite3]
|
||||||
redis: [4, 5, 6]
|
redis: [4, 5, 6]
|
||||||
mongo: ["6.0"]
|
mongo: ["6.0"]
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -488,10 +585,7 @@ jobs:
|
||||||
go run . inspect
|
go run . inspect
|
||||||
|
|
||||||
- name: Run Core Tests (exclude AI)
|
- name: Run Core Tests (exclude AI)
|
||||||
run: |
|
run: make unit-test-core
|
||||||
make unit-test-core
|
|
||||||
make benchmark
|
|
||||||
make memory-leak
|
|
||||||
|
|
||||||
- name: Codecov Report
|
- name: Codecov Report
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v4
|
||||||
|
|
|
||||||
6
Makefile
6
Makefile
|
|
@ -81,6 +81,12 @@ unit-test-ai:
|
||||||
if grep -q "^--- FAIL" tmp.out; then \
|
if grep -q "^--- FAIL" tmp.out; then \
|
||||||
rm tmp.out; \
|
rm tmp.out; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
|
elif grep -q "^FAIL" tmp.out; then \
|
||||||
|
rm tmp.out; \
|
||||||
|
exit 1; \
|
||||||
|
elif grep -q "^panic:" tmp.out; then \
|
||||||
|
rm tmp.out; \
|
||||||
|
exit 1; \
|
||||||
elif grep -q "build failed" tmp.out; then \
|
elif grep -q "build failed" tmp.out; then \
|
||||||
rm tmp.out; \
|
rm tmp.out; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue