Skip to content

Commit

Permalink
Matrix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
m00nwtchr committed Dec 18, 2022
1 parent 844b8aa commit 95e383c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 79 deletions.
22 changes: 2 additions & 20 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: Swatinem/rust-cache@v2

- uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -63,16 +54,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: Swatinem/rust-cache@v2

- uses: actions-rs/toolchain@v1
with:
Expand Down
65 changes: 28 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2

- uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -53,19 +54,28 @@ jobs:
id: deployment
uses: actions/deploy-pages@v1

release:
runs-on: ubuntu-latest
build:
strategy:
matrix:
config:
- os: ubuntu-latest
path: target/release/cofd-pc
- os: windows-latest
path: target\release\cofd-pc.exe
name: Build ${{ matrix.config.os }}
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Release build
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
Expand All @@ -77,40 +87,21 @@ jobs:
command: test
args: --release --all-features

- uses: "marvinpinto/action-automatic-releases@latest"
- uses: actions/upload-artifact@master
with:
name: ${{ matrix.config.os }}-bin
path: ${{ matrix.config.path }}

release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v3
with:
path: artifacts

- uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
target/release/cofd-pc
# release-windows:
# runs-on: windows-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: nightly
# override: true

# - name: Release build
# uses: actions-rs/cargo@v1
# with:
# command: build
# args: --release --all-features

# - name: Test
# uses: actions-rs/cargo@v1
# with:
# command: test
# args: --release --all-features

# - uses: "marvinpinto/action-automatic-releases@latest"
# with:
# repo_token: "${{ secrets.GITHUB_TOKEN }}"
# prerelease: false
# files: |
# target/release/cofd-pc
files: artifacts/*-bin/*
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ opt-level = 'z'
# optimization for size
# opt-level = 's'

cargo-features = ["named-profiles"]

[profile.coverage]
panic = "abort"
opt-level = 0
Expand Down
30 changes: 13 additions & 17 deletions cofd/app/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ use std::path::PathBuf;

use serde::{Deserialize, Serialize};


use cfg_if::cfg_if;

#[cfg(target_arch = "wasm32")]
use anyhow::anyhow;

pub struct Store {
#[cfg(target_arch = "wasm32")]
local_storage: web_sys::Storage,
#[cfg(not(target_arch = "wasm32"))]
path: PathBuf,
dirs: ProjectDirs,
}

impl Store {
Expand All @@ -31,30 +33,32 @@ impl Store {
store = None;
}
} else {
let path = Store::save_path();
let dirs = ProjectDirs::from("", "", "cofd-pc").unwrap();

let dir = path.parent();
let dir = dirs.data_dir().parent();
if dir.is_some() && !dir.unwrap().exists() {
std::fs::create_dir_all(dir.unwrap()).ok()?;
}

store = Some(Self {
path
dirs
});
}
}

store
}

pub fn get<T: for<'a> Deserialize<'a>>(&self, _name: &str) -> anyhow::Result<Option<T>> {
pub fn get<T: for<'a> Deserialize<'a>>(&self, name: &str) -> anyhow::Result<Option<T>> {
let val;

cfg_if! {
if #[cfg(target_arch = "wasm32")] {
val = self.local_storage.get_item(name).map_err(|err| anyhow!("{:?}", err))?;
} else {
val = Some(std::fs::read_to_string(self.path.clone())?);
val = Some(std::fs::read_to_string(
self.dirs.data_dir().join(format!("{name}.ron")),
)?);
}
}

Expand All @@ -65,25 +69,17 @@ impl Store {
}
}

pub fn set<T: Serialize>(&self, _name: &str, value: &T) -> anyhow::Result<()> {
pub fn set<T: Serialize>(&self, name: &str, value: &T) -> anyhow::Result<()> {
let val = ron::ser::to_string(value)?;

cfg_if! {
if #[cfg(target_arch = "wasm32")] {
self.local_storage.set_item(name, &val).map_err(|err| anyhow!("{:?}", err))?;
} else {
std::fs::write(self.path.clone(), val)?;
std::fs::write(self.dirs.data_dir().join(format!("{name}.ron")), val)?;
}
}

Ok(())
}

#[cfg(not(target_arch = "wasm32"))]
fn save_path() -> PathBuf {
ProjectDirs::from("", "", "cofd-pc")
.unwrap()
.data_dir()
.join("characters.ron")
}
}
13 changes: 10 additions & 3 deletions cofd/app/src/view/overview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ use cofd::{
ability::Ability,
changeling::Regalia,
mage::{Ministry, Order},
werewolf::{
HuntersAspect, KuruthTrigger, KuruthTriggerSet, KuruthTriggers, Tribe,
},
werewolf::{HuntersAspect, KuruthTrigger, KuruthTriggerSet, KuruthTriggers, Tribe},
Merit, Splat,
},
};
Expand Down Expand Up @@ -662,6 +660,9 @@ where

match &character.splat {
Splat::Mortal => {}
Splat::Bound(..) => {
col2 = col2.push(fuel);
}
_ => {
col2 = col2.push(st).push(fuel);
}
Expand Down Expand Up @@ -701,6 +702,12 @@ where
.push(conditions);
col2 = col2.push(traits);
}
Splat::Bound(..) => {
col1 = col1.push(merits)
// Keys
.push(abilities);
col2 = col2.push(aspirations);
}
_ => {
col1 = col1.push(merits).push(traits);
col2 = col2.push(conditions).push(aspirations);
Expand Down

0 comments on commit 95e383c

Please sign in to comment.