-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (102 loc) · 3.51 KB
/
format-lint-build-test.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
name: Format, Lint, Build and Test
on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review
env:
NODE_VERSION: "lts/*"
RUST_VERSION: "1.75"
CARGO_CONCORDIUM_VERSION: "3.2"
MY_CONTRACT_PATH: contracts/my-contract
MY_CONTRACT_DEPLOY_SCRIPT_PATH: contracts/my-contract/deploy-scripts
jobs:
rustfmt-clippy:
name: Formatting and linting smart contracts
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust toolchain with rustfmt available
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
target: wasm32-unknown-unknown
components: rustfmt, clippy
- name: Run cargo fmt - ${{ env.MY_CONTRACT_PATH }}
working-directory: ${{ env.MY_CONTRACT_PATH }}
run: cargo fmt --check
- name: Run cargo fmt - ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }}
working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }}
run: cargo fmt --check
- name: Run cargo clippy - ${{ env.MY_CONTRACT_PATH }}
working-directory: ${{ env.MY_CONTRACT_PATH }}
run: cargo clippy --locked -- -D warnings
- name: Run cargo clippy - ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }}
working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }}
run: cargo clippy --locked -- -D warnings
prettier-eslint:
name: Formatting and linting frontend
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Setup Node for frontend
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install NPM dependencies
working-directory: frontend
run: npm clean-install
- name: Run prettier
working-directory: frontend
run: npm run format-check
- name: Run eslint
working-directory: frontend
run: npm run lint-check
build-and-test:
name: Build and test everything
needs: [rustfmt-clippy, prettier-eslint]
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-unknown
toolchain: ${{ env.RUST_VERSION }}
- name: Install cargo-concordium from crates.io
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-concordium
version: ${{env.CARGO_CONCORDIUM_VERSION}}
- name: Build and test smart contract
working-directory: ${{ env.MY_CONTRACT_PATH }}
run: cargo concordium test --out "./concordium-out/module.wasm.v1"
# Frontend build and test
- name: Setup Node for frontend
uses: actions/setup-node@v4
with:
node-version: ${{env.NODE_VERSION}}
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install NPM dependencies
working-directory: frontend
run: npm clean-install
# This must be run after building the smart contracts.
- name: Generate smart contract clients
working-directory: frontend
run: npm run generate
- name: Build all libraries and samples
working-directory: frontend
run: npm run build