-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial CI for Rust contracts (#22)
* Add initial CI for Rust contracts * Improve clippy configuration for CI * Fix clippy warnings * Fix clippy warnings * Add workspace configuration * fix: add v2 resolver and other basic functionality * fix: remove default folder * fix: lower restrictions for running CI * fix: use the workspace version for easier tracking --------- Co-authored-by: Geoffrey Mureithi <[email protected]> Co-authored-by: Geoffrey Mureithi <[email protected]>
- Loading branch information
1 parent
0f8cad6
commit 4476d86
Showing
7 changed files
with
105 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Build and test contracts | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: ["main"] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
RUSTFLAGS: "-Dwarnings" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up cargo cache | ||
uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
lib/target | ||
key: 1-${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.toml') }} | ||
restore-keys: ${{ runner.os }}-cargo-build | ||
|
||
- name: Prepare target | ||
run: rustup target add wasm32-unknown-unknown | ||
|
||
# This will attempt to build all contracts in the workspace. | ||
# This command will likely change when we have more than contracts in the workspace | ||
- name: Build All | ||
run: cargo build --release --target wasm32-unknown-unknown --verbose | ||
|
||
- name: Lint | ||
run: cargo clippy --all-targets --all-features | ||
|
||
test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up cargo cache | ||
uses: actions/cache@v3 | ||
continue-on-error: false | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
contracts/target | ||
key: 1-${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.toml') }} | ||
restore-keys: ${{ runner.os }}-cargo-build | ||
|
||
- name: Test | ||
run: cargo test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
|
||
[workspace] | ||
# We want to use v2 of the cargo dependency resolver. | ||
resolver = "2" | ||
# Our workspace members include the packages in the contracts directory. | ||
members = ["contracts/voting", "contracts/raffle"] | ||
|
||
|
||
[profile.release] | ||
opt-level = "z" | ||
overflow-checks = true | ||
debug = 0 | ||
strip = "symbols" | ||
debug-assertions = false | ||
panic = "abort" | ||
codegen-units = 1 | ||
lto = true | ||
|
||
[profile.release-with-logs] | ||
inherits = "release" | ||
debug-assertions = true | ||
|
||
|
||
[workspace.dependencies.soroban-sdk] | ||
version = "0.9.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters