diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4ef65a8..cd2ea53 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -8,13 +8,11 @@ on: workflow_dispatch: jobs: - clippy_pr: + checker: + name: Check, Clippy runs-on: ubuntu-latest - container: jugeeya/cargo-skyline:3.2.0 steps: - uses: actions/checkout@v2 - - name: Setup PATH - run: export PATH=$PATH:/root/.cargo/bin:/opt/devkitpro/devkitA64/bin - name: Install minimal nightly rust uses: actions-rs/toolchain@v1 with: @@ -23,39 +21,20 @@ jobs: components: rustfmt, clippy default: true target: x86_64-unknown-linux-gnu - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - toolchain: nightly - args: --all-features --target=x86_64-unknown-linux-gnu - - uses: mbrobbel/rustfmt-check@master - with: - token: ${{ secrets.GITHUB_TOKEN }} + - name: Check + run: cargo +nightly check --target=x86_64-unknown-linux-gnu + - name: Clippy + run: cargo +nightly clippy --all-targets --all-features --target=x86_64-unknown-linux-gnu plugin: + name: Plugin NRO runs-on: ubuntu-latest - outputs: - changelog: ${{ steps.build_release.outputs.changelog }} container: - image: jugeeya/cargo-skyline:3.2.0 + image: jugeeya/cargo-skyline:3.2.0-no-dkp steps: - uses: actions/checkout@v2 - name: Build release NRO id: build_release - run: | - # # Grab changelog for beta description later - # # Grab latest tag, grab log vs. main, replace newlines with two newlines and a list marker - # changelog="- $(git log --pretty=format:%s `git tag --sort=-committerdate | head -1`...main | sed -z 's/\n/\n\n- /g')" - # # GH actions hate multiline strings. https://trstringer.com/github-actions-multiline-strings/ - # changelog="${changelog//'%'/'%25'}" - # changelog="${changelog//$'\n'/'%0A'}" - # changelog="${changelog//$'\r'/'%0D'}" - # echo "changelog<> $GITHUB_ENV - # echo "$changelog" >> $GITHUB_ENV - # echo "EOF" >> $GITHUB_ENV - # echo "::set-output name=changelog::$changelog" - - # Actually build plugin - PATH=$PATH:/root/.cargo/bin:/opt/devkitpro/devkitA64/bin /root/.cargo/bin/cargo-skyline skyline build --release + run: cargo-skyline skyline build --release env: HOME: /root - name: Upload plugin artifact @@ -69,15 +48,16 @@ jobs: name: static path: src/static plugin_outside_training_mode: + name: Plugin NRO (Outside Training Mode) if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest container: - image: jugeeya/cargo-skyline:3.2.0 + image: jugeeya/cargo-skyline:3.2.0-no-dkp steps: - uses: actions/checkout@v2 - name: Build outside_training_mode NRO run: | - PATH=$PATH:/root/.cargo/bin:/opt/devkitpro/devkitA64/bin /root/.cargo/bin/cargo-skyline skyline build --release --features outside_training_mode + cargo-skyline skyline build --release --features outside_training_mode env: HOME: /root - name: Upload plugin (outside training mode) artifact @@ -86,6 +66,7 @@ jobs: name: plugin_outside_training_mode path: target/aarch64-skyline-switch/release/libtraining_modpack.nro upload: + name: Upload Beta Release runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' needs: @@ -134,10 +115,6 @@ jobs: name: beta body: > Beta built off of the latest code in the repository. - - ## Changelog - - ${{needs.plugin.outputs.changelog}} ## Installation diff --git a/src/lib.rs b/src/lib.rs index 4f4f79a..867410b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,8 +22,6 @@ mod hitbox_visualizer; mod training; mod logging; -#[cfg(test)] -mod test; use crate::common::*; use crate::events::{Event, EVENT_QUEUE}; @@ -99,7 +97,7 @@ pub fn main() { let ovl_path = "sd:/switch/.overlays/ovlTrainingModpack.ovl"; if fs::metadata(ovl_path).is_ok() { warn!("Removing ovlTrainingModpack.ovl..."); - fs::remove_file(ovl_path).expect(&format!("Could not remove {}", ovl_path)); + fs::remove_file(ovl_path).unwrap_or_else(|_| panic!("Could not remove {}", ovl_path)) } info!("Performing version check..."); @@ -109,7 +107,7 @@ pub fn main() { info!("Checking for previous menu in training_modpack_menu.json..."); if fs::metadata(menu_conf_path).is_ok() { let menu_conf = fs::read_to_string(menu_conf_path) - .expect(&format!("Could not remove {}", menu_conf_path)); + .unwrap_or_else(|_| panic!("Could not remove {}", menu_conf_path)); if let Ok(menu_conf_json) = serde_json::from_str::(&menu_conf) { unsafe { MENU = menu_conf_json.menu; @@ -118,10 +116,8 @@ pub fn main() { } } else { warn!("Previous menu found but is invalid. Deleting..."); - fs::remove_file(menu_conf_path).expect(&format!( - "{} has invalid schema but could not be deleted!", - menu_conf_path - )); + fs::remove_file(menu_conf_path) + .unwrap_or_else(|_| panic!("{} has invalid schema but could not be deleted!", menu_conf_path)); } } else { info!("No previous menu file found."); @@ -132,7 +128,7 @@ pub fn main() { if fs::metadata(combo_path).is_ok() { info!("Previous button combo settings found. Loading..."); let combo_conf = - fs::read_to_string(combo_path).expect(&format!("Could not read {}", combo_path)); + fs::read_to_string(combo_path).unwrap_or_else(|_| panic!("Could not remove {}", combo_path)); if button_config::validate_config(&combo_conf) { button_config::save_all_btn_config_from_toml(&combo_conf); } else { diff --git a/src/test.rs b/src/test.rs deleted file mode 100644 index 85807a9..0000000 --- a/src/test.rs +++ /dev/null @@ -1,33 +0,0 @@ -/// Recommended to run with the following command: -/// `RUSTFLAGS=-Awarnings cargo test --target=x86_64-unknown-linux-gnu` -/// But you can replace the target with your PC's target. - -/// This will run and render the default menu in your default HTML opening program, ideally Chrome. -#[test] -fn write_menu() { - unsafe { - use crate::common::menu::write_menu; - use std::process::Command; - - let folder_path = "../training_modpack.htdocs"; - let path = "../training_modpack.htdocs/training_menu.html"; - - assert!( - std::path::Path::new(folder_path).exists(), - "Needs required folder: ../training_modpack.htdocs!" - ); - - std::fs::write(path, write_menu()).unwrap(); - - let (cmd, args) = if wsl::is_wsl() || cfg!(target_os = "windows") { - ("cmd.exe", ["/C", "start", path]) - } else { - ("sh", ["-c", "open", path]) - }; - - Command::new(cmd) - .args(&args) - .output() - .expect("failed to open rendered HTML file"); - } -}