-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example with guards and asynchronous code for Rust canisters (#877)
* Infrastructure * integration test * examples with various futures * add dfx support * temp with made up future * clean-up * use same state field for single/multi items test * clean-up * doc * added Github workflow file * provision pocket-ic server * use same version as locally * added guard against parallel processing * upgrade PocketIc * added test against parallel processing. * simplify provisioning of PocketIC and added Linting * fix * fix order of CI steps * ensure items are not in processing when reset * add ownership
- Loading branch information
1 parent
46704c2
commit 01b1e4d
Showing
11 changed files
with
2,524 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
POCKET_IC_SERVER_VERSION=${POCKET_IC_SERVER_VERSION:=4.0.0} | ||
POCKET_IC_SERVER_PATH=${POCKET_IC_SERVER_PATH:="${HOME}/bin/pocket-ic-server"} | ||
|
||
if [[ $OSTYPE == "linux-gnu"* ]] || [[ $RUNNER_OS == "Linux" ]] | ||
then | ||
PLATFORM=linux | ||
elif [[ $OSTYPE == "darwin"* ]] || [[ $RUNNER_OS == "macOS" ]] | ||
then | ||
PLATFORM=darwin | ||
else | ||
echo "OS not supported: ${OSTYPE:-$RUNNER_OS}" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "$POCKET_IC_SERVER_PATH" ]; then | ||
echo "Downloading PocketIC." | ||
mkdir -p "$(dirname "${POCKET_IC_SERVER_PATH}")" | ||
curl -sSL "https://github.com/dfinity/pocketic/releases/download/${POCKET_IC_SERVER_VERSION}/pocket-ic-x86_64-${PLATFORM}.gz" -o "${POCKET_IC_SERVER_PATH}".gz | ||
gunzip "${POCKET_IC_SERVER_PATH}.gz" | ||
chmod +x "${POCKET_IC_SERVER_PATH}" | ||
else | ||
echo "PocketIC server already exists, skipping download." | ||
fi | ||
|
||
# Set environment variables. | ||
echo "POCKET_IC_BIN=${POCKET_IC_SERVER_PATH}" >> "$GITHUB_ENV" |
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,63 @@ | ||
name: rust-guards | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
paths: | ||
- rust/guards/** | ||
- .github/workflows/provision-darwin.sh | ||
- .github/workflows/provision-linux.sh | ||
- .github/workflows/provision-pocket-ic-server.sh | ||
- .github/workflows/rust-guards-example.yml | ||
- .ic-commit | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
rust-guards-darwin: | ||
runs-on: macos-12 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Provision Darwin | ||
run: bash .github/workflows/provision-darwin.sh | ||
- name: Provision PocketIC Darwin | ||
run: bash .github/workflows/provision-pocket-ic-server.sh | ||
- name: Build Guards Darwin | ||
run: | | ||
pushd rust/guards | ||
cargo build --target wasm32-unknown-unknown --release | ||
popd | ||
- name: Lint Guards Darwin | ||
run: | | ||
pushd rust/guards | ||
cargo fmt --all -- --check && cargo clippy --all-targets --all-features -- -D warnings | ||
popd | ||
- name: Test Guards Darwin | ||
run: | | ||
pushd rust/guards | ||
cargo test | ||
popd | ||
rust-guards-linux: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Provision Linux | ||
run: bash .github/workflows/provision-linux.sh | ||
- name: Provision PocketIC Linux | ||
run: bash .github/workflows/provision-pocket-ic-server.sh | ||
- name: Build Guards Linux | ||
run: | | ||
pushd rust/guards | ||
cargo build --target wasm32-unknown-unknown --release | ||
popd | ||
- name: Lint Guards Linux | ||
run: | | ||
pushd rust/guards | ||
cargo fmt --all -- --check && cargo clippy --all-targets --all-features -- -D warnings | ||
popd | ||
- name: Test Guards Linux | ||
run: | | ||
pushd rust/guards | ||
cargo test | ||
popd |
Oops, something went wrong.