Skip to content

Commit b08a453

Browse files
authored
ci: smarter tests (#370)
1 parent ac76abc commit b08a453

8 files changed

Lines changed: 244 additions & 20 deletions

File tree

.github/workflows/lint-rust.yml

Lines changed: 110 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,108 @@ concurrency:
2323
cancel-in-progress: true
2424

2525
jobs:
26+
changes:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
pull-requests: read
30+
outputs:
31+
packages: ${{ steps.filter.outputs.changes }}
32+
steps:
33+
- uses: actions/checkout@v3
34+
- uses: dorny/paths-filter@v2
35+
id: filter
36+
with:
37+
filters: |
38+
tauri-plugin-app:
39+
- .github/workflows/lint-rust.yml
40+
- plugins/app/**
41+
tauri-plugin-authenticator:
42+
- .github/workflows/lint-rust.yml
43+
- plugins/authenticator/**
44+
tauri-plugin-autostart:
45+
- .github/workflows/lint-rust.yml
46+
- plugins/autostart/**
47+
tauri-plugin-cli:
48+
- .github/workflows/lint-rust.yml
49+
- plugins/cli/**
50+
tauri-plugin-clipboard:
51+
- .github/workflows/lint-rust.yml
52+
- plugins/clipboard/**
53+
tauri-plugin-dialog:
54+
- .github/workflows/lint-rust.yml
55+
- plugins/dialog/**
56+
- plugins/fs/**
57+
tauri-plugin-fs:
58+
- .github/workflows/lint-rust.yml
59+
- plugins/fs/**
60+
tauri-plugin-global-shortcut:
61+
- .github/workflows/lint-rust.yml
62+
- plugins/global-shortcut/**
63+
tauri-plugin-http:
64+
- .github/workflows/lint-rust.yml
65+
- plugins/http/**
66+
- plugins/fs/**
67+
tauri-plugin-localhost:
68+
- .github/workflows/lint-rust.yml
69+
- plugins/localhost/**
70+
tauri-plugin-log:
71+
- .github/workflows/lint-rust.yml
72+
- plugins/log/**
73+
tauri-plugin-notification:
74+
- .github/workflows/lint-rust.yml
75+
- plugins/notification/**
76+
tauri-plugin-os:
77+
- .github/workflows/lint-rust.yml
78+
- plugins/os/**
79+
tauri-plugin-persisted-scope:
80+
- .github/workflows/lint-rust.yml
81+
- plugins/persisted-scope/**
82+
- plugins/fs/**
83+
tauri-plugin-positioner:
84+
- .github/workflows/lint-rust.yml
85+
- plugins/positioner/**
86+
tauri-plugin-process:
87+
- .github/workflows/lint-rust.yml
88+
- plugins/process/**
89+
tauri-plugin-shell:
90+
- .github/workflows/lint-rust.yml
91+
- plugins/shell/**
92+
tauri-plugin-single-instance:
93+
- .github/workflows/lint-rust.yml
94+
- plugins/single-instance/**
95+
tauri-plugin-sql:
96+
- .github/workflows/lint-rust.yml
97+
- plugins/sql/**
98+
tauri-plugin-store:
99+
- .github/workflows/lint-rust.yml
100+
- plugins/store/**
101+
tauri-plugin-stronghold:
102+
- .github/workflows/lint-rust.yml
103+
- plugins/stronghold/**
104+
tauri-plugin-updater:
105+
- .github/workflows/lint-rust.yml
106+
- plugins/updater/**
107+
tauri-plugin-upload:
108+
- .github/workflows/lint-rust.yml
109+
- plugins/upload/**
110+
tauri-plugin-websocket:
111+
- .github/workflows/lint-rust.yml
112+
- plugins/websocket/**
113+
tauri-plugin-window:
114+
- .github/workflows/lint-rust.yml
115+
- plugins/window/**
116+
tauri-plugin-window-state:
117+
- .github/workflows/lint-rust.yml
118+
- plugins/window-state/**
119+
26120
clippy:
121+
needs: changes
122+
if: ${{ needs.changes.outputs.packages != '[]' && needs.changes.outputs.packages != '' }}
27123
runs-on: ubuntu-latest
28124
strategy:
29125
fail-fast: false
126+
matrix:
127+
package: ${{ fromJSON(needs.changes.outputs.packages) }}
30128

31129
steps:
32130
- uses: actions/checkout@v3
@@ -47,17 +145,21 @@ jobs:
47145
working-directory: examples/api
48146
run: mkdir dist
49147

50-
- name: clippy
51-
run: cargo clippy --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features -- -D warnings
148+
- name: clippy ${{ matrix.package }}
149+
if: matrix.package != 'tauri-plugin-sql'
150+
run: cargo clippy --package ${{ matrix.package }} --all-targets -- -D warnings
52151

53-
- name: clippy sql:sqlite
54-
run: cargo clippy --package 'tauri-plugin-sql' --all-targets --features sqlite -- -D warnings
152+
- name: clippy ${{ matrix.package }} --all-features
153+
if: ${{ !contains(fromJSON('["tauri-plugin-http", "tauri-plugin-upload", "tauri-plugin-updater", "tauri-plugin-websocket", "tauri-plugin-sql"]'), matrix.package) }}
154+
run: cargo clippy --package ${{ matrix.package }} --all-targets --all-features -- -D warnings
55155

56-
- name: clippy sql:mysql
57-
run: cargo clippy --package 'tauri-plugin-sql' --all-targets --features mysql -- -D warnings
156+
- name: clippy ${{ matrix.package }} mysql
157+
if: matrix.package == 'tauri-plugin-sql'
158+
run: cargo clippy --package ${{ matrix.package }} --all-targets --no-default-features --features mysql -- -D warnings
58159

59-
- name: clippy sql:postgres
60-
run: cargo clippy --package 'tauri-plugin-sql' --all-targets --features postgres -- -D warnings
160+
- name: clippy ${{ matrix.package }} postgres
161+
if: matrix.package == 'tauri-plugin-sql'
162+
run: cargo clippy --package ${{ matrix.package }} --all-targets --no-default-features --features postgres -- -D warnings
61163

62164
fmt:
63165
runs-on: ubuntu-latest

.github/workflows/test-rust.yml

Lines changed: 112 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,111 @@ concurrency:
2525
cancel-in-progress: true
2626

2727
jobs:
28-
test:
29-
runs-on: ${{ matrix.platform }}
28+
changes:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
pull-requests: read
32+
outputs:
33+
packages: ${{ steps.filter.outputs.changes }}
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: dorny/paths-filter@v2
37+
id: filter
38+
with:
39+
filters: |
40+
tauri-plugin-app:
41+
- .github/workflows/test-rust.yml
42+
- plugins/app/**
43+
tauri-plugin-authenticator:
44+
- .github/workflows/test-rust.yml
45+
- plugins/authenticator/**
46+
tauri-plugin-autostart:
47+
- .github/workflows/test-rust.yml
48+
- plugins/autostart/**
49+
tauri-plugin-cli:
50+
- .github/workflows/test-rust.yml
51+
- plugins/cli/**
52+
tauri-plugin-clipboard:
53+
- .github/workflows/test-rust.yml
54+
- plugins/clipboard/**
55+
tauri-plugin-dialog:
56+
- .github/workflows/test-rust.yml
57+
- plugins/dialog/**
58+
- plugins/fs/**
59+
tauri-plugin-fs:
60+
- .github/workflows/test-rust.yml
61+
- plugins/fs/**
62+
tauri-plugin-global-shortcut:
63+
- .github/workflows/test-rust.yml
64+
- plugins/global-shortcut/**
65+
tauri-plugin-http:
66+
- .github/workflows/test-rust.yml
67+
- plugins/http/**
68+
- plugins/fs/**
69+
tauri-plugin-localhost:
70+
- .github/workflows/test-rust.yml
71+
- plugins/localhost/**
72+
tauri-plugin-log:
73+
- .github/workflows/test-rust.yml
74+
- plugins/log/**
75+
tauri-plugin-notification:
76+
- .github/workflows/test-rust.yml
77+
- plugins/notification/**
78+
tauri-plugin-os:
79+
- .github/workflows/test-rust.yml
80+
- plugins/os/**
81+
tauri-plugin-persisted-scope:
82+
- .github/workflows/test-rust.yml
83+
- plugins/persisted-scope/**
84+
- plugins/fs/**
85+
tauri-plugin-positioner:
86+
- .github/workflows/test-rust.yml
87+
- plugins/positioner/**
88+
tauri-plugin-process:
89+
- .github/workflows/test-rust.yml
90+
- plugins/process/**
91+
tauri-plugin-shell:
92+
- .github/workflows/test-rust.yml
93+
- plugins/shell/**
94+
tauri-plugin-single-instance:
95+
- .github/workflows/test-rust.yml
96+
- plugins/single-instance/**
97+
tauri-plugin-sql:
98+
- .github/workflows/test-rust.yml
99+
- plugins/sql/**
100+
tauri-plugin-store:
101+
- .github/workflows/test-rust.yml
102+
- plugins/store/**
103+
tauri-plugin-stronghold:
104+
- .github/workflows/test-rust.yml
105+
- plugins/stronghold/**
106+
tauri-plugin-updater:
107+
- .github/workflows/test-rust.yml
108+
- plugins/updater/**
109+
tauri-plugin-upload:
110+
- .github/workflows/test-rust.yml
111+
- plugins/upload/**
112+
tauri-plugin-websocket:
113+
- .github/workflows/test-rust.yml
114+
- plugins/websocket/**
115+
tauri-plugin-window:
116+
- .github/workflows/test-rust.yml
117+
- plugins/window/**
118+
tauri-plugin-window-state:
119+
- .github/workflows/test-rust.yml
120+
- plugins/window-state/**
30121
122+
test:
123+
needs: changes
124+
if: ${{ needs.changes.outputs.packages != '[]' && needs.changes.outputs.packages != '' }}
31125
strategy:
32126
fail-fast: false
33127
matrix:
128+
package: ${{ fromJSON(needs.changes.outputs.packages) }}
34129
platform: [ubuntu-latest, macos-latest, windows-latest]
35130

131+
runs-on: ${{ matrix.platform }}
132+
36133
steps:
37134
- uses: actions/checkout@v3
38135

@@ -43,7 +140,7 @@ jobs:
43140
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev
44141
45142
- name: install openssl
46-
if: matrix.platform == 'windows-latest'
143+
if: ${{ matrix.platform == 'windows-latest' && matrix.package == 'tauri-plugin-authenticator' }}
47144
run: |
48145
echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
49146
vcpkg install openssl:x64-windows-static-md
@@ -56,14 +153,18 @@ jobs:
56153
working-directory: examples/api
57154
run: mkdir dist
58155

59-
- name: build
60-
run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features
156+
- name: test ${{ matrix.package }}
157+
if: matrix.package != 'tauri-plugin-sql'
158+
run: cargo test --package ${{ matrix.package }} --all-targets
61159

62-
- name: build sql:sqlite
63-
run: cargo build --package 'tauri-plugin-sql' --all-targets --features sqlite
160+
- name: test ${{ matrix.package }} --all-features
161+
if: ${{ !contains(fromJSON('["tauri-plugin-http", "tauri-plugin-upload", "tauri-plugin-updater", "tauri-plugin-websocket", "tauri-plugin-sql"]'), matrix.package) }}
162+
run: cargo test --package ${{ matrix.package }} --all-targets --all-features
64163

65-
- name: build sql:mysql
66-
run: cargo build --package 'tauri-plugin-sql' --all-targets --features mysql
164+
- name: test ${{ matrix.package }} mysql
165+
if: matrix.package == 'tauri-plugin-sql'
166+
run: cargo test --package ${{ matrix.package }} --all-targets --no-default-features --features mysql
67167

68-
- name: build sql:postgres
69-
run: cargo build --package 'tauri-plugin-sql' --all-targets --features postgres
168+
- name: test ${{ matrix.package }} postgres
169+
if: matrix.package == 'tauri-plugin-sql'
170+
run: cargo test --package ${{ matrix.package }} --all-targets --no-default-features --features postgres

Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/http/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ http = "0.2"
1919
reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] }
2020

2121
[features]
22+
default = [ "native-tls-vendored" ]
2223
multipart = [ "reqwest/multipart" ]
2324
native-tls = [ "reqwest/native-tls" ]
2425
native-tls-vendored = [ "reqwest/native-tls-vendored" ]

plugins/sql/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ time = "0.3"
2121
tokio = { version = "1", features = ["sync"] }
2222

2323
[features]
24+
default = [ "sqlite" ]
2425
sqlite = ["sqlx/sqlite"]
2526
mysql = ["sqlx/mysql"]
2627
postgres = ["sqlx/postgres"]

plugins/updater/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ mockito = "0.31"
3535
tokio-test = "0.4.2"
3636

3737
[features]
38+
default = [ "native-tls-vendored" ]
3839
native-tls = [ "reqwest/native-tls" ]
3940
native-tls-vendored = [ "reqwest/native-tls-vendored" ]
4041
rustls-tls = [ "reqwest/rustls-tls" ]

plugins/upload/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ tokio = { version = "1", features = [ "fs" ] }
1919
tokio-util = { version = "0.7", features = [ "codec" ] }
2020
reqwest = { version = "0.11", features = [ "json", "stream" ] }
2121
futures-util = "0.3"
22-
read-progress-stream = "1.0.0"
22+
read-progress-stream = "1.0.0"
23+
24+
[features]
25+
default = [ "native-tls-vendored" ]
26+
native-tls = [ "reqwest/native-tls" ]
27+
native-tls-vendored = [ "reqwest/native-tls-vendored" ]
28+
rustls-tls = [ "reqwest/rustls-tls" ]

plugins/websocket/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ rand = "0.8"
1919
futures-util = "0.3"
2020
tokio = { version = "1", features = ["net", "sync"] }
2121
tokio-tungstenite = { version = "0.18", features = ["native-tls"] }
22+
23+
[features]
24+
default = [ "native-tls-vendored" ]
25+
native-tls = [ "tokio-tungstenite/native-tls" ]
26+
native-tls-vendored = [ "tokio-tungstenite/native-tls-vendored" ]
27+
rustls-tls-webpki-roots = [ "tokio-tungstenite/rustls-tls-webpki-roots" ]

0 commit comments

Comments
 (0)