|
| 1 | +name: Deploy yaafc-yemu browser demo to GitHub Pages |
| 2 | + |
| 3 | +# Builds the full yaafc-yemu wasm demo and publishes it to GitHub Pages |
| 4 | +# under the repository's Pages site. The deployed page boots a riscv64 |
| 5 | +# Alpine VM in the visitor's browser via TinyEMU wasm, with the yaafc |
| 6 | +# mesh (gateway + 11 backends) launching inside that VM. No yetty |
| 7 | +# dependency — kernel + opensbi are built from this repo's 3rdparty |
| 8 | +# recipes, alpine minirootfs comes straight from dl-cdn.alpinelinux.org. |
| 9 | +# |
| 10 | +# Trigger: every push to main, plus manual dispatch. First run takes |
| 11 | +# ~15 minutes (linux kernel build); subsequent runs reuse the cached |
| 12 | +# 3rdparty tarballs. |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - main |
| 18 | + paths: |
| 19 | + # Skip Pages deploy when only docs change. |
| 20 | + - 'CMakeLists.txt' |
| 21 | + - 'Makefile' |
| 22 | + - 'include/**' |
| 23 | + - 'src/**' |
| 24 | + - 'build-tools/**' |
| 25 | + - 'scenarios/git-yaafc/**' |
| 26 | + - '.github/workflows/deploy-yaafc-yemu-demo.yml' |
| 27 | + workflow_dispatch: {} |
| 28 | + |
| 29 | +# Concurrency: skip in-flight runs when a newer push arrives. Pages |
| 30 | +# itself only allows one in-flight deploy per env. |
| 31 | +concurrency: |
| 32 | + group: pages |
| 33 | + cancel-in-progress: false |
| 34 | + |
| 35 | +permissions: |
| 36 | + contents: read |
| 37 | + pages: write |
| 38 | + id-token: write |
| 39 | + |
| 40 | +env: |
| 41 | + # 64 MiB rootfs — alpine minirootfs (~8 MiB) + yaafc static binary |
| 42 | + # (~7 MiB) + 49 MiB free space for runtime sqlite/mdbx state. Keeps |
| 43 | + # the wasm asset under the 100 MiB GitHub Pages soft limit. |
| 44 | + DISK_MIB: 64 |
| 45 | + |
| 46 | +jobs: |
| 47 | + build: |
| 48 | + name: build |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + with: |
| 53 | + # We don't depend on history (no submodules); a shallow |
| 54 | + # clone is enough. |
| 55 | + fetch-depth: 1 |
| 56 | + |
| 57 | + - name: install build deps |
| 58 | + run: | |
| 59 | + sudo apt-get update -y |
| 60 | + sudo apt-get install -y --no-install-recommends \ |
| 61 | + build-essential cmake ninja-build \ |
| 62 | + gcc-riscv64-linux-gnu g++-riscv64-linux-gnu binutils-riscv64-linux-gnu \ |
| 63 | + qemu-system-misc qemu-utils \ |
| 64 | + e2fsprogs util-linux curl tar python3 \ |
| 65 | + bc bison flex libssl-dev libelf-dev cpio rsync |
| 66 | +
|
| 67 | + - name: install emsdk |
| 68 | + uses: mymindstorm/setup-emsdk@v14 |
| 69 | + with: |
| 70 | + version: 3.1.74 |
| 71 | + actions-cache-folder: 'emsdk-cache-3.1.74' |
| 72 | + |
| 73 | + # ----- caches ----- |
| 74 | + # Recipe-tarball cache. Keyed on the version files of each |
| 75 | + # recipe so a bump invalidates exactly what changed, nothing |
| 76 | + # else. The user-cache (~/.cache/yaafc-3rdparty) holds source |
| 77 | + # tarballs (linux-7.0.tar.gz, opensbi-v1.4.tar.gz) — those |
| 78 | + # don't change unless the version bumps. |
| 79 | + - name: cache 3rdparty tarballs (~/.cache/yaafc-3rdparty) |
| 80 | + uses: actions/cache@v4 |
| 81 | + with: |
| 82 | + path: ~/.cache/yaafc-3rdparty |
| 83 | + key: yaafc-3rdparty-cache-v1-${{ hashFiles('build-tools/3rdparty/*/version', 'build-tools/3rdparty/*/_build.sh', 'build-tools/3rdparty/linux/linux-kernel-*.config') }} |
| 84 | + restore-keys: | |
| 85 | + yaafc-3rdparty-cache-v1- |
| 86 | +
|
| 87 | + # Built 3rdparty outputs (already extracted, ready to use). |
| 88 | + # Same cache key as above — if the user-cache hits, this hits |
| 89 | + # too and we skip the actual build step. |
| 90 | + - name: cache built 3rdparty (build-yemu-release/3rdparty + 3rdparty-cache) |
| 91 | + uses: actions/cache@v4 |
| 92 | + with: |
| 93 | + path: | |
| 94 | + build-yemu-release/3rdparty |
| 95 | + build-yemu-release/3rdparty-cache |
| 96 | + key: yaafc-yemu-3rdparty-build-v1-${{ hashFiles('build-tools/3rdparty/*/version', 'build-tools/3rdparty/*/_build.sh', 'build-tools/3rdparty/linux/linux-kernel-*.config') }} |
| 97 | + |
| 98 | + # ----- yaafc host + cross builds ----- |
| 99 | + - name: build yaafc host (build-desktop-release) |
| 100 | + run: make build-desktop-release |
| 101 | + |
| 102 | + - name: build yaafc riscv64 (build-linux-riscv64-release) |
| 103 | + run: make build-linux-riscv64-release |
| 104 | + |
| 105 | + - name: stage build-deploy/ |
| 106 | + run: make build-deploy |
| 107 | + |
| 108 | + # ----- yemu rootfs (this triggers the local linux+opensbi recipes |
| 109 | + # AND fetches alpine minirootfs from alpinelinux.org) ----- |
| 110 | + - name: bake yemu rootfs |
| 111 | + run: | |
| 112 | + # sudo on GitHub-hosted runners is passwordless for the |
| 113 | + # runner user — losetup + mount work without prompting. |
| 114 | + make build-yemu-release |
| 115 | +
|
| 116 | + - name: shrink alpine-rootfs.img |
| 117 | + run: | |
| 118 | + # The image was created with truncate -s ${DISK_MIB} MiB; if |
| 119 | + # the actual content is smaller we can shrink to fit and |
| 120 | + # keep the deployed asset small. |
| 121 | + IMG=build-yemu-release/alpine-rootfs.img |
| 122 | + sudo e2fsck -fy "$IMG" || true |
| 123 | + sudo resize2fs -M "$IMG" || true |
| 124 | + # Truncate trailing zero pages so the wire size matches the |
| 125 | + # actual ext4 footprint. |
| 126 | + BLOCKS=$(sudo dumpe2fs -h "$IMG" 2>/dev/null \ |
| 127 | + | awk '/Block count/ {print $3}') |
| 128 | + BSIZE=$(sudo dumpe2fs -h "$IMG" 2>/dev/null \ |
| 129 | + | awk '/Block size/ {print $3}') |
| 130 | + SIZE=$(( BLOCKS * BSIZE )) |
| 131 | + echo "shrinking to ${SIZE} bytes (${BLOCKS} blocks @ ${BSIZE}B)" |
| 132 | + truncate -s "$SIZE" "$IMG" |
| 133 | + ls -lh "$IMG" |
| 134 | +
|
| 135 | + # ----- webasm bundle ----- |
| 136 | + - name: build wasm bundle |
| 137 | + run: make build-webasm-yemu-release |
| 138 | + |
| 139 | + - name: list deploy contents |
| 140 | + run: | |
| 141 | + du -sh build-webasm-yemu-release/ |
| 142 | + ls -lh build-webasm-yemu-release/ |
| 143 | + ls -lh build-webasm-yemu-release/assets/ |
| 144 | +
|
| 145 | + # ----- Pages deploy ----- |
| 146 | + - uses: actions/configure-pages@v5 |
| 147 | + |
| 148 | + - name: upload Pages artifact |
| 149 | + uses: actions/upload-pages-artifact@v3 |
| 150 | + with: |
| 151 | + path: build-webasm-yemu-release |
| 152 | + |
| 153 | + deploy: |
| 154 | + name: deploy |
| 155 | + needs: build |
| 156 | + runs-on: ubuntu-latest |
| 157 | + environment: |
| 158 | + name: github-pages |
| 159 | + url: ${{ steps.deployment.outputs.page_url }} |
| 160 | + steps: |
| 161 | + - id: deployment |
| 162 | + uses: actions/deploy-pages@v4 |
0 commit comments