-
Notifications
You must be signed in to change notification settings - Fork 85
117 lines (109 loc) · 4.48 KB
/
build-wasm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
on:
push:
tags:
- '*'
pull_request:
paths:
- ".github/workflows/build-wasm.yml"
name: Build&Publish WASM
concurrency:
group: '${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
permissions:
id-token: write
contents: read
jobs:
build-runtime-wasms:
# environment: ${{ github.ref == 'refs/heads/main' && 'production' || '' }}
# environment: production
# Benchmark (with cache hit)
# ubuntu-latest 50 min
# ubuntu-latest-4-cores 34 min
runs-on: ubuntu-latest-4-cores
strategy:
matrix:
# To test until I get one right
# target: [build-runtime, build-runtime-fast, build-runtime-testnet]
# package: [centrifuge-runtime, altair-runtime]
target: [build-runtime, build-runtime-fast]
package: [altair-runtime, centrifuge-runtime]
# rust_version: ["1.69.0"]
name: ${{ matrix.target }}-${{ matrix.package }}
# Cannot make sccache work with the srtool container
# env:
# SCCACHE_GHA_ENABLED: "true"
# RUSTC_WRAPPER: "sccache"
steps:
# PREP
- name: Check out code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #3.5.2
- name: Prep build on Ubuntu
uses: ./.github/actions/prep-ubuntu
# Use default toolchain
# with:
# RUST_TOOLCHAIN: ${{ matrix.rust_version }}
# sccache does not work inside the srtool container
- uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # 2.6.2
with:
prefix-key: build #-${{ matrix.package }}
shared-key: wasm
workspaces: |
.
./target/srtool
cache-directories: ./runtime
# save-if: ${{ github.ref == 'refs/heads/master' }}
# BUILD
-
id: buildopt
run: |
if ${{ matrix.target == 'build-runtime-fast'}} ; then
echo "BUILD_OPTS=--features=fast-runtime" >> GITHUB_ENV
fi
echo "BUILD_OPTS=${{ env.BUILD_OPTS }}"
- name: Run srtool
run: >
docker run --rm --user root --platform=linux/amd64
-e PACKAGE=${{ matrix.package }} -v /home/runner/.cargo:/cargo-home
-v ${{ github.workspace }}:/build paritytech/srtool:1.73.0-0.12.0
/srtool/build
# - name: Run Docker SRTool
# uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 #v3
# env:
# RUSTC_VERSION: ${{ matrix.rust_version }}
# TARPAULIN_VERSION: 0.19.1 # travis-ci codecov generator
# with:
# image: paritytech/srtool:${{ matrix.rust_version }}
# options: --user root -v /home/runner/.cargo:/cargo-home -v ${{ github.workspace }}:/build -e BUILD_OPTS=${{ env.BUILD_OPTS || ''}} -e PACKAGE=${{ matrix.package }}
# run: |
# echo "---- Env VARS ----"
# echo "BUILD_OPT=${BUILD_OPT}"
# echo "PACKAGE=${PACKAGE}"
# echo "---- List Cache Folder ----"
# ls -la /cargo-home/
# du -sh /cargo-home/*
# echo "---- RUNNING BUILD ----"
# /srtool/build --save
- name: Upload srtool report
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 #v3.1.3
with:
name: srtool-wasm-report.txt
path: ./${{ matrix.package }}-srtool-wasm-report.json
- id: 'auth'
# if: ${{ github.ref == 'refs/heads/main' }}
uses: 'google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033' # v1.1.1
with:
workload_identity_provider: ${{ secrets.GWIP_ARTIFACTS }}
service_account: ${{ secrets.GSA_ARTIFACTS }}
- name: Setup - gcloud / gsutil
if: ${{ steps.auth.outcome == 'success' }}
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1
- name: Publish artifacts to GCS
if: ${{ steps.auth.outcome == 'success' }}
shell: bash
run: |
target=$(echo "${{ matrix.target }}" | sed -e "s/^build-//" )
runtime_name=$(echo "${{ matrix.package }}" | sed -e "s/-runtime$//" )
filename=$(echo "${{ matrix.package }}" | sed -e 's/-/_/g' )
gsutil cp \
./runtime/${runtime_name}/target/srtool/release/wbuild/${{ matrix.package }}/${filename}.compact.compressed.wasm \
gs://centrifuge-wasm-repo/${runtime_name}/${runtime_name}-${target}-$(git rev-parse --short HEAD).wasm