# Copyright © SixtyFPS GmbH <info@slint.dev>
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0

# This workflow checks out and build a bunch of crates that uses Slint,
# with the current branch

name: Crater

on:
    workflow_dispatch:

jobs:
    crater:
        env:
            SLINT_NO_QT: 1
            CARGO_INCREMENTAL: false
            RUST_BACKTRACE: 1
        strategy:
            fail-fast: false
            matrix:
                git_url:
                    # from madewithslint
                    - "https://github.com/slint-ui/cargo-ui"
                    - "https://github.com/GaspardCulis/slint-tetris"
                    #- "https://github.com/dngulin/gpcl" # depends on the winit backend
                    - "https://codeberg.org/flovansl/co_sl"
                    - "https://seed.radicle.garden/z3oxAZSLcyXgpa7fcvgtueF49jHpH.git" #vivi
                    #- "https://github.com/ElevenJune/mastermind_Rust" # Not upgraded to Slint 1.0
                    #- "https://github.com/Project-Trains/launcher" # Not upgraded to Slint 1.0
                    - "https://github.com/bjorn/raccoin"
                    - "https://gitlab.com/floers/ordinary"  #  Has `zip="*"` in its Cargo.toml
                    - "https://github.com/parchlinux/parch-welcome/"
                    #- "https://github.com/boclair/fractal-explorer"  # RE-ENABLE WHEN https://github.com/arturoc/color-rs/pull/2 is released
                    - "https://github.com/arunpkio/tymoz"
                    - "https://github.com/Surrealism-All/surrealism-ui-template"
                    - https://github.com/raykavin/market-prices-rust
                    - https://github.com/pezfisk/OxideManager
                    - https://github.com/m4rz3r0/foruster

                    # from crates.io
                    - "https://codeberg.org/drendog/frametrix"
                    - "https://github.com/hzqd/mycalc"
                    - "https://github.com/zilongyang/rust_slint_todos"
                    - "https://github.com/gavinshox/chess-oxide"
                    - "https://github.com/Obscurely/falion"
                    #- "https://github.com/abhay-n-j/warp-gui-app" (wrong edition in Cargo.toml)
                    - "https://github.com/dimas-fw/dimas"
                    - "https://github.com/vova-max-png/slintcalc"
                    - "https://github.com/moistpyro/land-calc"
                    - "https://github.com/clay-6/baze64"
                    - "https://github.com/Siiir/k_means-interactive/"
                    - "https://codeberg.org/waydeer/layer-shika"
                    - "https://github.com/limitcool/xm"
                    #- "https://github.com/vexide/vexide-slint"  # vexide somehow enable the error_in_core feature of snafu
                    - "https://github.com/ChenhuiZhang/envsensor-demo"
                    - "https://github.com/arunkumar-mourougappane/gjallarhorn-rs"
                    - "https://github.com/3axap4ehko/litra"
                    - "https://github.com/rezabani/modern-minesweeper"
                    - "https://github.com/guimath/phog"
                    - "https://github.com/mcbridejc/slint-evdev-input"
                    - "https://github.com/heathcliff26/turbo-clicker"


                    - "https://github.com/Decodetalkers/launchre"
                    - "https://github.com/Decodetalkers/haruhishot"
                    - "https://github.com/smalltext/trace-slint/"
                    # - "https://github.com/danrauch/thermocam" #  error: failed to run custom build command for `v4l2-sys-mit v0.2.0`
                    - "https://github.com/saturn77/magnet"

                    # - "https://github.com/zzq0097/mmm_rs" # could not compile `netease-cloud-music-api` (lib)
                    - "https://github.com/CMahaff/lasim" # many stars
                    #- "https://github.com/spades9/image-tools"  # compile error
                    - "https://github.com/studylessshape/calculator-by-rs"
                    - "https://github.com/gleb-skobinsky/system-metrics"
                    - "https://github.com/AccAutomaton/ECJTU-CAN-Helper"
                    - "https://github.com/Vadoola/pv-unlocker"
                    #- "https://github.com/zzoe/liando" # compile error in zstd-safe https://github.com/gyscos/zstd-rs/issues/270
                    - "https://github.com/Knowit-Objectnet/infoskjerm-trondheim"
                    - "https://github.com/CaleGlisson/Zelda_pattern_rust"
                    - "https://codeberg.org/dweiss96/rf2_league_mod_tool"
                    - "https://github.com/Badless/slint-editor"
                    - "https://github.com/IvanB101/hamming-huffman"
                    - "https://github.com/izuku0550/Custom-Note-Builder"
                    - "https://github.com/mrquantumoff/quadrant_lite"

                    - "https://github.com/jpnurmi/jpos-weather"
                    #- "https://github.com/osp-project/RizPackageTools" 404
                    - "https://github.com/xenein/CountMeDown-rs"
                    - "https://github.com/JeremiasMeister/rust-heightmap-generator"
                    - "https://github.com/joaofl/any-serve"
                    - "https://github.com/Heng30/rssbox"
                    - "https://github.com/Heng30/rssbox-android"
                    - "https://github.com/Heng30/uibox"
                    #- "https://github.com/Heng30/bitbox" #pinned slint-build version
                    #- "https://github.com/Heng30/solana-wallet-sollet" # error in dependency (pyth-sdk-solana)
                    - "https://github.com/nzhenev/vtbox"
                    #- "https://github.com/hambooooo/hamboo-rs" #uses nightly rust
                    # - "https://github.com/hambooooo/hamboo-embassy" #uses nightly rust
                    #- "https://github.com/Kllngii/Wetterstation"  # can't check submodules
                    - "https://github.com/tredeneo/simple-inventary-management" #uses sqlx that needs database access
                    # - "https://github.com/xcodes2cn/Xviewer" #copies slint
                    - "https://github.com/olishmollie/radix"
                    - "https://github.com/zivit/watchlist"
                    - "https://github.com/FelgoSDK/RustyWeather"
                    - "https://github.com/ThilinaTLM/docker_ui"
                    - "https://github.com/PlanetTeamSpeakk/Thermostat"
                    - "https://github.com/develcooking/Reelix"
                    - "https://github.com/Albino-Client/AlbinoLauncher"
                    - "https://github.com/radev1924/profit-first-income-calculator-desktop"
                    - "https://github.com/JarrodDoyle/slint-fmeditor"
                    - "https://github.com/planet0104/slint-noframe-window"
                    #- "https://github.com/Dusk-Labs/kira" uses private API
                    # - "https://github.com/TuEmb/can-viewer"   # depends on a deleted repo
                    # - "https://github.com/qhua948/anubis" # uses nightly rust
                    - "https://github.com/Surrealism-All/slimk"
                    - "https://github.com/BounceU/car_thang"
                    - "https://github.com/sloganking/codevis-gui"
                    - "https://github.com/CzNorbi/tic_tac_toe_ui"
                    - "https://github.com/remy2019/smtbr_gui"
                    - "https://github.com/mrandal/PDFer"
                    - "https://github.com/dhasoft-rs/7Seg-Slint-Widget"
                    # - "https://github.com/DraKraft/ozon-rs"  # Error: the trait `ToSql` is not implemented for `usize`
                    # - "https://github.com/SUP2Ak/Lur-Slint" # repo gone?
                    # - "https://github.com/foxboxpdx/melonstt" # repo gone?
                    - "https://github.com/sanyexieai/me_chat"
                    #- "https://github.com/oreo3494/rockpaper.git" # error because of `rand`
                    - "https://github.com/padangpanda/password-generator-desktop"
                    - "https://github.com/RealAdarsh/slint-guess-game"
                    - "https://github.com/DASPRiD/vrc-osc-manager"
                    - "https://github.com/beac0n/ruroco"

                    - "https://github.com/SergioRibera/Simplemoji"
                    - "https://github.com/Ashintosh/NoPass"
                    # - "https://github.com/Gremious/stickerbox" depends on unstable-wgpu-24
                    - "https://github.com/aenriii/rimgv"
                    - "https://github.com/Brayan-724/amosd"
                    - "https://github.com/kevinquillen/sysinfo"
                    - "https://github.com/home-cooked-firmware/hcui"
                    - "https://github.com/EinsPhoenix/MineSweeper-Rust"
                    - "https://github.com/themkoi/Cosmic-Wanderer"
                    - "https://github.com/xcrong/slint_data_processer"
                    - "https://github.com/Newlifer/peditor"
                    - "https://github.com/spineda2019/tRust"
                    - "https://github.com/franckKyete/tools-desktop"
                    - "https://github.com/zys60233/secret-box"
                    - "https://github.com/xjy12345654/css_parser"
                    - "https://github.com/zuyzz/app_flock"
                    #- "https://github.com/interstellarfrog/OG3-Pack-Updater" #zip2.6 is yanked
                    - "https://github.com/balicz3k/FileGuard"
                    - "https://github.com/ravioni-encoder/ravioni"
                    - "https://github.com/konmenel/tzimpouki"
                    - "https://github.com/TAlgorhythmic/dystellar-launcher-rs"
                    - "https://github.com/trappitsch/calculon"
                    - "https://github.com/Jaysmito101/slint-nav"
                    - "https://github.com/mq1/TinyWiiBackupManager"
                    - "https://github.com/jacquetc/qleany"
                    - https://github.com/taichi765/Tsukuyomi
                    - https://github.com/Cheikh-Nakamoto/Generateur-d-architecture-
                    - https://github.com/Spencer-0003/aletheia
                    - https://github.com/engels74/EasyHDR
                    - https://github.com/reedrosenbluth/oscen
                    - https://github.com/futo-org/fcast
                    - https://github.com/BiliRumble/Cloubit

                    # Missing images
                    # - "https://github.com/rurishigeo/Probe-Downloader"
                    # - "https://github.com/Tricked-dev/stardew-mod-manager"
                    # - "https://github.com/Erik7354/slint_minesweeper"
                    # - "https://github.com/guimath/GeoQuiz"


                    # Use our private API (eg: backend winit)
                    # - "https://github.com/Davide255/LVIE"
                    # - "https://github.com/Vadoola/Tomotroid"
                    # - "https://github.com/Horbin-Magician/rotor-rs"
                    # - "https://github.com/ilmai/plugin-things"
                    # - "https://github.com/Hoverth/keyboardthing"


                    # - "https://codeberg.org/moire/moire"  # Broken because of other dependencies.

                    # Needs extra dependencies
                    # - "https://github.com/nununoisy/gb-presenter-rs"
                    # - "https://github.com/nununoisy/nsf-presenter-rs"
                    # - "https://github.com/bombless/slint-tree"
                    # "https://github.com/AaronGulman/Rusty-CryptoMonitor"  (lua54)

                    #- "https://github.com/link9c/media_backup"  #(windows only (failed to resolve: use of undeclared crate or module `winres`))
                    #- "https://github.com/Vadoola/ignition_npp_tools" #windows only
                    #- "https://github.com/zloisupport/vanctrl" #windows only
                    #- "https://github.com/GRX005/McModManager-rs"
                    #- "https://github.com/un4ckn0wl3z/title-randomizer-rs"


                    # Not updated to Slint 1.0
                    #- "https://github.com/jannes/han-cihui"
                    #- "https://github.com/leofidus/ntfs-explorer"
                    #- "https://github.com/gsuyemoto/rust-bombfield"
                    #- "https://github.com/kizeevov/l5"
                    #- "https://github.com/SergioGasquez/espup-slint"

                sub_path: ["."]
                os: ["ubuntu-24.04"]

                include:
                    - git_url: "https://github.com/jturcotte/chiptrack"
                      sub_path: "."
                      extra_packages: libasound2-dev libfreetype-dev libfontconfig-dev
                    - git_url: "https://github.com/Futsch1/image-sieve"
                      sub_path: "."
                      extra_packages: libgtk-3-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev llvm libheif-dev
                    - git_url: "https://github.com/griccardos/rusl"
                      sub_path: "slint"
                    #- git_url: "https://github.com/DanielMadmon/tasker"  # needs "themis dep"
                    #  sub_path: "bin/tasker_gui"
                    # - git_url: "https://github.com/Kllngii/Wetterstation" # can't check submodules
                    #  sub_path: "wetterstation-ui"
                    - git_url: "https://github.com/plule/theremotion"
                      sub_path: "theremotion-ui"
                    - git_url: "https://github.com/matthiasbeyer/deskodon"
                      sub_path: "frontend"
                    - git_url: "https://github.com/malwaredb/malwaredb-rs"
                      extra_args: "--features=admin,admin-gui"
                      sub_path: "."
                    #- git_url: "https://github.com/Martoni/QRNote"  # Pins slint version
                    #  sub_path: "qr-note"
                    #- git_url: "https://github.com/planet0104/satellite_wallpaper"
                    #  sub_path: "."
                    #  os: windows-latest
                    #- git_url: "https://github.com/colelawrence/here-now" # Compile error
                    #  sub_path: "hn-desktop-ui"
                    - git_url: "https://github.com/MunyaradziMagura/Pomodoro"
                      sub_path: "pomodoro"
                    - git_url: "https://github.com/flukejones/asusctl"
                      sub_path: "rog-control-center"
                    #- git_url: "https://github.com/ellenhp/openlmr"  #doesn't compile
                    #  sub_path: "openlmr-core"
                    #- git_url: "https://github.com/jenkinsmichpa/coconut_crab"
                    #  sub_path: "coconut_crab_client"
                    #  os: windows-latest
                    - git_url: "https://github.com/ivabus/lonelyradio"
                      sub_path: "monoclient-s"
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libasound2-dev
                    - git_url: "https://github.com/ahqsoftwares/tauri-ahq-store"
                      sub_path: "src-setup"
                    - git_url: "https://github.com/qarmin/czkawka"
                      sub_path: krokiet
                    - git_url: "https://github.com/Vjze/Rust_demo"  # this is using SurrealismUI
                      sub_path: Rust_Slint
                    #- git_url: "https://github.com/LeeeSe/MessAuto"
                    #  os: macos-latest
                    #  sub_path: "."
                    - git_url: "https://github.com/planet0104/USB-Screen/"
                      extra_args: "--no-default-features --features=editor"
                      sub_path: "."
                    - git_url: "https://github.com/newfla/daily-strip"
                      sub_path: "."
                      extra_args: "--no-default-features --features=slint_frontend"
                    - git_url: "https://github.com/niqt/matrust/"
                      sub_path: "."
                    - git_url: "https://github.com/obhq/obliteration"
                      sub_path: "gui"
                    - git_url: "https://github.com/jaymedavis/romboy"
                      sub_path: "romboy"
                    #- git_url: "https://github.com/somantics/retrodungeon"  # compile error
                    #  sub_path: "."
                    #  extra_args: "--features=femtovg"
                    #- git_url: "https://github.com/jonfast565/runinator" # compile error (Used `MainWindow instead of `App` in rust)
                    #  sub_path: "command-center"
                    # - git_url: "https://github.com/stars-labs/mpc-wallet" # uses properties that don't exist  (AI hallucinations?)
                    #   sub_path: "apps/native-node"
                    - git_url: "https://github.com/larus-breeze/sw_frontend_rs"
                      sub_path: "device/sim"
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libasound2-dev
                    # - git_url: "https://github.com/gramistella/cornerstone"  # depends indirectly on old versions of crates (deno_ast/swc) that do not compile
                    #  sub_path: "frontend_slint"
                    - git_url: "https://github.com/dilo145/password_generator"
                      sub_path: "password_generator_gui"
                    - git_url: "https://github.com/DiD92/map-generator"
                      sub_path: "generator-ui"
                    - git_url: "https://github.com/Szybet/snake-slint"
                      sub_path: "snake_bin_std"
                    - git_url: "https://github.com/Heng30/flymoon"
                      sub_path: "flymoon"
                    - git_url: "https://github.com/gopher64/gopher64"
                      sub_path: "."
                      extra_packages: libpipewire-0.3-dev libwayland-dev libdecor-0-dev liburing-dev cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libfribidi-dev libsndio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev
                    - git_url: "https://github.com/PonasKovas/salix"
                      sub_path: "client-gui"
                    - git_url: "https://github.com/chrishengler/terraingen"
                      sub_path: "gui-slint"
                    - git_url: "https://github.com/Vinegret43/dispute"
                      sub_path: "."
                      extra_packages: libdbus-1-dev alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev
                    - git_url: "https://github.com/Heng30/chatbox"
                      sub_path: "."
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libjack-jackd2-dev
                    - git_url: "https://github.com/Risuleia/Tranquilo"
                      sub_path: "."
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libjack-jackd2-dev
                    - git_url: "https://github.com/R3alCl0ud/Rust4Diva"
                      sub_path: "."
                      extra_packages: libarchive-dev
                    - git_url: "https://github.com/Enn3Developer/n_music"
                      extra_packages: libasound2-dev libfontconfig-dev libfreetype-dev
                      sub_path: "n_player"
                    - git_url: "https://github.com/BiliRumble/Cloubit"
                      sub_path: "."
                      extra_packages:  build-essential perl nasm libasound2-dev pkg-config
                    - git_url: "https://github.com/TsaoLun/always-blue"
                      sub_path: "."
                      extra_packages: libasound2-dev libfreetype-dev libfontconfig-dev
                    - git_url: "https://github.com/jturcotte/beskope"
                      sub_path: "."
                      extra_packages: libasound2-dev libfreetype-dev libfontconfig-dev libpipewire-0.3-dev
                    - git_url: "https://github.com/sloganking/quick-assistant"
                      sub_path: "."
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libasound2-dev
                    - git_url: "https://github.com/laycookie/record"
                      sub_path: "."
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libasound2-dev
                    - git_url: "https://github.com/Danila-Bain/wav-wav"
                      sub_path: "."
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libasound2-dev
                    - git_url: "https://github.com/mackler/Lodge-Musician"
                      sub_path: "."
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libasound2-dev
                    - git_url: "https://github.com/game-exchange-token/gxt"
                      sub_path: "gxt-cli"
                      extra_args: "--features=ui"
                    - git_url: "https://github.com/paulusminus/lipl-display"
                      sub_path: "crates/lipl-display-slint"
                    - git_url: "https://github.com/vimyoung/spell"
                      sub_path: "spell-framework"
                    - git_url: "https://github.com/Farmadupe/vid_dup_finder_lib"
                      sub_path: vid_dup_finder_app
                    - git_url: "https://github.com/simmsb/inkview-rs"
                      sub_path: inkview-slint
                    - git_url: "https://codeberg.org/psylink/psylink"
                    - git_url: "https://github.com/shuntia/bestest"
                      extra_args: "--features=gui"
                    - git_url: https://github.com/Konstantin-Dudersky/rsiot
                      extra_args: "--features=cmp_slint"
                    - git_url: https://github.com/Szybet/snake-slint/
                      sub_path: "snake_bin_std"
                    - git_url: https://github.com/maplibre/maplibre-native-slint
                      sub_path: rust
                    - git_url: https://github.com/AgustinSRG/PersonalMediaVault
                      sub_path: launcher-gui
                    - git_url: https://github.com/MERCorg/merc
                      sub_path: tools/gui
                    - git_url: https://github.com/guycorbaz/rbibli
                      sub_path: frontend
                    - git_url: https://github.com/tadghh/transparent-windows
                      extra_args: "--features=tray-item/ksni"
                    - git_url: "https://codeberg.org/vivi-ui/lili"
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libasound2-dev
                    - git_url: "https://github.com/bandipapa/rsaber"
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libasound2-dev
                    - git_url: "https://github.com/heng30/wayshot"
                      extra_packages: alsa-utils libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libasound2-dev
                    - git_url: https://github.com/heng30/tasklog
                      sub_path: tasklog
                      extra_args: "--features=desktop"



        runs-on: "ubuntu-latest"
        steps:
            - uses: actions/checkout@v6
            - uses: ./.github/actions/install-linux-dependencies
              if: runner.os == 'Linux'
              with:
                  extra-packages: libpango1.0-dev libgtk-3-dev libatk1.0-dev libjack-jackd2-dev autoconf libxcb-xrm0 libxcb-xrm-dev automake  libxcb-keysyms1-dev libxcb-util0-dev libxcb-icccm4-dev libyajl-dev libstartup-notification0-dev libxcb-randr0-dev libev-dev libxcb-cursor-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev libudev-dev clang pkg-config nasm libsoup2.4-dev libfuse3-dev libx11-xcb-dev  ${{ matrix.extra_packages }}
            # Don't use the cache because we don't run this job often, and it would cache the .cargo/config.toml with extra keys
            - uses: dtolnay/rust-toolchain@master
              with:
                  toolchain: stable
            - name: setup patch
              run: |
                  echo "" >> ~/.cargo/config.toml
                  echo [patch.crates-io] >> ~/.cargo/config.toml
                  echo slint = { path = \"$GITHUB_WORKSPACE/api/rs/slint\" } >> ~/.cargo/config.toml
                  echo slint-build = { path = \"$GITHUB_WORKSPACE/api/rs/build\" }  >> ~/.cargo/config.toml
                  echo slint-interpreter = { path = \"$GITHUB_WORKSPACE/internal/interpreter\" }  >> ~/.cargo/config.toml
                  echo i-slint-backend-winit = { path = \"$GITHUB_WORKSPACE/internal/backends/winit\" }  >> ~/.cargo/config.toml
                  echo i-slint-core = { path = \"$GITHUB_WORKSPACE/internal/core\" }  >> ~/.cargo/config.toml
            - name: Checkout the repo
              run: |
                  cd $HOME
                  git clone ${{ matrix.git_url }}  the_repo --depth 1
                  cd the_repo
                  git submodule update --init --recursive
            - name: build
              run: |
                  cd $HOME/the_repo
                  rm -r rust-toolchain.toml .cargo/config.toml || true
                  cd ./${{ matrix.sub_path }}
                  sed -i "s/{{project-name}}/the-project/" Cargo.toml
                  cargo update
                  cargo check ${{ matrix.extra_args }}


# Slint only: how can we test them?
# https://github.com/Surrealism-All/SurrealismUI
# https://github.com/8yteDance/SlintSubMenu

# C++
# https://github.com/LeVietXuanKG/TodoApp_Slint
# https://github.com/NatnaelTaddese/slint_cpp_bilinear_interpolation
# https://github.com/vudinhkhoa0/DEMO_DOAN_CTDL-GT
# https://github.com/progzone122/micropad
