From 7de8b963f9779961955a1c82fd42cfe3456a39b0 Mon Sep 17 00:00:00 2001 From: Guillem Cordoba Date: Thu, 19 Aug 2021 13:19:12 +0200 Subject: [PATCH] Updated deps --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++ dna/Cargo.lock | 24 ++++++++--------- dna/workdir/dna/dna.yaml | 2 -- dna/zomes/chess/Cargo.toml | 2 +- dna/zomes/chess/src/chess_game.rs | 2 +- dna/zomes/chess/src/current_games.rs | 7 +++-- dna/zomes/chess/src/lib.rs | 16 +++++------ ui/package.json | 2 +- 8 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b56ea4f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the main branch +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build-and-test: + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + # Checks out a copy of your repository on the ubuntu-latest machine + - name: Checkout code + uses: actions/checkout@v2 + + - uses: cachix/install-nix-action@v12 + with: + nix_path: nixpkgs=channel:nixos-unstable + + - name: build-holochain + run: | + cd $GITHUB_WORKSPACE + nix-shell . --run "cd dna && CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown" + nix-shell . --run "cd dna && hc dna pack workdir" + + - name: test-holochain + run: | + cd $GITHUB_WORKSPACE + nix-shell . --run "cd dna/tests && npm install" + nix-shell . --run "cd dna/tests && npm test" \ No newline at end of file diff --git a/dna/Cargo.lock b/dna/Cargo.lock index 5a68a11..9de7714 100644 --- a/dna/Cargo.lock +++ b/dna/Cargo.lock @@ -320,6 +320,17 @@ dependencies = [ "serde", ] +[[package]] +name = "hc_turn_based_game" +version = "0.0.1" +source = "git+http://github.com/eyss/hc-turn-based-game?rev=4a34bf9fd1e008fb13cffe7ef591b45da6a4560a#4a34bf9fd1e008fb13cffe7ef591b45da6a4560a" +dependencies = [ + "chrono", + "derive_more", + "hdk", + "serde", +] + [[package]] name = "hc_zome_chess" version = "0.0.1" @@ -327,8 +338,8 @@ dependencies = [ "chess", "chrono", "derive_more", + "hc_turn_based_game", "hdk", - "holochain_turn_based_game", "serde", ] @@ -432,17 +443,6 @@ dependencies = [ "syn", ] -[[package]] -name = "holochain_turn_based_game" -version = "0.2.3" -source = "git+http://github.com/eyss/holochain-turn-based-game?rev=5e07a5f7c3d12d246eede978b65ce0d5f7f15f49#5e07a5f7c3d12d246eede978b65ce0d5f7f15f49" -dependencies = [ - "chrono", - "derive_more", - "hdk", - "serde", -] - [[package]] name = "holochain_wasmer_common" version = "0.0.67" diff --git a/dna/workdir/dna/dna.yaml b/dna/workdir/dna/dna.yaml index 9329e84..0573565 100644 --- a/dna/workdir/dna/dna.yaml +++ b/dna/workdir/dna/dna.yaml @@ -10,5 +10,3 @@ zomes: bundled: ../../target/wasm32-unknown-unknown/release/invitations.wasm - name: chess bundled: ../../target/wasm32-unknown-unknown/release/hc_zome_chess.wasm - - name: joining_code - bundled: ../../target/wasm32-unknown-unknown/release/joining_code.wasm diff --git a/dna/zomes/chess/Cargo.toml b/dna/zomes/chess/Cargo.toml index 67e087a..1f23da2 100644 --- a/dna/zomes/chess/Cargo.toml +++ b/dna/zomes/chess/Cargo.toml @@ -15,5 +15,5 @@ chrono = {version = "0.4", features = ["serde"]} hdk = {git = "https://github.com/holochain/holochain", rev = "363af6d8af8d18e4616f6aa56ad4d1f0fabaafb7", package = "hdk", version = "0.0.101-alpha.0"} -holochain_turn_based_game = {git ="http://github.com/eyss/holochain-turn-based-game", rev ="5e07a5f7c3d12d246eede978b65ce0d5f7f15f49"} +hc_turn_based_game = {git ="http://github.com/eyss/hc-turn-based-game", rev ="4a34bf9fd1e008fb13cffe7ef591b45da6a4560a"} chess = "3.2.0" diff --git a/dna/zomes/chess/src/chess_game.rs b/dna/zomes/chess/src/chess_game.rs index e890bac..d0041c5 100644 --- a/dna/zomes/chess/src/chess_game.rs +++ b/dna/zomes/chess/src/chess_game.rs @@ -1,7 +1,7 @@ use chess::{ChessMove, Color, Game, GameResult, Piece, Square}; use hdk::prelude::holo_hash::{AgentPubKeyB64, EntryHashB64}; use hdk::prelude::*; -use holochain_turn_based_game::prelude::TurnBasedGame; +use hc_turn_based_game::prelude::TurnBasedGame; use std::str::FromStr; #[derive(Clone, Debug)] diff --git a/dna/zomes/chess/src/current_games.rs b/dna/zomes/chess/src/current_games.rs index 712fb2e..6f3ff9b 100644 --- a/dna/zomes/chess/src/current_games.rs +++ b/dna/zomes/chess/src/current_games.rs @@ -19,12 +19,14 @@ pub fn add_current_game(game_hash: EntryHash, players: Vec) -> Exte } pub fn remove_current_game(game_hash: EntryHash, players: Vec) -> ExternResult<()> { + warn!("Removing current game for {:?}", players); for agent in players { - let link_to_current_game = get_current_games_for(agent)? + let link_to_current_game = get_current_games_for(agent.clone())? .into_iter() .find(|link| link.target.eq(&game_hash)); if let Some(link) = link_to_current_game { + warn!("Current game for {} {}", agent, link.create_link_hash); delete_link(link.create_link_hash)?; } } @@ -37,7 +39,8 @@ fn current_games_tag() -> LinkTag { } fn get_current_games_for(agent: AgentPubKey) -> ExternResult> { - let links = get_links(agent.into(), Some(current_games_tag()))?; + let links = get_links(agent.clone().into(), Some(current_games_tag()))?; + warn!("Current games for {} {:?}", agent, links); Ok(links.into_inner()) } diff --git a/dna/zomes/chess/src/lib.rs b/dna/zomes/chess/src/lib.rs index 07683c6..91af233 100644 --- a/dna/zomes/chess/src/lib.rs +++ b/dna/zomes/chess/src/lib.rs @@ -1,6 +1,6 @@ use hdk::prelude::holo_hash::{AgentPubKeyB64, EntryHashB64}; use hdk::prelude::*; -use holochain_turn_based_game::prelude::*; +use hc_turn_based_game::prelude::*; use chrono::serde::ts_milliseconds; use chrono::{DateTime, NaiveDateTime, Utc}; @@ -44,7 +44,7 @@ entry_defs![ #[hdk_extern] pub fn init(_: ()) -> ExternResult { - holochain_turn_based_game::prelude::init_turn_based_games() + hc_turn_based_game::prelude::init_turn_based_games() } #[hdk_extern] @@ -52,7 +52,7 @@ pub fn create_game(opponent: AgentPubKeyB64) -> ExternResult { let my_pub_key = agent_info()?.agent_initial_pubkey; let players = vec![opponent.clone(), AgentPubKeyB64::from(my_pub_key.clone())]; - let game_hash = holochain_turn_based_game::prelude::create_game(players.clone())?; + let game_hash = hc_turn_based_game::prelude::create_game(players.clone())?; current_games::add_current_game( game_hash.clone().into(), @@ -64,7 +64,7 @@ pub fn create_game(opponent: AgentPubKeyB64) -> ExternResult { #[hdk_extern] pub fn make_move(input: MakeMoveInput) -> ExternResult { - holochain_turn_based_game::prelude::create_move( + hc_turn_based_game::prelude::create_move( input.game_hash, input.previous_move_hash, input.game_move, @@ -73,12 +73,12 @@ pub fn make_move(input: MakeMoveInput) -> ExternResult { #[hdk_extern] pub fn get_game(game_hash: EntryHashB64) -> ExternResult { - holochain_turn_based_game::prelude::get_game(game_hash) + hc_turn_based_game::prelude::get_game(game_hash) } #[hdk_extern] pub fn get_game_moves(game_hash: EntryHashB64) -> ExternResult> { - holochain_turn_based_game::prelude::get_game_moves(game_hash) + hc_turn_based_game::prelude::get_game_moves(game_hash) } #[hdk_extern] @@ -104,7 +104,7 @@ pub fn get_my_current_games(_: ()) -> ExternResult> { #[hdk_extern] fn validate_create_entry_game_entry(data: ValidateData) -> ExternResult { - holochain_turn_based_game::prelude::validate_game_entry::(data) + hc_turn_based_game::prelude::validate_game_entry::(data) // TODO: add validation for read-only agents } @@ -112,6 +112,6 @@ fn validate_create_entry_game_entry(data: ValidateData) -> ExternResult ExternResult { - holochain_turn_based_game::prelude::validate_game_move_entry::(data) + hc_turn_based_game::prelude::validate_game_move_entry::(data) // TODO: add validation for read-only agents } diff --git a/ui/package.json b/ui/package.json index 85d75aa..b23c96d 100644 --- a/ui/package.json +++ b/ui/package.json @@ -10,7 +10,7 @@ "start-alice": "HC_PORT=8888 concurrently -k --names ui,hc \"ENV=hcdev npm run start-ui\" \"APP_ID=elemental-chess ADMIN_PORT=9000 npm run start-holochain\"", "start-bob": "HC_PORT=8889 concurrently -k --names ui,hc \"ENV=hcdev npm run start-ui\" \"APP_ID=elemental-chess ADMIN_PORT=9001 npm run start-holochain\"", "start-ui": "concurrently -k --names tsc,web-dev-server \"npm run build-watch\" \"sleep 5 && web-dev-server --config web-dev-server.config.mjs\"", - "start-holochain": "RUST_LOG=warn hc s -f=$ADMIN_PORT generate -r=$HC_PORT ../dna/workdir/happ/elemental-chess.happ --app-id=$APP_ID network -b https://bootstrap-staging.holo.host quic", + "start-holochain": "RUST_LOG=info WASM_LOG=trace hc s -f=$ADMIN_PORT generate -r=$HC_PORT ../dna/workdir/happ/elemental-chess.happ --app-id=$APP_ID network -b https://bootstrap-staging.holo.host quic", "build-watch": "rimraf dist && rollup -c rollup.config.js -w", "build-holochain": "rimraf dist && ENV=hc rollup -c rollup.config.js", "build-holo": "rimraf dist && ENV=holo rollup -c rollup.config.js",