generated from kvnxiao/tauri-nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 21
220 lines (189 loc) · 10.3 KB
/
lint-rs.yml
File metadata and controls
220 lines (189 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# Installs Rust and checks formatting + linting
name: Lint Rust
on:
push:
branches:
- main
pull_request:
paths-ignore:
- "src/**"
- "package.json"
- "package-lock.json"
- "bun.lock"
- "pnpm-lock.yaml"
- "README.md"
jobs:
build:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Disable git core.autocrlf on Windows
if: matrix.os == 'windows-latest'
run: git config --global core.autocrlf false
- name: Checkout repository code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.90.0
components: rustfmt, clippy
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
# Install essential build tools and C/C++ headers first
sudo apt-get install -y build-essential gcc g++ make cmake
# Install Clang and LLVM for bindgen
sudo apt-get install -y clang libclang-dev llvm-dev
# Try to install specific clang version if available
sudo apt-get install -y libclang-14-dev || sudo apt-get install -y libclang-13-dev || sudo apt-get install -y libclang-12-dev || true
# Install standard library headers
sudo apt-get install -y libc6-dev linux-libc-dev
# Install other required dependencies
sudo apt-get install -y libwebkit2gtk-4.1-dev curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev
# Install FFmpeg and development libraries
sudo apt-get install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev libswscale-dev libswresample-dev pkg-config
- name: Setup FFmpeg environment for Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
echo "=== FFmpeg Header Location Fix ==="
# Check if headers are in expected location
if [ ! -f "/usr/include/libswscale/swscale.h" ]; then
echo "Headers not found in /usr/include, searching..."
# Find actual location
SWSCALE_PATHS=$(find /usr -name "swscale.h" 2>/dev/null)
echo "Found swscale.h at: $SWSCALE_PATHS"
# Find main header location
MAIN_SWSCALE=$(echo "$SWSCALE_PATHS" | grep "libswscale/swscale.h" | head -1)
if [ -n "$MAIN_SWSCALE" ]; then
BASE_DIR=$(dirname $(dirname "$MAIN_SWSCALE"))
echo "Found FFmpeg headers in: $BASE_DIR"
# Create symlinks
FFMPEG_LIBS=("libavcodec" "libavformat" "libavutil" "libswscale" "libavfilter" "libavdevice" "libswresample")
for lib in "${FFMPEG_LIBS[@]}"; do
if [ -d "$BASE_DIR/$lib" ] && [ ! -L "/usr/include/$lib" ]; then
sudo ln -sfn "$BASE_DIR/$lib" "/usr/include/$lib"
echo "✅ Created symlink: /usr/include/$lib -> $BASE_DIR/$lib"
fi
done
fi
fi
# Set PKG_CONFIG_PATH
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig" >> $GITHUB_ENV
# Find and set up libclang for bindgen
echo "=== Finding libclang ==="
# Find libclang.so
LIBCLANG_PATH=$(find /usr -name "libclang.so*" -type f 2>/dev/null | grep -E "libclang.so|libclang-[0-9]+.so" | head -1)
if [ -n "$LIBCLANG_PATH" ]; then
LIBCLANG_DIR=$(dirname "$LIBCLANG_PATH")
echo "Found libclang at: $LIBCLANG_PATH"
echo "Setting LIBCLANG_PATH=$LIBCLANG_DIR"
echo "LIBCLANG_PATH=$LIBCLANG_DIR" >> $GITHUB_ENV
else
echo "WARNING: libclang.so not found, trying default paths"
# Try common paths
for path in /usr/lib/llvm-*/lib /usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib; do
if [ -d "$path" ] && ls "$path"/libclang*.so* 2>/dev/null | grep -q .; then
echo "Found libclang in: $path"
echo "LIBCLANG_PATH=$path" >> $GITHUB_ENV
break
fi
done
fi
# Set up bindgen clang args
echo "BINDGEN_EXTRA_CLANG_ARGS=-I/usr/include -I/usr/include/x86_64-linux-gnu" >> $GITHUB_ENV
- name: Install macOS dependencies
if: matrix.os == 'macos-latest'
run: |
brew install ffmpeg pkg-config
echo "PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "FFMPEG_DIR=/opt/homebrew/opt/ffmpeg" >> $GITHUB_ENV
echo "FFMPEG_INCLUDE_DIR=/opt/homebrew/opt/ffmpeg/include" >> $GITHUB_ENV
echo "FFMPEG_LIB_DIR=/opt/homebrew/opt/ffmpeg/lib" >> $GITHUB_ENV
# Debug FFmpeg installation
echo "=== FFmpeg Installation Debug ==="
which ffmpeg || echo "ffmpeg not in PATH"
pkg-config --exists libavcodec && echo "✅ libavcodec found" || echo "❌ libavcodec not found"
pkg-config --cflags libavcodec || echo "No cflags"
pkg-config --libs libavcodec || echo "No libs"
ls -la /opt/homebrew/opt/ffmpeg/include/ | head -10
ls -la /opt/homebrew/opt/ffmpeg/lib/ | head -10
- name: Install Windows dependencies
if: matrix.os == 'windows-latest'
run: |
# Install pkg-config
choco install pkgconfiglite -y
# Install vcpkg
git clone https://github.com/Microsoft/vcpkg.git C:\vcpkg
C:\vcpkg\bootstrap-vcpkg.bat
C:\vcpkg\vcpkg integrate install
# Install FFmpeg via vcpkg
C:\vcpkg\vcpkg install ffmpeg:x64-windows
# Set environment variables
echo "VCPKG_ROOT=C:\vcpkg" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=C:\vcpkg\installed\x64-windows\lib\pkgconfig" >> $GITHUB_ENV
echo "FFMPEG_DIR=C:\vcpkg\installed\x64-windows" >> $GITHUB_ENV
echo "FFMPEG_INCLUDE_DIR=C:\vcpkg\installed\x64-windows\include" >> $GITHUB_ENV
echo "FFMPEG_LIB_DIR=C:\vcpkg\installed\x64-windows\lib" >> $GITHUB_ENV
echo "C:\vcpkg\installed\x64-windows\bin" >> $GITHUB_PATH
- name: Create empty 'dist' directory
run: mkdir dist
- name: Set up Node.js v22
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: "npm"
- name: Install dependencies on Unix
if: runner.os != 'Windows'
run: |
npm config set fetch-timeout 300000
npm config set fetch-retries 5
# Try to install with retries, excluding onnxruntime-node
npm ci --prefer-offline --no-audit --no-fund --omit=optional || \
npm install --no-audit --no-fund --omit=optional
# Install onnxruntime-node separately with retry logic
node ./scripts/install-onnxruntime.js || echo "onnxruntime-node installation failed, continuing..."
- name: Install dependencies on Windows
if: runner.os == 'Windows'
shell: pwsh
run: ./scripts/windows-npm-install.ps1
- name: Debug environment on macOS
if: matrix.os == 'macos-latest'
run: |
echo "=== Environment Variables ==="
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
echo "FFMPEG_DIR=$FFMPEG_DIR"
echo "FFMPEG_INCLUDE_DIR=$FFMPEG_INCLUDE_DIR"
echo "FFMPEG_LIB_DIR=$FFMPEG_LIB_DIR"
echo ""
echo "=== Cargo environment ==="
cd src-tauri
cargo --version
rustc --version
- name: Run rustfmt check
run: npm run format:rust:check
env:
PKG_CONFIG_PATH: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/lib/pkgconfig:/usr/local/lib/pkgconfig' || (matrix.os == 'windows-latest' && 'C:\vcpkg\installed\x64-windows\lib\pkgconfig' || '') }}
VCPKG_ROOT: ${{ matrix.os == 'windows-latest' && 'C:\vcpkg' || '' }}
FFMPEG_DIR: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/opt/ffmpeg' || (matrix.os == 'windows-latest' && 'C:\vcpkg\installed\x64-windows' || '') }}
FFMPEG_INCLUDE_DIR: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/opt/ffmpeg/include' || (matrix.os == 'windows-latest' && 'C:\vcpkg\installed\x64-windows\include' || '') }}
FFMPEG_LIB_DIR: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/opt/ffmpeg/lib' || (matrix.os == 'windows-latest' && 'C:\vcpkg\installed\x64-windows\lib' || '') }}
FFMPEG_SYS_DISABLE_X86ASM: ${{ matrix.os == 'windows-latest' && '1' || '' }}
CARGO_FEATURE_FFMPEG_SYS_DISABLE_X86ASM: ${{ matrix.os == 'windows-latest' && '1' || '' }}
FFMPEG_SYS_DISABLE_LINK: ${{ matrix.os == 'windows-latest' && '1' || '' }}
CARGO_FEATURE_FFMPEG_SYS_DISABLE_LINK: ${{ matrix.os == 'windows-latest' && '1' || '' }}
- name: Run clippy check and deny warnings
run: npm run lint:rust
env:
PKG_CONFIG_PATH: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/lib/pkgconfig:/usr/local/lib/pkgconfig' || (matrix.os == 'windows-latest' && 'C:\vcpkg\installed\x64-windows\lib\pkgconfig' || '') }}
VCPKG_ROOT: ${{ matrix.os == 'windows-latest' && 'C:\vcpkg' || '' }}
FFMPEG_DIR: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/opt/ffmpeg' || (matrix.os == 'windows-latest' && 'C:\vcpkg\installed\x64-windows' || '') }}
FFMPEG_INCLUDE_DIR: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/opt/ffmpeg/include' || (matrix.os == 'windows-latest' && 'C:\vcpkg\installed\x64-windows\include' || '') }}
FFMPEG_LIB_DIR: ${{ matrix.os == 'macos-latest' && '/opt/homebrew/opt/ffmpeg/lib' || (matrix.os == 'windows-latest' && 'C:\vcpkg\installed\x64-windows\lib' || '') }}
FFMPEG_SYS_DISABLE_X86ASM: ${{ matrix.os == 'windows-latest' && '1' || '' }}
CARGO_FEATURE_FFMPEG_SYS_DISABLE_X86ASM: ${{ matrix.os == 'windows-latest' && '1' || '' }}
FFMPEG_SYS_DISABLE_LINK: ${{ matrix.os == 'windows-latest' && '1' || '' }}
CARGO_FEATURE_FFMPEG_SYS_DISABLE_LINK: ${{ matrix.os == 'windows-latest' && '1' || '' }}