Skip to content

Commit 86d9732

Browse files
committed
CI build mode for WASM runtime artifact
1 parent fc6625b commit 86d9732

File tree

3 files changed

+69
-25
lines changed

3 files changed

+69
-25
lines changed

.github/actions/plan/modes.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type Mode = {
44
cargoArgs: string;
55
cargoCacheKey: string;
66
platformIndependent?: true;
7+
artifactSelector?: "peer" | "runtime" | "runtime-evm-tracing";
78
};
89

910
export type Modes = Record<string, Mode>;
@@ -63,10 +64,28 @@ export const code = {
6364
} satisfies Modes;
6465

6566
export const build = {
66-
build: {
67-
name: "build",
67+
buildPeer: {
68+
name: "build peer",
6869
cargoCommand: "build",
6970
cargoArgs: "--locked --workspace --release",
7071
cargoCacheKey: "release-build",
72+
artifactSelector: "peer",
73+
},
74+
// buildRuntime: {
75+
// name: "build runtime",
76+
// cargoCommand: "build",
77+
// cargoArgs: "--locked --workspace --release --package humanode-runtime",
78+
// cargoCacheKey: "runtime",
79+
// platformIndependent: true,
80+
// artifactSelector: "runtime",
81+
// },
82+
buildRuntimeEvmTracing: {
83+
name: "build runtime with EVM tracing",
84+
cargoCommand: "build",
85+
cargoArgs:
86+
"--locked --workspace --release --package humanode-runtime --features evm-tracing",
87+
cargoCacheKey: "runtime-evm-tracing",
88+
platformIndependent: true,
89+
artifactSelector: "runtime-evm-tracing",
7190
},
7291
} satisfies Modes;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
RUNTIME_PATH='target/release/wbuild/humanode-runtime/humanode_runtime.compact.compressed.wasm'
5+
6+
case "$ARTIFACT_SELECTOR" in
7+
peer)
8+
ARTIFACT_PATH='target/release/humanode-peer'
9+
ARTIFACT_NAME="humanode-peer-$(rustc -vV | sed -n 's|host: ||p')"
10+
11+
if [[ "$PLATFORM_ARTIFACT_MARKER" != "" ]]; then
12+
ARTIFACT_NAME="${ARTIFACT_NAME}-${PLATFORM_ARTIFACT_MARKER}"
13+
fi
14+
15+
if [[ "${PATHEXT:-""}" != "" ]]; then
16+
ARTIFACT_PATH="${ARTIFACT_PATH}.exe"
17+
fi
18+
;;
19+
20+
runtime)
21+
ARTIFACT_PATH="$RUNTIME_PATH"
22+
ARTIFACT_NAME='humanode-runtime.wasm'
23+
;;
24+
25+
runtime-evm-tracing)
26+
ARTIFACT_PATH="$RUNTIME_PATH"
27+
ARTIFACT_NAME='humanode-runtime-evm-tracing.wasm'
28+
;;
29+
30+
*)
31+
printf 'Unknown artifact selector `%s`\n' "$ARTIFACT_SELECTOR" >&2
32+
exit 1
33+
;;
34+
esac
35+
36+
printf 'artifact-path=%s\n' "$ARTIFACT_PATH" >> "$GITHUB_OUTPUT"
37+
printf 'artifact-name=%s\n' "$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
38+
39+
printf 'Packaged `%s` into `%s`.\n' \
40+
"$ARTIFACT_PATH" \
41+
"$ARTIFACT_NAME" \
42+
>> "$GITHUB_STEP_SUMMARY"

.github/workflows/build.yml

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,39 +97,22 @@ jobs:
9797
id: set-upload-params
9898
env:
9999
PLATFORM_ARTIFACT_MARKER: ${{ matrix.plan.platform.artifactMarker }}
100-
run: |
101-
EXECUTABLE_PATH="target/release/humanode-peer"
102-
ARTIFACT_NAME="humanode-peer-$(rustc -vV | sed -n 's|host: ||p')"
100+
ARTIFACT_SELECTOR: ${{ matrix.plan.mode.artifactSelector }}
101+
run: .github/scripts/artifact-upload-params.sh
103102

104-
if [[ "$PLATFORM_ARTIFACT_MARKER" != "" ]]; then
105-
ARTIFACT_NAME="${ARTIFACT_NAME}-${PLATFORM_ARTIFACT_MARKER}"
106-
fi
107-
108-
if [[ "${PATHEXT:-""}" != "" ]]; then
109-
EXECUTABLE_PATH="${EXECUTABLE_PATH}.exe"
110-
fi
111-
112-
printf 'executable-path=%s\n' "$EXECUTABLE_PATH" >> "$GITHUB_OUTPUT"
113-
printf 'artifact-name=%s\n' "$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
114-
115-
printf 'Packaged `%s` into `%s`.\n' \
116-
"$EXECUTABLE_PATH" \
117-
"$ARTIFACT_NAME" \
118-
>> "$GITHUB_STEP_SUMMARY"
119-
120-
- name: Upload artifact
103+
- name: Upload
121104
uses: actions/upload-artifact@v4
122105
with:
123106
name: ${{ steps.set-upload-params.outputs.artifact-name }}
124-
path: ${{ steps.set-upload-params.outputs.executable-path }}
107+
path: ${{ steps.set-upload-params.outputs.artifact-path }}
125108
if-no-files-found: error
126109
retention-days: 5
127110

128111
- name: Archive the binary for release
129112
if: startsWith(github.ref, 'refs/tags/')
130113
env:
131-
EXECUTABLE_NAME: ${{ steps.set-upload-params.outputs.executable-path }}
132-
run: utils/make-release-archive "$EXECUTABLE_NAME" archive.tar.gz
114+
ARTIFACT_PATH: ${{ steps.set-upload-params.outputs.artifact-path }}
115+
run: utils/make-release-archive "$ARTIFACT_PATH" archive.tar.gz
133116

134117
- name: Upload release archive
135118
uses: shogo82148/actions-upload-release-asset@v1

0 commit comments

Comments
 (0)