Skip to content

Test Incus Images

Test Incus Images #397

Workflow file for this run

name: Image Validation Pipeline
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
generate_matrix:
runs-on: ubuntu-latest
outputs:
images: ${{ steps.set-matrix.outputs.images }}
steps:
- name: Generate Image List
id: set-matrix
run: |
# 下载镜像列表
for arch in x86_64 arm64; do
curl -sL "https://raw.githubusercontent.com/oneclickvirt/incus_images/main/${arch}_all_images.txt" >> all_images.txt || echo "下载 $arch 列表失败"
done
# 过滤空行并去重
if [ -f all_images.txt ]; then
images=$(grep -v '^$' all_images.txt | sort -u | tr '\n' ',' | sed 's/,$//')
echo "images=${images}" >> $GITHUB_OUTPUT
else
echo "::error::未能获取镜像列表"
exit 1
fi
validate_images:
needs: generate_matrix
if: needs.generate_matrix.outputs.images != ''
strategy:
fail-fast: false
matrix:
image: ${{ split(needs.generate_matrix.outputs.images, ',') }}

Check failure on line 37 in .github/workflows/test.yml

View workflow run for this annotation

GitHub Actions / Image Validation Pipeline

Invalid workflow file

The workflow is not valid. .github/workflows/test.yml (Line: 37, Col: 16): Unrecognized function: 'split'. Located at position 1 within expression: split(needs.generate_matrix.outputs.images, ',') .github/workflows/test.yml (Line: 37, Col: 16): Unexpected value '${{ split(needs.generate_matrix.outputs.images, ',') }}'
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Initialize Incus Environment
run: |
sudo apt-get update
sudo apt-get install -y zfsutils-linux snapd curl
sudo snap install --channel=latest/stable incus
sudo incus admin init --auto --storage-backend=dir
sudo incus network set incusbr0 ipv6.address=none
incus --version
- name: Execute Validation Test
id: test
run: |
if [ ! -f "test.sh" ]; then
echo "::error::测试脚本不存在"
exit 1
fi
chmod +x test.sh
safe_name=$(echo "${{ matrix.image }}" | sed 's/[^a-zA-Z0-9]/_/g')
result_file="${safe_name}_validation.txt"
if sudo ./test.sh "${{ matrix.image }}" > >(tee -a "$result_file") 2>&1; then
echo "✅ 验证成功:${{ matrix.image }}"
echo "${{ matrix.image }}" > "$result_file"
else
echo "❌ 验证失败:${{ matrix.image }}"
exit 1
fi
timeout-minutes: 30
- name: Preserve Test Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: validation-${{ matrix.image }}
path: |
*_validation.txt
log
retention-days: 3
aggregate_results:
needs: validate_images
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Collect Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate Consolidated Report
run: |
mkdir -p results
touch results/x86_64_valid.txt results/arm64_valid.txt
find artifacts -name '*validation.txt' -type f | while read -r file; do
if ! grep -q '❌' "$file"; then
cat "$file" | grep -v '^$' >> valid_images.tmp
fi
done
if [ -f valid_images.tmp ]; then
sort -u valid_images.tmp > valid_images.txt
grep 'x86_64' valid_images.txt > results/x86_64_valid.txt || true
grep 'arm64' valid_images.txt > results/arm64_valid.txt || true
rm valid_images.tmp
fi
{
echo "# 每日镜像验证报告"
echo "生成时间: $(date +'%Y-%m-%d %H:%M:%S %Z')"
echo
echo "## 有效镜像统计"
echo "- x86_64 镜像数量: $(wc -l < results/x86_64_valid.txt)"
echo "- arm64 镜像数量: $(wc -l < results/arm64_valid.txt)"
echo
echo "## 详细列表"
echo "### x86_64 有效镜像"
echo '```'
cat results/x86_64_valid.txt
echo '```'
echo
echo "### arm64 有效镜像"
echo '```'
cat results/arm64_valid.txt
echo '```'
} > REPORT.md
- name: Upload Validation Results
uses: actions/upload-artifact@v4
with:
name: validation-results
path: |
results/*
REPORT.md
log
- name: Commit to Repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "自动更新验证结果 [skip ci]"
file_pattern: |
results/*_valid.txt
REPORT.md
branch: main