123 lines
3.8 KiB
YAML
123 lines
3.8 KiB
YAML
# 只调度到你的 macOS 本机 agent(local/exec)
|
||
labels:
|
||
host: Mac-mini.local
|
||
platform: darwin/arm64
|
||
gpu: metal
|
||
|
||
when:
|
||
event: [push, manual, pull_request]
|
||
|
||
steps:
|
||
- name: env-info
|
||
image: /bin/zsh
|
||
commands:
|
||
- |
|
||
set -e
|
||
echo "PWD: $(pwd)"
|
||
echo "TMPDIR: ${TMPDIR:-unset}"
|
||
echo "Agent: ${CI_AGENT_NAME:-unknown}"
|
||
echo "Backend: ${CI_SYSTEM_BACKEND} Platform: ${CI_SYSTEM_PLATFORM}"
|
||
echo "PATH (runtime): $PATH"
|
||
which git || true
|
||
which git-lfs || true
|
||
git lfs version || true
|
||
sw_vers
|
||
xcodebuild -version || true
|
||
|
||
# 1) 四个工具自检
|
||
- name: tools-versions
|
||
image: /bin/zsh
|
||
commands:
|
||
- |
|
||
set -e
|
||
echo "[which]"
|
||
which woodpecker-cli || true
|
||
which plugin-git || true
|
||
which plugin-s3 || true
|
||
which plugin-docker-buildx || true
|
||
echo "[versions]"
|
||
woodpecker-cli --version || true
|
||
plugin-git --help | head -n1 || true
|
||
plugin-s3 --help | head -n1 || true
|
||
plugin-docker-buildx --help | head -n1 || true
|
||
|
||
# 2) Swift 原生小程序(证明在 macOS 本机执行)
|
||
- name: swift-hello
|
||
image: /bin/zsh
|
||
commands:
|
||
- |
|
||
set -e
|
||
cat > hello.swift <<'SWIFT'
|
||
print("Hello from Swift!")
|
||
SWIFT
|
||
swiftc hello.swift -o hello
|
||
./hello
|
||
|
||
# 3) (演示)plugin-git 可用性(clone 阶段已用过,这里只是确认二进制在 PATH)
|
||
- name: plugin-git-smoke
|
||
image: /bin/zsh
|
||
commands:
|
||
- |
|
||
set -e
|
||
echo "Smoketest plugin-git (help) ..."
|
||
plugin-git --help | head -n3
|
||
echo "Skip real clone: agent 已经把仓库拉到工作目录了."
|
||
|
||
# 4) S3 演示(有 AK/SK 就传;没有就跳过)
|
||
- name: s3-upload-demo
|
||
image: /bin/zsh
|
||
environment:
|
||
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
|
||
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
|
||
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
|
||
S3_BUCKET: ${S3_BUCKET}
|
||
S3_ENDPOINT: ${S3_ENDPOINT}
|
||
commands:
|
||
- |
|
||
set -e
|
||
if [[ -n "$AWS_ACCESS_KEY_ID" && -n "$AWS_SECRET_ACCESS_KEY" && -n "$S3_BUCKET" ]]; then
|
||
echo "Hello S3 from Woodpecker at $(date)" > s3-demo.txt
|
||
# plugin-s3 的环境变量(与容器版一致)
|
||
export PLUGIN_SOURCE="s3-demo.txt"
|
||
export PLUGIN_BUCKET="$S3_BUCKET"
|
||
export PLUGIN_TARGET="woodpecker-demo/"
|
||
[[ -n "$S3_ENDPOINT" ]] && export PLUGIN_ENDPOINT="$S3_ENDPOINT" && export PLUGIN_PATH_STYLE=true
|
||
plugin-s3
|
||
else
|
||
echo "No S3 creds found. Skipping s3-upload-demo."
|
||
fi
|
||
|
||
# 5) Docker Buildx 演示(装了 Docker 才跑;未装就跳过)
|
||
- name: docker-buildx-demo
|
||
image: /bin/zsh
|
||
commands:
|
||
- |
|
||
set -e
|
||
if command -v docker >/dev/null 2>&1; then
|
||
echo 'FROM alpine:3.20 AS base' > Dockerfile
|
||
echo 'RUN echo "hello" > /hello.txt' >> Dockerfile
|
||
export PLUGIN_CONTEXT="."
|
||
export PLUGIN_DOCKERFILE="Dockerfile"
|
||
export PLUGIN_TAGS="test:latest"
|
||
export PLUGIN_BUILDKIT_INLINE_CACHE=true
|
||
export PLUGIN_PUSH=false
|
||
plugin-docker-buildx
|
||
else
|
||
echo "Docker not found. Skipping docker-buildx-demo."
|
||
fi
|
||
|
||
# (可选)Podman 演示:你机器没有 Docker 但有 Podman 时
|
||
- name: podman-build-demo
|
||
image: /bin/zsh
|
||
commands:
|
||
- |
|
||
set -e
|
||
if command -v podman >/dev/null 2>&1; then
|
||
echo 'FROM alpine:3.20 AS base' > Dockerfile
|
||
echo 'RUN echo "hello with podman" > /hello.txt' >> Dockerfile
|
||
podman build -t local/test:latest .
|
||
podman image ls | grep 'local/test' || true
|
||
else
|
||
echo "Podman not found. Skipping podman-build-demo."
|
||
fi
|