2828 workflow_dispatch :
2929
3030env :
31- GO_VERSION : " 1.24 "
31+ GO_VERSION : " 1.25 "
3232 FLUTTER_VERSION : " 3.41.6"
3333
3434jobs :
@@ -50,21 +50,77 @@ jobs:
5050 runs-on : ubuntu-latest
5151 steps :
5252 - uses : actions/checkout@v3
53- - uses : actions/setup-go@v4
53+ - uses : actions/setup-go@v5
5454 with :
5555 go-version : ${{ env.GO_VERSION }}
56+ - name : Install webview dependencies
57+ run : |
58+ sudo apt-get update -y
59+ sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev xvfb
5660 - name : Run Unit tests.
5761 run : |
5862 # Get packages for testing and coverage (including cmd/web for flags_test.go)
59- PACKAGES=$(go list ./... | grep -v / bind/ | grep -v -E '/ cmd/(?! web)')
60- go test -v -coverpkg=$(echo "$PACKAGES" | paste -sd "," -) -covermode=count -coverprofile=coverage.txt $PACKAGES
63+ PACKAGES=$(go list ./... | awk '!/\/ bind\// && (!/\/cmd\// || /\/ cmd\/ web$/ )')
64+ env CGO_ENABLED=1 xvfb-run -a go test -tags webview -v -coverpkg=$(echo "$PACKAGES" | paste -sd "," -) -covermode=count -coverprofile=coverage.txt $PACKAGES
6165 # Filter out main.go from coverage report to avoid lowering coverage percentage
6266 grep -v "main.go" coverage.txt > coverage_filtered.txt || true
6367 mv coverage_filtered.txt coverage.txt
6468 - uses : codecov/codecov-action@v4
6569 with :
6670 files : ./coverage.txt
6771 token : ${{ secrets.CODECOV_UPLOAD_TOKEN }}
72+ test-webview-integration :
73+ name : Test webview integration (${{ matrix.name }})
74+ strategy :
75+ fail-fast : false
76+ matrix :
77+ include :
78+ - name : Windows
79+ os : windows-latest
80+ - name : macOS
81+ os : macos-latest
82+ runs-on : ${{ matrix.os }}
83+ steps :
84+ - uses : actions/checkout@v3
85+ - uses : actions/setup-go@v5
86+ with :
87+ go-version : ${{ env.GO_VERSION }}
88+ - uses : subosito/flutter-action@v2
89+ if : runner.os == 'macOS'
90+ with :
91+ flutter-version : ${{ env.FLUTTER_VERSION }}
92+ - name : Test webview
93+ if : runner.os == 'Windows'
94+ run : go test -tags webview -v -timeout 300s ./internal/webview/goprovider/
95+ env :
96+ CGO_ENABLED : 1
97+ - name : Test webview
98+ if : runner.os == 'macOS'
99+ shell : bash
100+ run : |
101+ set -euo pipefail
102+ SOCKET_PATH="$HOME/Library/Application Support/com.gopeed.gopeed/gopeed_webview.sock"
103+ LOG_PATH="$RUNNER_TEMP/gopeed-webview-rpc.log"
104+ rm -f "$SOCKET_PATH"
105+
106+ go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/macos/Frameworks/libgopeed.dylib github.com/GopeedLab/gopeed/bind/desktop
107+
108+ cd ui/flutter
109+ flutter pub get
110+ flutter run -d macos >"$LOG_PATH" 2>&1 &
111+ FLUTTER_PID=$!
112+ cd ../..
113+
114+ cleanup() {
115+ kill "$FLUTTER_PID" >/dev/null 2>&1 || true
116+ }
117+ trap cleanup EXIT
118+
119+ if ! go test -tags webview -v -timeout 600s ./internal/webview/rpcprovider/ -args -webview-rpc-network unix -webview-rpc-address "$SOCKET_PATH"; then
120+ cat "$LOG_PATH"
121+ exit 1
122+ fi
123+
68124 build-desktop :
69125 strategy :
70126 matrix :
80136 flutter_channel : " main"
81137 name : Build desktop check (${{ matrix.os }})
82138 runs-on : ${{ matrix.os }}
83- needs : [test]
139+ needs : [ test ]
84140 steps :
85141 - uses : actions/checkout@v3
86142 - name : Enable long paths for flutter main branch checks
@@ -109,7 +165,7 @@ jobs:
109165 "CGO_ENABLED=1" >> $env:GITHUB_ENV
110166 "CLANGARM64_ROOT=$target" >> $env:GITHUB_ENV
111167 $b >> $env:GITHUB_PATH
112- - uses : actions/setup-go@v4
168+ - uses : actions/setup-go@v5
113169 with :
114170 go-version : ${{ env.GO_VERSION }}
115171 - uses : subosito/flutter-action@v2
@@ -129,7 +185,7 @@ jobs:
129185 - if : runner.os == 'Linux'
130186 run : |
131187 sudo apt-get update -y
132- sudo apt-get install -y ninja-build libgtk-3-dev libayatana-appindicator3-dev libkeybinder-3.0-dev
188+ sudo apt-get install -y ninja-build libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libkeybinder-3.0-dev
133189 go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/linux/bundle/lib/libgopeed.so github.com/GopeedLab/gopeed/bind/desktop
134190 cd ui/flutter
135191 flutter build linux
@@ -138,11 +194,11 @@ jobs:
138194 runs-on : ${{ matrix.os }}
139195 strategy :
140196 matrix :
141- os : [macos-14, ubuntu-latest]
142- needs : [test]
197+ os : [ macos-14, ubuntu-latest ]
198+ needs : [ test ]
143199 steps :
144200 - uses : actions/checkout@v3
145- - uses : actions/setup-go@v4
201+ - uses : actions/setup-go@v5
146202 with :
147203 go-version : ${{ env.GO_VERSION }}
148204 - uses : subosito/flutter-action@v2
@@ -171,10 +227,10 @@ jobs:
171227 build-web :
172228 name : Build web check
173229 runs-on : ubuntu-latest
174- needs : [test]
230+ needs : [ test ]
175231 steps :
176232 - uses : actions/checkout@v3
177- - uses : actions/setup-go@v4
233+ - uses : actions/setup-go@v5
178234 with :
179235 go-version : ${{ env.GO_VERSION }}
180236 - uses : subosito/flutter-action@v2
@@ -192,10 +248,10 @@ jobs:
192248 build-docker :
193249 name : Build docker check
194250 runs-on : ubuntu-latest
195- needs : [test]
251+ needs : [ test ]
196252 steps :
197253 - uses : actions/checkout@v3
198- - uses : actions/setup-go@v4
254+ - uses : actions/setup-go@v5
199255 with :
200256 go-version : ${{ env.GO_VERSION }}
201257 - uses : subosito/flutter-action@v2
0 commit comments