chore: run integration tests against PocketIC #2815
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
name: ic-ref | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
build: [linux-stable] | |
include: | |
- build: linux-stable | |
ic-hs-ref: "3d71032e" | |
wallet-tag: "20230308" | |
os: ubuntu-latest | |
steps: | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- uses: actions/checkout@v4 | |
- name: Install dfx | |
uses: dfinity/setup-dfx@main | |
with: | |
dfx-version: "0.24.2-beta.0" | |
- name: Cargo cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Download cycles-wallet canister | |
run: | | |
wget https://github.com/dfinity/cycles-wallet/releases/download/${{ matrix.wallet-tag }}/wallet.wasm | |
mv wallet.wasm $HOME/wallet.wasm | |
- name: Download universal-canister | |
run: | | |
wget https://download.dfinity.systems/ic-ref/ic-ref-test-0.0.1-${{ matrix.ic-hs-ref }}-x86_64-linux.tar.gz | |
tar -xvf ic-ref-test-0.0.1-${{ matrix.ic-hs-ref }}-x86_64-linux.tar.gz test-data/universal-canister.wasm | |
mv test-data/universal-canister.wasm $HOME/canister.wasm | |
- name: Run Integration Tests | |
run: | | |
set -ex | |
dfx start --background --clean | |
sleep 1 | |
export IC_REF_PORT=$(dfx info replica-port) | |
export IC_UNIVERSAL_CANISTER_PATH=$HOME/canister.wasm | |
export IC_WALLET_CANISTER_PATH=$HOME/wallet.wasm | |
cargo test --all-features -- --ignored | |
dfx stop | |
env: | |
RUST_BACKTRACE: 1 | |
- name: Run Integration Tests against PocketIC | |
run: | | |
set -ex | |
dfx start --background --clean --pocketic | |
sleep 1 | |
export IC_REF_PORT=$(dfx info webserver-port) | |
export IC_UNIVERSAL_CANISTER_PATH=$HOME/canister.wasm | |
export IC_WALLET_CANISTER_PATH=$HOME/wallet.wasm | |
export POCKET_IC="http://localhost:${IC_REF_PORT}" | |
cargo test --all-features -- --ignored --test-threads=1 # TODO: drop --test-threads=1 | |
dfx stop | |
env: | |
RUST_BACKTRACE: 1 | |
- name: Install and Configure SoftHSM | |
run: | | |
set -ex | |
sudo apt-get install -f libsofthsm2 opensc-pkcs11 opensc | |
sudo usermod -a -G softhsm $USER | |
echo "SOFTHSM2_CONF=$HOME/softhsm.conf" >>$GITHUB_ENV | |
echo "directories.tokendir = $HOME/softhsm/tokens/" >$HOME/softhsm.conf | |
mkdir -p $HOME/softhsm/tokens | |
- name: Run Integration Tests with SoftHSM | |
run: | | |
set -ex | |
softhsm2-util --init-token --slot $HSM_SLOT_INDEX --label "agent-rs-token" --so-pin $HSM_SO_PIN --pin $HSM_PIN | |
# create key: | |
pkcs11-tool -k --module $HSM_PKCS11_LIBRARY_PATH --login --slot-index $HSM_SLOT_INDEX -d $HSM_KEY_ID --key-type EC:prime256v1 --pin $HSM_PIN | |
dfx start --background --clean | |
sleep 1 | |
export IC_REF_PORT=$(dfx info replica-port) | |
export IC_UNIVERSAL_CANISTER_PATH=$HOME/canister.wasm | |
export IC_WALLET_CANISTER_PATH=$HOME/wallet.wasm | |
cd ref-tests | |
cargo test --all-features -- --ignored --nocapture --test-threads=1 | |
dfx stop | |
env: | |
RUST_BACKTRACE: 1 | |
HSM_PKCS11_LIBRARY_PATH: /usr/lib/softhsm/libsofthsm2.so | |
HSM_SO_PIN: 123456 | |
HSM_PIN: 1234 | |
HSM_SLOT_INDEX: 0 | |
HSM_KEY_ID: abcdef | |
- name: Run Integration Tests with SoftHSM against PocketIC | |
run: | | |
set -ex | |
dfx start --background --clean --pocketic | |
sleep 1 | |
export IC_REF_PORT=$(dfx info webserver-port) | |
export IC_UNIVERSAL_CANISTER_PATH=$HOME/canister.wasm | |
export IC_WALLET_CANISTER_PATH=$HOME/wallet.wasm | |
export POCKET_IC="http://localhost:${IC_REF_PORT}" | |
cd ref-tests | |
cargo test --all-features -- --ignored --nocapture --test-threads=1 | |
dfx stop | |
env: | |
RUST_BACKTRACE: 1 | |
HSM_PKCS11_LIBRARY_PATH: /usr/lib/softhsm/libsofthsm2.so | |
HSM_SO_PIN: 123456 | |
HSM_PIN: 1234 | |
HSM_SLOT_INDEX: 0 | |
HSM_KEY_ID: abcdef | |
- name: Run Doc Tests | |
run: | | |
set -ex | |
dfx start --background --clean | |
sleep 1 | |
export IC_REF_PORT=$(dfx info replica-port) | |
cargo test --all-features --doc -- --ignored | |
dfx stop | |
env: | |
RUST_BACKTRACE: 1 | |
- name: Run Doc Tests against PocketIC | |
run: | | |
set -ex | |
dfx start --background --clean --pocketic | |
sleep 1 | |
export IC_REF_PORT=$(dfx info webserver-port) | |
export POCKET_IC="http://localhost:${IC_REF_PORT}" | |
cargo test --all-features --doc -- --ignored --test-threads=1 # TODO: drop --test-threads=1 | |
dfx stop | |
env: | |
RUST_BACKTRACE: 1 | |
aggregate: | |
name: ic-ref:required | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
needs: test | |
steps: | |
- name: Check ic-ref result | |
if: ${{ needs.test.result != 'success' }} | |
run: exit 1 |