1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-28 04:44:06 +00:00

[Github Action] no-dkp image; Move to cargo clippy as simple runner to fix PRs (#462)

* Update rust.yml

* Update rust.yml

* Update rust.yml

* Update rust.yml

* Update rust.yml

* Update rust.yml

* Fixes for clippy

* Fix clippy again

* Also run check

* Add names

* Remove rustfmt
This commit is contained in:
jugeeya 2023-01-31 15:17:00 -08:00 committed by GitHub
parent 6d312521d1
commit 5bb12d04fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 78 deletions

View file

@ -8,13 +8,11 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
clippy_pr: checker:
name: Check, Clippy
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: jugeeya/cargo-skyline:3.2.0
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup PATH
run: export PATH=$PATH:/root/.cargo/bin:/opt/devkitpro/devkitA64/bin
- name: Install minimal nightly rust - name: Install minimal nightly rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -23,39 +21,20 @@ jobs:
components: rustfmt, clippy components: rustfmt, clippy
default: true default: true
target: x86_64-unknown-linux-gnu target: x86_64-unknown-linux-gnu
- uses: actions-rs/clippy-check@v1 - name: Check
with: run: cargo +nightly check --target=x86_64-unknown-linux-gnu
token: ${{ secrets.GITHUB_TOKEN }} - name: Clippy
toolchain: nightly run: cargo +nightly clippy --all-targets --all-features --target=x86_64-unknown-linux-gnu
args: --all-features --target=x86_64-unknown-linux-gnu
- uses: mbrobbel/rustfmt-check@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
plugin: plugin:
name: Plugin NRO
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
changelog: ${{ steps.build_release.outputs.changelog }}
container: container:
image: jugeeya/cargo-skyline:3.2.0 image: jugeeya/cargo-skyline:3.2.0-no-dkp
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Build release NRO - name: Build release NRO
id: build_release id: build_release
run: | run: cargo-skyline skyline build --release
# # 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<<EOF" >> $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
env: env:
HOME: /root HOME: /root
- name: Upload plugin artifact - name: Upload plugin artifact
@ -69,15 +48,16 @@ jobs:
name: static name: static
path: src/static path: src/static
plugin_outside_training_mode: plugin_outside_training_mode:
name: Plugin NRO (Outside Training Mode)
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: jugeeya/cargo-skyline:3.2.0 image: jugeeya/cargo-skyline:3.2.0-no-dkp
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Build outside_training_mode NRO - name: Build outside_training_mode NRO
run: | 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: env:
HOME: /root HOME: /root
- name: Upload plugin (outside training mode) artifact - name: Upload plugin (outside training mode) artifact
@ -86,6 +66,7 @@ jobs:
name: plugin_outside_training_mode name: plugin_outside_training_mode
path: target/aarch64-skyline-switch/release/libtraining_modpack.nro path: target/aarch64-skyline-switch/release/libtraining_modpack.nro
upload: upload:
name: Upload Beta Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main'
needs: needs:
@ -135,10 +116,6 @@ jobs:
body: > body: >
Beta built off of the latest code in the repository. Beta built off of the latest code in the repository.
## Changelog
${{needs.plugin.outputs.changelog}}
## Installation ## Installation

View file

@ -22,8 +22,6 @@ mod hitbox_visualizer;
mod training; mod training;
mod logging; mod logging;
#[cfg(test)]
mod test;
use crate::common::*; use crate::common::*;
use crate::events::{Event, EVENT_QUEUE}; use crate::events::{Event, EVENT_QUEUE};
@ -99,7 +97,7 @@ pub fn main() {
let ovl_path = "sd:/switch/.overlays/ovlTrainingModpack.ovl"; let ovl_path = "sd:/switch/.overlays/ovlTrainingModpack.ovl";
if fs::metadata(ovl_path).is_ok() { if fs::metadata(ovl_path).is_ok() {
warn!("Removing ovlTrainingModpack.ovl..."); 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..."); info!("Performing version check...");
@ -109,7 +107,7 @@ pub fn main() {
info!("Checking for previous menu in training_modpack_menu.json..."); info!("Checking for previous menu in training_modpack_menu.json...");
if fs::metadata(menu_conf_path).is_ok() { if fs::metadata(menu_conf_path).is_ok() {
let menu_conf = fs::read_to_string(menu_conf_path) 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::<MenuJsonStruct>(&menu_conf) { if let Ok(menu_conf_json) = serde_json::from_str::<MenuJsonStruct>(&menu_conf) {
unsafe { unsafe {
MENU = menu_conf_json.menu; MENU = menu_conf_json.menu;
@ -118,10 +116,8 @@ pub fn main() {
} }
} else { } else {
warn!("Previous menu found but is invalid. Deleting..."); warn!("Previous menu found but is invalid. Deleting...");
fs::remove_file(menu_conf_path).expect(&format!( fs::remove_file(menu_conf_path)
"{} has invalid schema but could not be deleted!", .unwrap_or_else(|_| panic!("{} has invalid schema but could not be deleted!", menu_conf_path));
menu_conf_path
));
} }
} else { } else {
info!("No previous menu file found."); info!("No previous menu file found.");
@ -132,7 +128,7 @@ pub fn main() {
if fs::metadata(combo_path).is_ok() { if fs::metadata(combo_path).is_ok() {
info!("Previous button combo settings found. Loading..."); info!("Previous button combo settings found. Loading...");
let combo_conf = 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) { if button_config::validate_config(&combo_conf) {
button_config::save_all_btn_config_from_toml(&combo_conf); button_config::save_all_btn_config_from_toml(&combo_conf);
} else { } else {

View file

@ -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");
}
}