Run LXD Tests #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run LXD Tests | |
on: | |
schedule: | |
- cron: '0 4 2-30/2 * *' | |
workflow_dispatch: | |
jobs: | |
prepare-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: set-matrix | |
run: | | |
# 下载两个平台的镜像列表 | |
curl -o x86_64_all_images.txt https://raw.githubusercontent.com/oneclickvirt/lxd_images/main/x86_64_all_images.txt | |
curl -o arm64_all_images.txt https://raw.githubusercontent.com/oneclickvirt/lxd_images/main/arm64_all_images.txt | |
echo "构建测试矩阵..." | |
matrix_json="{\"include\":[" | |
while IFS= read -r image; do | |
if [[ -n "$image" ]]; then | |
matrix_json+="{\"image\":\"$image\",\"arch\":\"amd64\",\"runner\":\"ubuntu-latest\"}," | |
fi | |
done < x86_64_all_images.txt | |
while IFS= read -r image; do | |
if [[ -n "$image" ]]; then | |
matrix_json+="{\"image\":\"$image\",\"arch\":\"arm64\",\"runner\":\"ubuntu-24.04-arm\"}," | |
fi | |
done < arm64_all_images.txt | |
# 去掉最后一个逗号 | |
matrix_json=${matrix_json%,} | |
matrix_json+="]}" | |
echo "matrix=$matrix_json" >> "$GITHUB_OUTPUT" | |
test-single-image: | |
needs: prepare-matrix | |
strategy: | |
fail-fast: false | |
max-parallel: 12 | |
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} | |
runs-on: ${{ matrix.runner }} | |
timeout-minutes: 7 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Fresh Environment | |
run: | | |
echo "设置新环境..." | |
sudo apt-get update -y | |
sudo sh -c 'export noninteractive=true; curl -L https://raw.githubusercontent.com/oneclickvirt/lxd/main/scripts/lxdinstall.sh -o lxdinstall.sh && chmod +x lxdinstall.sh && bash lxdinstall.sh >/dev/null 2>&1' | |
- name: Configure Git | |
run: | | |
git config --global user.name "daily-test" | |
git config --global user.email "[email protected]" | |
- name: Test Image | |
run: | | |
echo "测试镜像: ${{ matrix.image }}" | |
if sudo bash test.sh "${{ matrix.image }}"; then | |
echo "测试通过: ${{ matrix.image }}" | |
echo "success=true" | |
else | |
echo "测试失败: ${{ matrix.image }}" | |
echo "success=false" | |
fi | |
echo "image=${{ matrix.image }}" | |
echo "arch=${{ matrix.arch }}" |