on: [push, pull_request]

name: CI

env:
  # --cfg=web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses
  # https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html
  # https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
  RUSTFLAGS: -D warnings --cfg=web_sys_unstable_apis
  RUSTDOCFLAGS: -D warnings

jobs:
  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          components: rustfmt
      - uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

  # trunk:
  #   name: trunk
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@v4
  #     - uses: actions-rs/toolchain@v1
  #       with:
  #         profile: minimal
  #         toolchain: stable
  #         target: wasm32-unknown-unknown
  #         override: true
  #     - name: Download and install Trunk binary
  #       working-directory: crates/rpack_egui
  #       run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
  #     - name: Build
  #       working-directory: crates/rpack_egui
  #       run: ./trunk build
  #     - uses: actions-rs/cargo@v1
  #       with:
  #         command: check
  #         args: --all-features --lib --target wasm32-unknown-unknown
