diff --git a/.github/filters.yml b/.github/filters.yml new file mode 100644 index 00000000..c7dbdae4 --- /dev/null +++ b/.github/filters.yml @@ -0,0 +1,84 @@ +tauri-plugin-app: + - .github/test-rust.yml + - plugins/app/** +tauri-plugin-authenticator: + - .github/test-rust.yml + - plugins/authenticator/** +tauri-plugin-autostart: + - .github/test-rust.yml + - plugins/autostart/** +tauri-plugin-cli: + - .github/test-rust.yml + - plugins/cli/** +tauri-plugin-clipboard: + - .github/test-rust.yml + - plugins/clipboard/** +tauri-plugin-dialog: + - .github/test-rust.yml + - plugins/dialog/** +tauri-plugin-fs: + - .github/test-rust.yml + - plugins/fs/** +tauri-plugin-fs-wtach: + - .github/test-rust.yml + - plugins/fs-wtach/** +tauri-plugin-global-shortcut: + - .github/test-rust.yml + - plugins/global-shortcut/** +tauri-plugin-http: + - .github/test-rust.yml + - plugins/http/** +tauri-plugin-localhost: + - .github/test-rust.yml + - plugins/localhost/** +tauri-plugin-log: + - .github/test-rust.yml + - plugins/log/** +tauri-plugin-notification: + - .github/test-rust.yml + - plugins/notification/** +tauri-plugin-os: + - .github/test-rust.yml + - plugins/os/** +tauri-plugin-persisted-scope: + - .github/test-rust.yml + - plugins/persisted-scope/** +tauri-plugin-positioner: + - .github/test-rust.yml + - plugins/positioner/** +tauri-plugin-process: + - .github/test-rust.yml + - plugins/process/** +tauri-plugin-shell: + - .github/test-rust.yml + - plugins/shell/** +tauri-plugin-single-instance: + - .github/test-rust.yml + - plugins/single-instance/** +tauri-plugin-sql: + - .github/test-rust.yml + - plugins/sql/** +tauri-plugin-store: + - .github/test-rust.yml + - plugins/store/** +tauri-plugin-store: + - .github/test-rust.yml + - plugins/store/** +tauri-plugin-stronghold: + - .github/test-rust.yml + - plugins/stronghold/** +tauri-plugin-updater: + - .github/test-rust.yml + - plugins/updater/** +tauri-plugin-upload: + - .github/test-rust.yml + - plugins/upload/** +tauri-plugin-websocket: + - .github/test-rust.yml + - plugins/websocket/** +tauri-plugin-window: + - .github/test-rust.yml + - plugins/window/** +tauri-plugin-window-state: + - .github/test-rust.yml + - plugins/window-state/** \ No newline at end of file diff --git a/.github/workflows/test-rust.yml b/.github/workflows/test-rust.yml index b81a1ef9..9e4cd9f0 100644 --- a/.github/workflows/test-rust.yml +++ b/.github/workflows/test-rust.yml @@ -25,14 +25,28 @@ concurrency: cancel-in-progress: true jobs: - test: - runs-on: ${{ matrix.platform }} + changes: + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + packages: ${{ steps.filter.outputs.changes }} + steps: + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: .github/filters.yaml + test: + needs: changes strategy: fail-fast: false matrix: + package: ${{ fromJSON(needs.changes.outputs.packages) }} platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: - uses: actions/checkout@v3 @@ -42,12 +56,6 @@ jobs: sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev - - name: install openssl - if: matrix.platform == 'windows-latest' - run: | - echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append - vcpkg install openssl:x64-windows-static-md - - uses: dtolnay/rust-toolchain@1.65.0 - uses: Swatinem/rust-cache@v2 @@ -56,14 +64,18 @@ jobs: working-directory: examples/api run: mkdir dist - - name: build - run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features + - name: test ${{ package }} + if: matrix.package != 'tauri-plugin-sql' + run: cargo test --package ${{ matrix.package }} --all-targets - - name: build sql:sqlite - run: cargo build --package 'tauri-plugin-sql' --all-targets --features sqlite + - name: test ${{ package }} --all-features + if: ${{ !contains(fromJSON('["tauri-plugin-http", "tauri-plugin-upload", "tauri-plugin-updater", "tauri-plugin-webspcket", "tauri-plugin-sql"]', matrix.package)) }} + run: cargo test --package ${{ matrix.package }} --all-targets --all-features - - name: build sql:mysql - run: cargo build --package 'tauri-plugin-sql' --all-targets --features mysql + - name: test ${{ package }} mysql + if: matrix.package == 'tauri-plugin-sql' + run: cargo test --package ${{ matrix.package }} --all-targets --features mysql - - name: build sql:postgres - run: cargo build --package 'tauri-plugin-sql' --all-targets --features postgres + - name: test ${{ package }} postgres + if: matrix.package == 'tauri-plugin-sql' + run: cargo test --package ${{ matrix.package }} --all-targets --features postgres diff --git a/Cargo.lock b/Cargo.lock index 266a3c38..0893ade2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5767,9 +5767,13 @@ dependencies = [ "futures-util", "log", "native-tls", + "rustls", "tokio", "tokio-native-tls", + "tokio-rustls", "tungstenite", + "webpki", + "webpki-roots", ] [[package]] @@ -5926,10 +5930,12 @@ dependencies = [ "log", "native-tls", "rand 0.8.5", + "rustls", "sha1", "thiserror", "url", "utf-8", + "webpki", ] [[package]] diff --git a/plugins/http/Cargo.toml b/plugins/http/Cargo.toml index faf4371f..a292cbed 100644 --- a/plugins/http/Cargo.toml +++ b/plugins/http/Cargo.toml @@ -19,6 +19,7 @@ http = "0.2" reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] } [features] +default = [ "native-tls-vendored" ] multipart = [ "reqwest/multipart" ] native-tls = [ "reqwest/native-tls" ] native-tls-vendored = [ "reqwest/native-tls-vendored" ] diff --git a/plugins/sql/Cargo.toml b/plugins/sql/Cargo.toml index 91a839ac..3b9bd854 100644 --- a/plugins/sql/Cargo.toml +++ b/plugins/sql/Cargo.toml @@ -21,6 +21,7 @@ time = "0.3" tokio = { version = "1", features = ["sync"] } [features] +default = [ "sqlite" ] sqlite = ["sqlx/sqlite"] mysql = ["sqlx/mysql"] postgres = ["sqlx/postgres"] \ No newline at end of file diff --git a/plugins/updater/Cargo.toml b/plugins/updater/Cargo.toml index d4f036fa..9f88d468 100644 --- a/plugins/updater/Cargo.toml +++ b/plugins/updater/Cargo.toml @@ -35,6 +35,7 @@ mockito = "0.31" tokio-test = "0.4.2" [features] +default = [ "native-tls-vendored" ] native-tls = [ "reqwest/native-tls" ] native-tls-vendored = [ "reqwest/native-tls-vendored" ] rustls-tls = [ "reqwest/rustls-tls" ] diff --git a/plugins/upload/Cargo.toml b/plugins/upload/Cargo.toml index 49abc6d4..500addfc 100644 --- a/plugins/upload/Cargo.toml +++ b/plugins/upload/Cargo.toml @@ -19,4 +19,10 @@ tokio = { version = "1", features = [ "fs" ] } tokio-util = { version = "0.7", features = [ "codec" ] } reqwest = { version = "0.11", features = [ "json", "stream" ] } futures-util = "0.3" -read-progress-stream = "1.0.0" \ No newline at end of file +read-progress-stream = "1.0.0" + +[features] +default = [ "native-tls-vendored" ] +native-tls = [ "reqwest/native-tls" ] +native-tls-vendored = [ "reqwest/native-tls-vendored" ] +rustls-tls = [ "reqwest/rustls-tls" ] \ No newline at end of file diff --git a/plugins/websocket/Cargo.toml b/plugins/websocket/Cargo.toml index 37eafb5d..94f7a55c 100644 --- a/plugins/websocket/Cargo.toml +++ b/plugins/websocket/Cargo.toml @@ -19,3 +19,9 @@ rand = "0.8" futures-util = "0.3" tokio = { version = "1", features = ["net", "sync"] } tokio-tungstenite = { version = "0.18", features = ["native-tls"] } + +[features] +default = [ "native-tls-vendored" ] +native-tls = [ "tokio-tungstenite/native-tls" ] +native-tls-vendored = [ "tokio-tungstenite/native-tls-vendored" ] +rustls-tls-webpki-roots = [ "tokio-tungstenite/rustls-tls-webpki-roots" ]