Skip to content

Commit f679f44

Browse files
aurexavfewensa
andauthored
CI Maintenance (#1683)
* CI Maintenance Signed-off-by: Xavier Lau <[email protected]> * Update .github/note-template/runtime.md Co-authored-by: fewensa <[email protected]> --------- Signed-off-by: Xavier Lau <[email protected]> Co-authored-by: fewensa <[email protected]>
1 parent d1852f0 commit f679f44

File tree

3 files changed

+68
-80
lines changed

3 files changed

+68
-80
lines changed

.github/actions/build/action.yml

+26-49
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
1-
name: "Build darwinia node"
1+
name: "Build Darwinia node"
22

33
description: "Darwinia artifacts building action."
44

55
inputs:
66
features:
77
description: "build features"
8+
required: true
9+
enable_tar_bz2:
10+
description: "enable package tar.bz2"
811
required: false
9-
default: ""
12+
default: "false"
1013
suffix:
1114
description: "output file suffix"
1215
required: false
1316
default: ""
14-
enable_cache:
15-
description: "enable cache"
16-
required: false
17-
default: "false"
18-
cache_shrink_script:
19-
description: "shrink cache script file path"
20-
required: false
21-
default: ".github/shrink-cache.sh"
22-
enable_tar_bz2:
23-
description: "enable package tar.bz2"
24-
required: false
25-
default: "false"
2617
skip-build:
2718
description: "use this for testing purposes only"
2819
required: false
@@ -38,51 +29,37 @@ runs:
3829
context: .
3930
file: .maintain/docker/ubuntu:20.04.Dockerfile
4031
tags: darwinia-network/build-tool:latest
41-
- name: Cache cargo
42-
if: ${{ inputs.enable_cache == 'true' && inputs.skip-build != 'true' }}
43-
uses: actions/cache@v3
44-
with:
45-
path: |
46-
./target
47-
key: darwinia-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('Cargo.lock') }}
48-
restore-keys: |
49-
darwinia-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}-
50-
darwinia-${{ runner.os }}-
32+
5133
- name: Build node
5234
shell: bash
5335
run: |
54-
FEATURES=${{ inputs.features }}
55-
SUFFIX=${{ inputs.suffix }}
56-
ENABLE_TAR_BZ2=${{ inputs.enable_tar_bz2 }}
57-
SKIP_BUILD=${{ inputs.skip-build }}
36+
set -euxo pipefail
37+
38+
FEATURES="${{ inputs.features }}"
39+
SUFFIX="${{ inputs.suffix }}"
40+
ENABLE_TAR_BZ2="${{ inputs.enable_tar_bz2 }}"
41+
SKIP_BUILD="${{ inputs['skip-build'] }}"
42+
43+
APP_NAME="darwinia"
44+
ARCH="x86_64-linux-gnu"
45+
OUTPUT_BASENAME="${APP_NAME}${SUFFIX:+-$SUFFIX}-$ARCH"
46+
BUILD_DIR="build"
5847
5948
if [ "$SKIP_BUILD" != "true" ]; then
60-
docker run -i --rm \
61-
--name=build-darwinia \
62-
-v=$(pwd):/build \
63-
darwinia-network/build-tool:latest \
64-
cargo b --release --locked \
65-
-p darwinia \
66-
--features=$FEATURES
49+
docker run -i --rm \
50+
--name=build-darwinia \
51+
-v="$(pwd):/build" \
52+
darwinia-network/build-tool:latest \
53+
cargo b --release --locked -p darwinia --features="$FEATURES"
6754
else
6855
mkdir -p target/release
6956
echo SKIP_BUILD > target/release/darwinia
7057
fi
7158
72-
BUILD_DIR=build
73-
mkdir -p $BUILD_DIR
59+
mkdir -p "$BUILD_DIR"
7460
75-
if [ "$ENABLE_TAR_BZ2" == "true" ]; then
76-
tar cjSf ${BUILD_DIR}/darwinia${SUFFIX:+-$SUFFIX}-x86_64-linux-gnu.tar.bz2 -C target/release darwinia
61+
if [ "$ENABLE_TAR_BZ2" = "true" ]; then
62+
tar cjf "$BUILD_DIR/${OUTPUT_BASENAME}.tar.bz2" -C target/release darwinia
7763
fi
7864
79-
tar cf ${BUILD_DIR}/darwinia${SUFFIX:+-$SUFFIX}-x86_64-linux-gnu.tar.zst -C target/release darwinia -I zstd
80-
- name: Shrink cache
81-
if: ${{ inputs.enable_cache == 'true' && inputs.skip-build != 'true' }}
82-
shell: bash
83-
run: |
84-
docker run -i --rm \
85-
--name=build-darwinia \
86-
-v=$(pwd):/build \
87-
darwinia-network/build-tool:latest \
88-
${{ inputs.cache_shrink_script }} release
65+
tar cf "$BUILD_DIR/${OUTPUT_BASENAME}.tar.zst" -C target/release darwinia -I zstd

.github/note-template/runtime.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
## {{ .Env.CHAIN | strings.Title }}
2-
<h3 align="right">Upgrade Priority LOW :green_circle:</h3>
1+
## {{ .Env.RUNTIME | strings.Title }}
2+
<h4 align="right">Upgrade Priority LOW :green_circle:</h4>
33

4-
#### Whitelist Hash
4+
### Digest
5+
```json
6+
{{ (ds "prr" | data.ToJSONPretty " ") }}
57
```
8+
9+
### Whitelist Hash
10+
```txt
611
{{ .Env.WHITELIST_HASH }}
712
```
8-
#### Blake2 256 Hash
9-
```
10-
{{ (ds "srtool").runtimes.compressed.subwasm.blake2_256 }}
11-
```

.github/workflows/release.yml

+34-24
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ env:
1111

1212
DOCKER_REGISTRY: ghcr.io
1313

14-
GOMPLATE_VERSION: v3.11.6
14+
GOMPLATE_VERSION: v4.3.1
1515
GOMPLATE: gomplate_linux-amd64
1616
GOMPLATE_URL: https://github.com/hairyhenderson/gomplate/releases/download
1717

1818
RUST_BACKTRACE: full
19-
RUST_TOOLCHAIN: 1.74.0
2019

2120
# Set this to true for CI testing purposes only.
2221
SKIP_BUILD: false
@@ -92,44 +91,56 @@ jobs:
9291
zstd -d wuh.zst
9392
chmod u+x ./wuh
9493
sudo mv ./wuh /usr/bin/wuh
95-
- name: Build ${{ matrix.runtime }} runtime
96-
id: srtool_build
97-
if: ${{ env.SKIP_BUILD != 'true' }}
98-
uses: chevdor/[email protected]
99-
env:
100-
BUILD_OPTS: --features=on-chain-release-build
94+
- name: Build runtime
95+
# It is recommended to use a specific version of the action in production.
96+
#
97+
# For example:
98+
# uses: hack-ink/polkadot-runtime-releaser/action/[email protected]
99+
uses: hack-ink/polkadot-runtime-releaser/action/build@v0.2.0
101100
with:
102-
image: paritytech/srtool
103-
tag: "1.74.0"
104-
chain: ${{ matrix.runtime }}
101+
# The target runtime to build.
102+
#
103+
# For example, `polkadot-runtime` or `staging-kusama-runtime`.
104+
runtime: ${{ matrix.runtime }}-runtime
105+
# The features to enable for this release build.
106+
#
107+
# Generally, this would be `on-chain-release-build` in order to disable the logging to shrink the WASM binary size.
108+
features: on-chain-release-build
109+
# Rust toolchain version to build the runtime.
110+
toolchain-ver: 1.81.0
111+
# The workdir to build the runtime.
112+
#
113+
# By default, it is current directory.
114+
# workdir: .
115+
# The output directory of the WASM binary.
116+
output-dir: .
105117
- name: Prepare runtime
106118
run: |
107119
SKIP_BUILD=${{ env.SKIP_BUILD }}
108120
109-
export CHAIN=${{ matrix.runtime }}
110-
111-
echo $CHAIN
121+
# Template will use this env var.
122+
export RUNTIME=${{ matrix.runtime }}
112123
113124
mkdir -p build
114125
115126
if [ "$SKIP_BUILD" == "true" ]; then
116-
echo SKIP_BUILD > build/${CHAIN}-srtool.json
117-
echo SKIP_BUILD > build/${CHAIN}_runtime.compact.compressed.wasm
127+
echo SKIP_BUILD > build/${RUNTIME}.wasm
118128
echo SKIP_BUILD > build/runtime.md
119129
else
120-
echo '${{ steps.srtool_build.outputs.json }}' | jq > build/${CHAIN}-srtool.json
121-
122-
WASM_FILE='${{ steps.srtool_build.outputs.wasm_compressed }}'
123130
WHITELIST_PALLET_INDEX=0x33
124-
if [ "$CHAIN" == "crab" ]; then
131+
if [ "$RUNTIME" == "crab" ]; then
125132
WHITELIST_PALLET_INDEX=0x2f
126133
fi
127-
export WHITELIST_HASH=$(wuh ${WASM_FILE} ${WHITELIST_PALLET_INDEX} 0x01)
134+
WASM=$(ls ${RUNTIME}*.wasm)
135+
# Template will use this env var.
136+
export WHITELIST_HASH=$(wuh ${WASM} ${WHITELIST_PALLET_INDEX} 0x01)
137+
138+
mv ${WASM} build/
128139
129-
mv ${WASM_FILE} build/
140+
DIGEST=$(ls ${RUNTIME}*.json)
130141
131142
cat .github/note-template/runtime.md \
132-
| gomplate -d srtool=build/${CHAIN}-srtool.json \
143+
| gomplate -d prr=${DIGEST} \
133144
> build/runtime.md
134145
fi
135146
- name: Upload ${{ matrix.runtime }} runtime
@@ -199,7 +210,6 @@ jobs:
199210
- name: Prepare nodes and runtimes
200211
run: |
201212
mkdir -p deploy
202-
mv *runtime/*.json deploy/
203213
mv *runtime/*.wasm deploy/
204214
mv darwinia/*.tar.* deploy/
205215
mv darwinia-tracing/*.tar.* deploy/

0 commit comments

Comments
 (0)