啟動測試:CLI 可執行 (Engine Load) #1
This file contains hidden or 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: Test Docker Image (Run) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| image: | |
| description: | | |
| Image name (directory name under images/). | |
| required: true | |
| type: choice | |
| options: | |
| - py-devkit-image-base | |
| - all | |
| tag: | |
| description: | | |
| Image tag to test (default: latest). | |
| Ignored when image=all (always uses :latest). | |
| required: false | |
| default: 'latest' | |
| env: | |
| REGISTRY: ghcr.io | |
| ORG: shumingyang-opencode | |
| jobs: | |
| discover: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.discover.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - id: discover | |
| run: | | |
| if [ "all" = "${{ inputs.image }}" ]; then | |
| FIRST=true | |
| JSON='{"image":[' | |
| for dir in images/*/; do | |
| name=$(basename "$dir") | |
| [ -f "images/$name/Dockerfile" ] || continue | |
| [ -f "images/$name/test-run.sh" ] || continue | |
| if [ "$FIRST" = true ]; then | |
| JSON="$JSON\"$name\"" | |
| FIRST=false | |
| else | |
| JSON="$JSON,\"$name\"" | |
| fi | |
| done | |
| JSON="$JSON]}" | |
| echo "matrix=$JSON" >> "$GITHUB_OUTPUT" | |
| else | |
| if [ ! -f "images/${{ inputs.image }}/test-run.sh" ]; then | |
| echo "Error: no test-run.sh found for ${{ inputs.image }}" | |
| exit 1 | |
| fi | |
| echo "matrix={\"image\":[\"${{ inputs.image }}\"]}" >> "$GITHUB_OUTPUT" | |
| fi | |
| run-test: | |
| needs: discover | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| strategy: | |
| matrix: ${{ fromJSON(needs.discover.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull and run tests | |
| run: | | |
| TAG="${{ inputs.tag }}" | |
| if [ "${{ inputs.image }}" = "all" ]; then | |
| TAG="latest" | |
| fi | |
| IMAGE="${{ env.REGISTRY }}/${{ env.ORG }}/${{ matrix.image }}:${TAG}" | |
| docker pull "$IMAGE" | |
| docker run --rm -i "$IMAGE" bash < images/${{ matrix.image }}/test-run.sh |