|
| 1 | +name: Rockchip Cross Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - '.dockerignore' |
| 7 | + - '.github/workflows/ci-build-rockchip.yml' |
| 8 | + - 'Dockerfile.rockchip' |
| 9 | + - 'Dockerfile.rockchip.dockerignore' |
| 10 | + - 'Dockerfile.rk3576' |
| 11 | + - 'docker-compose.rockchip.yml' |
| 12 | + - 'docker-compose.rk3576.yml' |
| 13 | + - 'config/rknn/**' |
| 14 | + - 'config/rockchip-build/**' |
| 15 | + - 'config/rockchip-media/**' |
| 16 | + - 'cmake/**' |
| 17 | + - 'data/resource/aiboxresource_rknn/**' |
| 18 | + - 'scripts/**' |
| 19 | + - 'src/**' |
| 20 | + - 'test/**' |
| 21 | + - 'tools/rknn/**' |
| 22 | + - 'CMakeLists.txt' |
| 23 | + push: |
| 24 | + branches: [main] |
| 25 | + paths: |
| 26 | + - '.dockerignore' |
| 27 | + - '.github/workflows/ci-build-rockchip.yml' |
| 28 | + - 'Dockerfile.rockchip' |
| 29 | + - 'Dockerfile.rockchip.dockerignore' |
| 30 | + - 'Dockerfile.rk3576' |
| 31 | + - 'docker-compose.rockchip.yml' |
| 32 | + - 'docker-compose.rk3576.yml' |
| 33 | + - 'config/rknn/platforms/**' |
| 34 | + - 'config/rockchip-build/**' |
| 35 | + - 'config/rockchip-media/**' |
| 36 | + - 'scripts/install_rkllm_sdk.py' |
| 37 | + - 'tools/rknn/media_sysroot_lock.py' |
| 38 | + schedule: |
| 39 | + # Run daily at 02:12 Beijing Time (18:12 UTC on the previous day). |
| 40 | + - cron: '12 18 * * *' |
| 41 | + workflow_dispatch: |
| 42 | + workflow_call: |
| 43 | + |
| 44 | +permissions: |
| 45 | + contents: read |
| 46 | + |
| 47 | +concurrency: |
| 48 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 49 | + cancel-in-progress: true |
| 50 | + |
| 51 | +jobs: |
| 52 | + package: |
| 53 | + name: rockchip-package (${{ matrix.chip }}) |
| 54 | + runs-on: ubuntu-latest |
| 55 | + timeout-minutes: 120 |
| 56 | + strategy: |
| 57 | + fail-fast: false |
| 58 | + matrix: |
| 59 | + include: |
| 60 | + - chip: rk3576 |
| 61 | + models: include |
| 62 | + - chip: rv1126b |
| 63 | + models: preserve |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Checkout code |
| 67 | + uses: actions/checkout@v7 |
| 68 | + with: |
| 69 | + submodules: recursive |
| 70 | + |
| 71 | + - name: Validate Rockchip package policy tooling |
| 72 | + run: | |
| 73 | + bash -n scripts/build_rknn.sh scripts/build_rockchip_package.sh |
| 74 | + python3 -m unittest discover -s test -p 'test_package_profile.py' |
| 75 | + python3 -m unittest discover -s test/agent \ |
| 76 | + -p 'test_rknn_media_sysroot_lock.py' |
| 77 | +
|
| 78 | + - name: Set up Docker Buildx |
| 79 | + uses: docker/setup-buildx-action@v3 |
| 80 | + |
| 81 | + - name: Build locked Rockchip builder |
| 82 | + uses: docker/build-push-action@v6 |
| 83 | + with: |
| 84 | + context: . |
| 85 | + file: Dockerfile.rockchip |
| 86 | + target: rockchip-builder |
| 87 | + platforms: linux/amd64 |
| 88 | + load: true |
| 89 | + tags: cosmo-edge-build-env-rockchip:ci |
| 90 | + provenance: false |
| 91 | + cache-from: type=gha,scope=rockchip-builder-${{ matrix.chip }} |
| 92 | + cache-to: type=gha,mode=max,scope=rockchip-builder-${{ matrix.chip }} |
| 93 | + |
| 94 | + - name: Validate shared Compose entry |
| 95 | + env: |
| 96 | + COSMO_ROCKCHIP_BUILDER_IMAGE: cosmo-edge-build-env-rockchip:ci |
| 97 | + COSMO_TARGET_CHIP: ${{ matrix.chip }} |
| 98 | + COSMO_PACKAGE_MODELS: ${{ matrix.models }} |
| 99 | + run: docker compose -f docker-compose.rockchip.yml config --quiet |
| 100 | + |
| 101 | + - name: Build target package and tests |
| 102 | + env: |
| 103 | + COSMO_ROCKCHIP_BUILDER_IMAGE: cosmo-edge-build-env-rockchip:ci |
| 104 | + COSMO_TARGET_CHIP: ${{ matrix.chip }} |
| 105 | + COSMO_PACKAGE_MODELS: ${{ matrix.models }} |
| 106 | + run: docker compose -f docker-compose.rockchip.yml run --rm cosmo-rockchip-package |
| 107 | + |
| 108 | + - name: Verify target artifacts |
| 109 | + env: |
| 110 | + CHIP: ${{ matrix.chip }} |
| 111 | + run: | |
| 112 | + set -euo pipefail |
| 113 | + shopt -s nullglob |
| 114 | + packages=("build_output/${CHIP}"/cosmo-*.tar.gz) |
| 115 | + if (( ${#packages[@]} != 1 )) || [[ ! -f "${packages[0]:-}" || -L "${packages[0]:-}" ]]; then |
| 116 | + echo "Expected exactly one regular ${CHIP} package artifact." >&2 |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | + package="${packages[0]}" |
| 120 | + package_name="${package##*/}" |
| 121 | + digest="$(sha256sum -- "$package")" |
| 122 | + digest="${digest%% *}" |
| 123 | + printf '%s %s\n' "$digest" "$package_name" | tee "${CHIP}-package.sha256" |
| 124 | + cmp -s <(printf '%s\n' "$CHIP") "build_output/${CHIP}/TARGET_CHIP" |
| 125 | + (cd "build_output/${CHIP}" && sha256sum -c SHA256SUMS) |
| 126 | + for binary in build_rknn/cosmo-tests build_rknn/cosmo-rknn-backend-smoke build_rknn/cosmo-rknn-fastpath-qualify; do |
| 127 | + binary_info="$(file "$binary")" |
| 128 | + printf '%s\n' "$binary_info" |
| 129 | + grep -Fq 'ARM aarch64' <<< "$binary_info" |
| 130 | + done |
| 131 | + printf "## %s candidate\n\n- Package: \`%s\`\n- SHA-256: \`%s\`\n" \ |
| 132 | + "$CHIP" "$package_name" "$digest" >> "$GITHUB_STEP_SUMMARY" |
| 133 | +
|
| 134 | + - name: Upload target candidate |
| 135 | + uses: actions/upload-artifact@v7 |
| 136 | + with: |
| 137 | + name: ${{ matrix.chip }}-candidate-${{ github.sha }} |
| 138 | + path: | |
| 139 | + build_output/${{ matrix.chip }}/*.tar.gz |
| 140 | + build_output/${{ matrix.chip }}/TARGET_CHIP |
| 141 | + build_output/${{ matrix.chip }}/MEDIA_RUNTIME_PROFILE |
| 142 | + build_output/${{ matrix.chip }}/SHA256SUMS |
| 143 | + ${{ matrix.chip }}-package.sha256 |
| 144 | + build_rknn/cosmo-tests |
| 145 | + build_rknn/cosmo-rknn-backend-smoke |
| 146 | + build_rknn/cosmo-rknn-fastpath-qualify |
| 147 | + if-no-files-found: error |
| 148 | + overwrite: true |
| 149 | + retention-days: 7 |
| 150 | + |
| 151 | + publish-builder: |
| 152 | + name: publish-rockchip-builder |
| 153 | + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' |
| 154 | + needs: package |
| 155 | + runs-on: ubuntu-latest |
| 156 | + timeout-minutes: 60 |
| 157 | + permissions: |
| 158 | + contents: read |
| 159 | + packages: write |
| 160 | + |
| 161 | + steps: |
| 162 | + - name: Checkout code |
| 163 | + uses: actions/checkout@v7 |
| 164 | + |
| 165 | + - name: Set up Docker Buildx |
| 166 | + uses: docker/setup-buildx-action@v3 |
| 167 | + |
| 168 | + - name: Log in to GHCR |
| 169 | + uses: docker/login-action@v3 |
| 170 | + with: |
| 171 | + registry: ghcr.io |
| 172 | + username: ${{ github.actor }} |
| 173 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 174 | + |
| 175 | + - name: Define immutable and stable tags |
| 176 | + id: metadata |
| 177 | + uses: docker/metadata-action@v5 |
| 178 | + with: |
| 179 | + images: ghcr.io/cosmo-wander-ai/cosmo_edge-build-env_rockchip |
| 180 | + tags: | |
| 181 | + type=sha,format=long |
| 182 | + type=raw,value=v1,enable={{is_default_branch}} |
| 183 | +
|
| 184 | + - name: Publish locked Rockchip builder |
| 185 | + id: publish |
| 186 | + uses: docker/build-push-action@v6 |
| 187 | + with: |
| 188 | + context: . |
| 189 | + file: Dockerfile.rockchip |
| 190 | + target: rockchip-builder |
| 191 | + platforms: linux/amd64 |
| 192 | + push: true |
| 193 | + tags: ${{ steps.metadata.outputs.tags }} |
| 194 | + labels: ${{ steps.metadata.outputs.labels }} |
| 195 | + provenance: false |
| 196 | + cache-from: type=gha,scope=rockchip-builder-publish |
| 197 | + cache-to: type=gha,mode=max,scope=rockchip-builder-publish |
| 198 | + |
| 199 | + - name: Record published digest |
| 200 | + env: |
| 201 | + PUBLISHED_DIGEST: ${{ steps.publish.outputs.digest }} |
| 202 | + run: | |
| 203 | + printf "## Shared Rockchip builder\n\n- Digest: \`%s\`\n" \ |
| 204 | + "$PUBLISHED_DIGEST" >> "$GITHUB_STEP_SUMMARY" |
0 commit comments