Skip to content

Commit 3597655

Browse files
committed
ni
1 parent 27f478c commit 3597655

3 files changed

Lines changed: 289 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build 3rdparty — linux
2+
3+
# RISC-V Linux kernel (kernel-riscv64.bin).
4+
# Platform-independent — RISC-V binary regardless of build host.
5+
# Triggered on `lib-linux-<version>` tags. Version source of truth:
6+
# build-tools/3rdparty/linux/version.
7+
8+
on:
9+
push:
10+
tags:
11+
- 'lib-linux-*'
12+
workflow_dispatch: {}
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
resolve:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
version: ${{ steps.read.outputs.version }}
22+
tag: ${{ steps.read.outputs.tag }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
- id: read
26+
run: |
27+
set -euo pipefail
28+
V="$(tr -d '[:space:]' < build-tools/3rdparty/linux/version)"
29+
[ -n "$V" ] || { echo "version file is empty" >&2; exit 1; }
30+
if [[ "${{ github.event_name }}" == "push" ]]; then
31+
REF="${GITHUB_REF#refs/tags/}"
32+
EXPECT="lib-linux-$V"
33+
if [ "$REF" != "$EXPECT" ]; then
34+
echo "tag $REF does not match version file ($EXPECT)" >&2
35+
exit 1
36+
fi
37+
fi
38+
echo "version=$V" >> "$GITHUB_OUTPUT"
39+
echo "tag=lib-linux-$V" >> "$GITHUB_OUTPUT"
40+
41+
build:
42+
needs: resolve
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: install build deps
47+
run: |
48+
sudo apt-get update -y
49+
sudo apt-get install -y --no-install-recommends \
50+
build-essential curl tar \
51+
gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu \
52+
bc bison flex libssl-dev libelf-dev cpio rsync
53+
- name: build linux kernel tarball
54+
run: |
55+
mkdir -p out
56+
OUTPUT_DIR="$PWD/out" \
57+
CACHE_DIR="$PWD/.cache" \
58+
WORK_DIR="$PWD/.work" \
59+
bash build-tools/3rdparty/linux/_build.sh
60+
- uses: softprops/action-gh-release@v2
61+
with:
62+
tag_name: ${{ needs.resolve.outputs.tag }}
63+
files: out/linux-*.tar.gz
64+
fail_on_unmatched_files: true
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build 3rdparty — opensbi
2+
3+
# RISC-V SBI firmware (opensbi-fw_jump.elf + opensbi-fw_dynamic.bin).
4+
# Platform-independent — RISC-V binary regardless of build host.
5+
# Triggered on `lib-opensbi-<version>` tags. Version source of truth:
6+
# build-tools/3rdparty/opensbi/version.
7+
8+
on:
9+
push:
10+
tags:
11+
- 'lib-opensbi-*'
12+
workflow_dispatch: {}
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
resolve:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
version: ${{ steps.read.outputs.version }}
22+
tag: ${{ steps.read.outputs.tag }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
- id: read
26+
run: |
27+
set -euo pipefail
28+
V="$(tr -d '[:space:]' < build-tools/3rdparty/opensbi/version)"
29+
[ -n "$V" ] || { echo "version file is empty" >&2; exit 1; }
30+
if [[ "${{ github.event_name }}" == "push" ]]; then
31+
REF="${GITHUB_REF#refs/tags/}"
32+
EXPECT="lib-opensbi-$V"
33+
if [ "$REF" != "$EXPECT" ]; then
34+
echo "tag $REF does not match version file ($EXPECT)" >&2
35+
exit 1
36+
fi
37+
fi
38+
echo "version=$V" >> "$GITHUB_OUTPUT"
39+
echo "tag=lib-opensbi-$V" >> "$GITHUB_OUTPUT"
40+
41+
build:
42+
needs: resolve
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: install build deps
47+
run: |
48+
sudo apt-get update -y
49+
sudo apt-get install -y --no-install-recommends \
50+
build-essential curl tar \
51+
gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu
52+
- name: build opensbi tarball
53+
run: |
54+
mkdir -p out
55+
OUTPUT_DIR="$PWD/out" \
56+
CACHE_DIR="$PWD/.cache" \
57+
WORK_DIR="$PWD/.work" \
58+
bash build-tools/3rdparty/opensbi/_build.sh
59+
- uses: softprops/action-gh-release@v2
60+
with:
61+
tag_name: ${{ needs.resolve.outputs.tag }}
62+
files: out/opensbi-*.tar.gz
63+
fail_on_unmatched_files: true
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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

Comments
 (0)