This repository has been archived by the owner on Sep 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
175 additions
and
13 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,85 @@ | ||
name: ic-ref | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
build: [ linux-0-8 ] | ||
include: | ||
- build: linux-0-8 | ||
ghc: '8.8.3' | ||
spec: 'joachim/test-for-agent-rust' | ||
os: ubuntu-latest | ||
rust: stable | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
path: main | ||
- uses: actions/checkout@v2 | ||
with: | ||
repository: 'dfinity-lab/ic-ref' | ||
# Personal Read-only Access Token created by [email protected] | ||
token: ${{ secrets.IC_REF_TOKEN }} | ||
path: ic-ref | ||
ref: ${{ matrix.spec }} | ||
|
||
- name: Cache ~/.cabal/store | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.cabal/store | ||
key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-store | ||
- uses: actions/[email protected] | ||
with: | ||
ghc-version: ${{ matrix.ghc }} | ||
|
||
- name: Cache Cargo registry | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.cargo/registry | ||
key: ${{ matrix.build }}-cargo-registry-${{ hashFiles('main/**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ matrix.build }}-cargo-registry- | ||
- name: Cache Cargo index | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.cargo/git | ||
key: ${{ matrix.build }}-cargo-index-${{ hashFiles('main/**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ matrix.build }}-cargo-index- | ||
- name: Cache Cargo build | ||
uses: actions/cache@v1 | ||
with: | ||
path: main/target | ||
key: ${{ matrix.build }}-target-${{ hashFiles('main/**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ matrix.build }}-target- | ||
- name: Install Rust | ||
run: | | ||
rustup update ${{ matrix.rust }} --no-self-update | ||
rustup default ${{ matrix.rust }} | ||
- name: Build ic-ref | ||
run: | | ||
ls -l /opt/ghc/ | ||
export PATH=/opt/ghc/bin:$PATH | ||
cabal --version | ||
ghc --version | ||
mkdir -p $HOME/bin | ||
cd ic-ref/impl | ||
cabal update | ||
cabal install -w ghc-${{ matrix.ghc }} --overwrite-policy=always --installdir=$HOME/bin | ||
- name: Run Tests | ||
run: | | ||
set -ex | ||
$HOME/bin/ic-ref --pick-port --write-port-to $HOME/ic_ref_port & | ||
sleep 1 | ||
export IC_REF_PORT=$(cat $HOME/ic_ref_port) | ||
cd main/ic-agent | ||
cargo test --features ic_ref_tests --test ic-ref | ||
env: | ||
RUST_BACKTRACE: 1 |
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 |
---|---|---|
|
@@ -4,8 +4,7 @@ on: [pull_request] | |
|
||
jobs: | ||
test: | ||
name: Lint | ||
|
||
name: lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
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
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,2 @@ | ||
#![cfg(feature = "ic_ref_tests")] | ||
mod ic_ref; |
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,2 @@ | ||
mod status; | ||
mod utils; |
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,25 @@ | ||
use super::utils::create_agent; | ||
|
||
#[actix_rt::test] | ||
async fn status_endpoint_works() -> Result<(), String> { | ||
let agent = create_agent().await?; | ||
agent.ping_once().await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[actix_rt::test] | ||
async fn status_endpoint_is_expected() -> Result<(), String> { | ||
let agent = create_agent().await?; | ||
let status = agent.ping_once().await?; | ||
|
||
match status { | ||
serde_cbor::Value::Map(map) => { | ||
let key = serde_cbor::Value::from("ic_api_version".to_string()); | ||
assert_eq!(map.get( &key), Some(&serde_cbor::Value::from("0.8.2".to_string()))); | ||
}, | ||
x => assert!(false, "Invalid status return: {:?}", x), | ||
} | ||
|
||
Ok(()) | ||
} |
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,12 @@ | ||
use ic_agent::{Agent, AgentConfig}; | ||
|
||
pub async fn create_agent() -> Result<Agent, String> | ||
{ | ||
let port_env = std::env::var("IC_REF_PORT").expect("Need to specify the IC_REF_PORT environment variable."); | ||
let port = port_env.parse::<u32>().expect("Could not parse the IC_REF_PORT environment variable as an integer."); | ||
|
||
Ok(ic_agent::Agent::new(AgentConfig { | ||
url: &format!("http://127.0.0.1:{}", port), | ||
..AgentConfig::default() | ||
})?) | ||
} |