cohstats / coh3-stats-desktop-app

COH3 Desktop app with current match information and OBS overlay.
https://coh3stats.com
GNU General Public License v3.0
8 stars 5 forks source link

Improve CI/CD with check fmt and clippy #74

Open petrvecera opened 7 months ago

petrvecera commented 7 months ago

I'd recommend adding check, fmt, and clippy here as well for some general linting of the Rust code. There's an example of the setup here: https://github.com/ryantaylor/vault/blob/master/.github/workflows/checks.yml

HeyZoos commented 3 weeks ago

Lol I completely forgot about the Hacktoberfest thing, this tag has inspired me to register for it 😂 - mind if I tackle this one next?

petrvecera commented 3 weeks ago

Sure! :) Ideally we would add this before the build https://github.com/cohstats/coh3-stats-desktop-app/blob/master/.github/workflows/tests.yaml#L84 because the build will fail in forks due to missing dependencies.

petrvecera commented 3 weeks ago

Btw @HeyZoos I am not sure if you are familiar with Rust - I have personally done only stuff with Copilot in it :D But in our CI/CD tests when we run the tests, I don't understand why it Compiles all the dependencies again when it compiled them already before in the build step :/

https://github.com/cohstats/coh3-stats-desktop-app/actions/runs/11159161292/job/31016994798

Also I am not sure about this error:

Updating git repository `[https://github.com/tauri-apps/plugins-workspace`](https://github.com/tauri-apps/plugins-workspace%60)
error: invalid character `{` in package name: `tauri-plugin-{{name}}`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters)
 --> C:\Users\runneradmin\.cargo\git\checkouts\plugins-workspace-fd0259fcb18f51ad\cea1d4f\shared\template\Cargo.toml:2:8
  |
2 | name = "tauri-plugin-{{name}}"
  |        ^^^^^^^^^^^^^^^^^^^^^^^
  |

This is just bonus stuff in case you would know how it can be fixed. Thanks a lot for looking into this 🙏

HeyZoos commented 2 weeks ago

No worries, I'm not sure I understand the behavior either. I've gotten a bit busy with work but just wanted to let you know I'm still looking into this. 👍

HeyZoos commented 1 day ago

Hey so unfortunately it seems like the checks need to happen after the build.

   Compiling coh3-stats-desktop-app v1.5.3 (D:\a\coh3-stats-desktop-app\coh3-stats-desktop-app\src-tauri)
error: proc macro panicked
  --> src/main.rs:76:14
   |
76 |         .run(tauri::generate_context!())
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: message: The `distDir` configuration is set to `"../dist"` but this path doesn't exist

error: could not compile `coh3-stats-desktop-app` (bin "coh3-stats-desktop-app") due to 1 previous error
Error: Process completed with exit code 1.

This distDir issue indicates that in order to compile the Rust backend it's expecting the output of the frontend build to exist.

HeyZoos commented 1 day ago

How do you feel about removing the updater configuration from the tests.yaml workflow?

In the publish.yaml you bring it back when doing a full release when pushing a tag:

name: "publish"
on:
  push:
    tags:
      - "*"
            - name: "Full Bundle Tauri Release"
              run: |
                rm ./src-tauri/tauri.conf.json
                mv ./src-tauri/full-bundle-tauri.conf.json ./src-tauri/tauri.conf.json

            - name: "Build and release the app"
              uses: tauri-apps/tauri-action@v0
              env:
                GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
                TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
                TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
              with:
                tagName: __VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
                releaseName: "__VERSION__"
                releaseBody: "See the assets to download this version and install."
                releaseDraft: true
                prerelease: false
                includeUpdaterJson: false
HeyZoos commented 1 day ago

For the name = "tauri-plugin-{{name}}" issue I wonder if it's because most of the tauri-plugin-* dependencies are on the dev branch and not against the published libraries. It looks like most of these crates have 2.0.0 versions so this might be fixed when you migrate to Tauri 2

HeyZoos commented 1 day ago

Actually, it's transitively pulling in a template folder through one of the dependencies, this might be easy to fix

C:\Users\jesse\.cargo\git\checkouts\plugins-workspace-fd0259fcb18f51ad\cea1d4f\shared\template\Cargo.toml
HeyZoos commented 1 day ago

Yeah setting all the tauri-plugin-* dependencies to v1 seems to have done the trick

https://github.com/cohstats/coh3-stats-desktop-app/pull/168/commits/d0c6f12f646be590e5ff74fc8bbbb7f9322e89b8

HeyZoos commented 1 day ago

But in our CI/CD tests when we run the tests, I don't understand why it Compiles all the dependencies again when it compiled them already before in the build step :/

For this, I've noticed the builds are mixing the compilation modes, I wonder if that's causing cache misses. For example, these are all logs from the same build

2024-10-24T01:07:33.0986767Z    Compiling tauri-plugin-log v0.1.0 (https://github.com/tauri-apps/plugins-workspace?branch=dev#cea1d4f7)
2024-10-24T01:08:34.9747359Z     Finished `release` profile [optimized] target(s) in 3m 52s
2024-10-24T01:10:40.2872755Z    Compiling coh3-stats-desktop-app v1.5.3 (D:\a\coh3-stats-desktop-app\coh3-stats-desktop-app\src-tauri)
2024-10-24T01:10:43.2838308Z     Finished `dev` profile [unoptimized + debuginfo] target(s) in 1m 51s
2024-10-24T01:10:46.0688728Z    Compiling coh3-stats-desktop-app v1.5.3 (D:\a\coh3-stats-desktop-app\coh3-stats-desktop-app\src-tauri)
2024-10-24T01:10:49.3633437Z     Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.88s
2024-10-24T01:13:13.9291127Z    Compiling rev_lines v0.3.0
2024-10-24T01:13:19.2614107Z     Finished `test` profile [unoptimized + debuginfo] target(s) in 2m 29s
2024-10-24T01:13:19.2961716Z      Running unittests src\lib.rs (target\debug\deps\coh3_stats_desktop_app-718d9e165d5639b4.exe)
2024-10-24T01:13:53.9517150Z     Finished `release` profile [optimized] target(s) in 34.20s
2024-10-24T01:13:53.9737040Z   Installing C:\Users\runneradmin/.cargo\bin\tauri-driver.exe
2024-10-24T01:13:53.9744019Z    Installed package `tauri-driver v2.0.1` (executable `tauri-driver.exe`)