-
Notifications
You must be signed in to change notification settings - Fork 24
78 lines (73 loc) · 2.44 KB
/
Copy pathdeployment-build-test.yaml
File metadata and controls
78 lines (73 loc) · 2.44 KB
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
name: PLT Deployment unit checks
on:
push:
branches:
- main
paths:
- '.github/workflows/deployment-build-test.yaml'
- 'concordium-base'
- 'deployment'
pull_request:
paths:
- '.github/workflows/deployment-build-test.yaml'
- 'concordium-base'
- 'deployment'
env:
CARGO_TERM_COLOR: always # implicitly adds '--color=always' to all cargo commands
jobs:
rustfmt:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Run rustfmt
working-directory: plt-deployment-unit
run: |
rustup component add rustfmt
cargo fmt -- --check
clippy_test:
name: Run Clippy and tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Clippy
working-directory: plt-deployment-unit
run: |
rustup component add clippy
cargo clippy --all-targets --all-features --locked -- -D warnings
- name: Test
working-directory: plt-deployment-unit
run: cargo test --all-targets --all-features
# Build the deployment unit to WebAssembly and report the size in bytes
report_wasm_size:
name: Build and report byte size of Wasm deployment unit
runs-on: ubuntu-latest
needs: [rustfmt, clippy_test]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build to WebAssembly
working-directory: plt-deployment-unit
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cargo build --release --target wasm32-unknown-unknown --locked
- name: Report the byte size of WASM deployment unit on PRs
working-directory: plt-deployment-unit
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Read the size of the build artifact in number of bytes
BYTESIZE=$(du -b target/wasm32-unknown-unknown/release/plt_deployment_unit.wasm | egrep -o '^[0-9]+')
# Format the exact bytes.
GROUPED=$(numfmt --suffix B --grouping $BYTESIZE)
# Attach comment to PR.
gh pr comment ${{ github.event.number }} --edit-last --create-if-none --body "The file size of the WebAssembly PLT deployment unit is **$GROUPED**."