Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(tauri): migrate from v1 to v2 #158

Merged
merged 13 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
name: Cargo Audit
runs-on: 'ubuntu-latest'
container:
image: ivangabriele/tauri:debian-bookworm-18
image: ivangabriele/tauri:debian-bookworm-22
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
target: ['x86_64-unknown-linux-gnu']
runs-on: ubuntu-latest
container:
image: ivangabriele/tauri:debian-bookworm-18
image: ivangabriele/tauri:debian-bookworm-22
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: E2E (debian-latest)
runs-on: ubuntu-latest
container:
image: ivangabriele/tauri:debian-bookworm-18
image: ivangabriele/tauri:debian-bookworm-22
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
name: Test Core (debian-latest)
runs-on: ubuntu-latest
container:
image: ivangabriele/tauri:debian-bookworm-18
image: ivangabriele/tauri:debian-bookworm-22
options: --security-opt seccomp=unconfined
env:
PROJECT_ROOT_PATH: /__w/clamav-desktop/clamav-desktop
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

########################################
# Tauri

# Generated by Tauri
# will have schema files for capabilities auto-completion
/src-tauri/gen/schemas

########################################
# Yarn without Zero-Installs
# https://yarnpkg.com/getting-started/qa/#which-files-should-be-gitignored
Expand Down Expand Up @@ -194,4 +201,4 @@ cobertura.xml
/src-tauri/sidecars/*
!/src-tauri/sidecars/.gitkeep

*storybook.log
*storybook.log
122 changes: 64 additions & 58 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

- [Personal Note](#personal-note)
- [Getting started](#getting-started)
- [Requirements](#requirements)
- [Mandatory Requirements](#mandatory-requirements)
- [Optional Requirements](#optional-requirements)
- [Debian-based OS](#debian-based-os)
- [First setup](#first-setup)
- [1. Git (with submodules)](#1-git-with-submodules)
- [2. Webview with Yarn v3](#2-webview-with-yarn-v3)
- [3. Core with Tauri \& tauri-driver](#3-core-with-tauri--tauri-driver)
- [4. Final Check](#4-final-check)
- [5. Optional requirements](#5-optional-requirements)
- [Debian-based OS](#debian-based-os)
- [2. Webview](#2-webview)
- [3. Core](#3-core)
- [4. Run Check](#4-run-check)
- [5. Core \& E2E Testing](#5-core--e2e-testing)
- [Local development](#local-development)
- [Build a release](#build-a-release)
- [Binary (standalone)](#binary-standalone)
- [Debian-based OS (deb)](#debian-based-os-deb)
- [macOS (dmg)](#macos-dmg)
- [Windows 8+ (msi)](#windows-8-msi)
- [Windows 10+ (msi)](#windows-10-msi)
- [Tests](#tests)
- [Core unit tests](#core-unit-tests)
- [Webview unit tests](#webview-unit-tests)
Expand Down Expand Up @@ -52,14 +53,28 @@ installation.

## Getting started

### Requirements
### Mandatory Requirements

- [Node.js](https://nodejs.org) or [nvm](https://github.com/nvm-sh/nvm#installing-and-updating): v18
- [Yarn](https://yarnpkg.com/getting-started/install): v1
_(we actually use Yarn v4 but it's bundled in all the latest Yarn v1 releases)_
- [Rust](https://www.rust-lang.org/tools/install): v1
- [clamav](https://github.com/Cisco-Talos/clamav): binaries must be available as global commands (PATH)
- make: v4
- [Node.js v22](https://nodejs.org) or [nvm](https://github.com/nvm-sh/nvm#installing-and-updating)
- [Yarn](https://yarnpkg.com/getting-started/install)
- [Rust](https://www.rust-lang.org/tools/install)
- [Tauri v2 Prerequisities](https://v2.tauri.app/start/prerequisites/)
- make v4

### Optional Requirements

- [cargo-deb](https://github.com/kornelski/cargo-deb#installation) for debian bundle packaging.
- [cargo-edit](https://github.com/killercup/cargo-edit). for `cargo upgrade`-related commands (i.e.: `make upgrade`)
- [cargo-watch](https://github.com/watchexec/cargo-watch#install)
for `cargo watch`-related commands (i.e.: `make test-*-watch`).
- [ggshield](https://github.com/GitGuardian/ggshield#installation) for `yarn test:sec` command.

#### Debian-based OS

- [nsis](https://nsis.sourceforge.io/Main_Page):
```sh
sudo apt-get install nsis
```
Comment on lines +74 to +77
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Add blank lines around code block

According to markdown best practices (MD031), fenced code blocks should be surrounded by blank lines for better readability.

#### Debian-based OS

- [nsis](https://nsis.sourceforge.io/Main_Page):
+
  ```sh
  sudo apt-get install nsis

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Markdownlint</summary>

75-75: null
Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit -->


### First setup

Expand All @@ -73,77 +88,68 @@ Then run:
```sh
git clone https://github.com/ivangabriele/clamav-desktop.git # or your fork
cd ./clamav-desktop
yarn setup # to init, install and update Husky hooks / Git submodules
```

#### 2. Webview with Yarn v3

You may need to intall SDKs for your IDE/editor to handle Yarn v3: https://yarnpkg.com/getting-started/editor-sdks
(i.e.: `yarn dlx @yarnpkg/sdks vscode` if you're using VSCode).

Once you're ready, you can run:
#### 2. Webview

```sh
cd .. # if you are still in `./src-tauri` directory
yarn
```

#### 3. Core with Tauri & tauri-driver
#### 3. Core

To check the requirements related to Tauri, WebKitWebDriver (Linux) amd tauri-driver installations, please check:
You will to not only have to build ClamAV Desktop itself but also ClamAV binaries as well as the ClamAV Desktop Daemon.

- [Tauri Installation Guide](https://tauri.app/v1/guides/getting-started/prerequisites/#installing)
- [Tauri WebDriver System Dependencies](https://tauri.app/v1/guides/testing/webdriver/introduction/#system-dependencies)
- [Tauri WebDriver CI Guide](https://tauri.app/v1/guides/testing/webdriver/ci/)
I tried to simplify all these processes with automated command that will hopefully work as is:
Comment on lines +101 to +103
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix grammar in setup instructions

There's a grammatical error in this sentence.

-You will to not only have to build ClamAV Desktop itself but also ClamAV binaries as well as the ClamAV Desktop Daemon.
+You will not only have to build ClamAV Desktop itself but also ClamAV binaries as well as the ClamAV Desktop Daemon.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
You will to not only have to build ClamAV Desktop itself but also ClamAV binaries as well as the ClamAV Desktop Daemon.
- [Tauri Installation Guide](https://tauri.app/v1/guides/getting-started/prerequisites/#installing)
- [Tauri WebDriver System Dependencies](https://tauri.app/v1/guides/testing/webdriver/introduction/#system-dependencies)
- [Tauri WebDriver CI Guide](https://tauri.app/v1/guides/testing/webdriver/ci/)
I tried to simplify all these processes with automated command that will hopefully work as is:
You will not only have to build ClamAV Desktop itself but also ClamAV binaries as well as the ClamAV Desktop Daemon.
I tried to simplify all these processes with automated command that will hopefully work as is:
🧰 Tools
🪛 LanguageTool

[grammar] ~101-~101: Did you mean “do” or “too”?
Context: ... sh yarn #### 3. Core You will to not only have to build ClamAV Desktop i...

(PRONOUN_MD_TO)


> [!WARNING]
> If you're under Ubuntu v24, there is a [known issue](<[libwebkit2gtk-4.0-dev](https://github.com/tauri-apps/tauri/issues/9662)>) with `libwebkit2gtk-4.0-dev`.
> You can follow this workaround in the meantime:
>
> ```sh
> echo "deb http://archive.ubuntu.com/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/jammy.list
> sudo apt update
> sudo apt install libwebkit2gtk-4.0-dev
> sudo rm /etc/apt/sources.list.d/jammy.list
> sudo apt update
> ```
>
> It's not ideal but seem acceptable **only** for development purposes.
- **Debian:**
- Setup automated ClamAV binaries build: `sudo make setup-debian`
- Uninstall if exists, build, install and start ClamAV Desktop Daemon service: `yarn dev:daemon:linux`
- **macOS:**
- Setup automated ClamAV binaries build: `sudo make setup-macos`
- Uninstall if exists, build, install and start ClamAV Desktop Daemon service: `yarn dev:daemon:macos`
- **Windows:**
- No need to setup ClamAV binaries build on Windows for now
since their official standalone bundles are directly downloaded from their Github repository.
- Uninstall if exists, build, install and start ClamAV Desktop Daemon service: `yarn dev:daemon:windows`

Once you're ready, you can run:
Once you're ready, you can copy the custom Core dev config file:

```sh
cargo install tauri-driver
cd ./src-tauri
cp ./.cargo/config.toml.example ./.cargo/config.toml # and customize the content to match your local environment
cargo build
cp ./src-tauri/.cargo/config.toml.example ./src-tauri/.cargo/config.toml
```

#### 4. Final Check
and customize the content to match your local environment.

> [!TIP]
> If you want to check that your Core builds separately from the webview,
> you can just run `cd ./src-tauri && cargo build`.

#### 4. Run Check

You should now be able to run `yarn dev` which will launch the application (serving first the Webview on port 1420 and
then launching the Core desktop app embedding this Webview).

#### 5. Optional requirements
#### 5. Core & E2E Testing

- [cargo-deb](https://github.com/kornelski/cargo-deb#installation) for debian bundle packaging.
- [cargo-edit](https://github.com/killercup/cargo-edit). for `cargo upgrade`-related commands (i.e.: `make upgrade`)
- [cargo-watch](https://github.com/watchexec/cargo-watch#install) for `cargo watch`-related commands (i.e.:
`make test-*-watch`).
- [ggshield](https://github.com/GitGuardian/ggshield#installation) for `yarn test:sec` command.
First check and install the requirements related to WebDriver:

##### Debian-based OS
- [Tauri WebDriver Documentation](https://v2.tauri.app/develop/tests/webdriver/)
- [Tauri WebDriver Documentation for CI](https://v2.tauri.app/develop/tests/webdriver/ci/)

- [nsis](https://nsis.sourceforge.io/Main_Page):
```sh
sudo apt-get install nsis
```
Once you're ready, you can check core & e2e tests by running:

```sh
yarn test:unit:core # or `make test`
yarn test:e2e
```

### Local development

This will watch for file changes and automatically re-hydrate the webapp on the go:

```sh
yarn dev:daemon:[linux|macos|windows] # if updated
yarn dev
```

Expand Down Expand Up @@ -171,7 +177,7 @@ yarn bundle:deb
yarn bundle:dmg
```

### Windows 8+ (msi)
### Windows 10+ (msi)

```sh
yarn bundle:msi:arch64
Expand Down
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "cd ./src-tauri && cargo build",
"build:daemon": "cd ./daemon && cargo build",
"build:webview": "vite build",
"bundle:bin": "tauri build -b none",
"bundle:bin": "tauri build --no-bundle",
"bundle:deb": "tauri build -b deb",
"bundle:deb:x32": "TARGET=i686-unknown-linux-gnu yarn bundle:deb --target i686-unknown-linux-gnu",
"bundle:deb:x64": "TARGET=x86_64-unknown-linux-gnu yarn bundle:deb --target x86_64-unknown-linux-gnu",
Expand Down Expand Up @@ -60,7 +60,16 @@
"@fontsource/poppins": "5.0.16",
"@fontsource/reddit-mono": "5.0.5",
"@lezer/highlight": "1.2.1",
"@tauri-apps/api": "1.6.0",
"@tauri-apps/api": "2.0.3",
"@tauri-apps/plugin-clipboard-manager": "2.0.0",
"@tauri-apps/plugin-dialog": "2.0.1",
"@tauri-apps/plugin-fs": "2.0.1",
"@tauri-apps/plugin-global-shortcut": "2.0.0",
"@tauri-apps/plugin-http": "2.0.1",
"@tauri-apps/plugin-notification": "2.0.0",
"@tauri-apps/plugin-os": "2.0.0",
"@tauri-apps/plugin-process": "2.0.0",
"@tauri-apps/plugin-shell": "2.0.1",
"@uiw/codemirror-extensions-langs": "4.23.1",
"@uiw/codemirror-themes": "4.23.1",
"@uiw/react-codemirror": "4.23.1",
Expand Down Expand Up @@ -96,7 +105,7 @@
"@storybook/test": "8.3.0",
"@swc/core": "1.7.24",
"@swc/jest": "0.2.36",
"@tauri-apps/cli": "1.6.1",
"@tauri-apps/cli": "^2.0.0-rc.15",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
Expand Down
29 changes: 10 additions & 19 deletions scripts/dev/install_debian_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,17 @@ apt-get update

################################################################################
# Install Tauri build dependencies
# https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux
# https://v2.tauri.app/start/prerequisites/#linux
apt install -y \
build-essential \
curl \
wget \
file \
libssl-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev

if [[ "${OS_VERSION%%.*}" -ge 24 ]]; then
echo "deb http://archive.ubuntu.com/ubuntu jammy main" | tee /etc/apt/sources.list.d/jammy.list
apt-get update
apt-get install -y libwebkit2gtk-4.0-dev
rm /etc/apt/sources.list.d/jammy.list
apt-get update
else
apt install -y libwebkit2gtk-4.0-dev
fi
build-essential \
curl \
file \
libayatana-appindicator3-dev \
librsvg2-dev \
libssl-dev \
libwebkit2gtk-4.1-dev \
libxdo-dev \
wget

################################################################################
# Install ClamAV build dependencies
Expand Down
Empty file modified scripts/dev/install_linux_service.sh
100644 → 100755
Empty file.
Empty file modified scripts/dev/uninstall_linux_service.sh
100644 → 100755
Empty file.
Loading
Loading