diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index cbf9a6f..8213a56 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -274,7 +274,7 @@ jobs: - name: Setup MSYS2 Toolchain For DuckDB (Windows AMD64) id: msys2_duckdb - if: ${{ matrix.build_optional_agents && matrix.platform == 'windows/amd64' && contains(format(',{0},', needs.driver_agents.outputs.drivers), ',duckdb,') }} + if: ${{ matrix.platform == 'windows/amd64' }} continue-on-error: true uses: msys2/setup-msys2@v2 with: @@ -284,7 +284,7 @@ jobs: mingw-w64-ucrt-x86_64-gcc - name: Configure DuckDB CGO Toolchain (Windows AMD64) - if: ${{ matrix.build_optional_agents && matrix.platform == 'windows/amd64' && contains(format(',{0},', needs.driver_agents.outputs.drivers), ',duckdb,') }} + if: ${{ matrix.platform == 'windows/amd64' }} shell: pwsh run: | function Find-MingwBin([string[]]$candidates) { @@ -342,7 +342,7 @@ jobs: Write-Host "✅ 已配置 DuckDB cgo 编译器: gcc=$gcc g++=$gxx" - name: Verify DuckDB CGO Toolchain (Windows AMD64) - if: ${{ matrix.build_optional_agents && matrix.platform == 'windows/amd64' && contains(format(',{0},', needs.driver_agents.outputs.drivers), ',duckdb,') }} + if: ${{ matrix.platform == 'windows/amd64' }} shell: pwsh run: | & "$env:CC" --version @@ -360,16 +360,11 @@ jobs: - name: Build shell: bash - env: - CHANGED_DRIVER_AGENTS: ${{ needs.driver_agents.outputs.drivers }} run: | set -euo pipefail DEV_VERSION="${{ steps.version.outputs.version }}" - if [ -n "$CHANGED_DRIVER_AGENTS" ]; then - ./tools/generate-driver-agent-revisions.sh --platform "${{ matrix.platform }}" --drivers "$CHANGED_DRIVER_AGENTS" - else - echo "🧭 No driver-agent changes; keeping committed driver revisions" - fi + echo "🧭 为 ${{ matrix.platform }} 全量生成 driver-agent revision 指纹,避免跨平台沿用旧 revision" + ./tools/generate-driver-agent-revisions.sh --platform "${{ matrix.platform }}" if [ -n "${{ matrix.wails_tags }}" ]; then wails build -s -skipbindings -platform ${{ matrix.platform }} -clean -o ${{ matrix.build_name }} -tags "${{ matrix.wails_tags }}" -ldflags "-s -w -X GoNavi-Wails/internal/app.AppVersion=${DEV_VERSION}" else diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e9e2cd..295b407 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -255,7 +255,7 @@ jobs: - name: Setup MSYS2 Toolchain For DuckDB (Windows AMD64) id: msys2_duckdb - if: ${{ matrix.build_optional_agents && matrix.platform == 'windows/amd64' && contains(format(',{0},', needs.driver_agents.outputs.drivers), ',duckdb,') }} + if: ${{ matrix.platform == 'windows/amd64' }} continue-on-error: true uses: msys2/setup-msys2@v2 with: @@ -265,7 +265,7 @@ jobs: mingw-w64-ucrt-x86_64-gcc - name: Configure DuckDB CGO Toolchain (Windows AMD64) - if: ${{ matrix.build_optional_agents && matrix.platform == 'windows/amd64' && contains(format(',{0},', needs.driver_agents.outputs.drivers), ',duckdb,') }} + if: ${{ matrix.platform == 'windows/amd64' }} shell: pwsh run: | function Find-MingwBin([string[]]$candidates) { @@ -323,7 +323,7 @@ jobs: Write-Host "✅ 已配置 DuckDB cgo 编译器: gcc=$gcc g++=$gxx" - name: Verify DuckDB CGO Toolchain (Windows AMD64) - if: ${{ matrix.build_optional_agents && matrix.platform == 'windows/amd64' && contains(format(',{0},', needs.driver_agents.outputs.drivers), ',duckdb,') }} + if: ${{ matrix.platform == 'windows/amd64' }} shell: pwsh run: | & "$env:CC" --version @@ -331,15 +331,10 @@ jobs: - name: Build shell: bash - env: - CHANGED_DRIVER_AGENTS: ${{ needs.driver_agents.outputs.drivers }} run: | set -euo pipefail - if [ -n "$CHANGED_DRIVER_AGENTS" ]; then - ./tools/generate-driver-agent-revisions.sh --platform "${{ matrix.platform }}" --drivers "$CHANGED_DRIVER_AGENTS" - else - echo "🧭 No driver-agent changes; keeping committed driver revisions" - fi + echo "🧭 为 ${{ matrix.platform }} 全量生成 driver-agent revision 指纹,避免跨平台沿用旧 revision" + ./tools/generate-driver-agent-revisions.sh --platform "${{ matrix.platform }}" if [ -n "${{ matrix.wails_tags }}" ]; then wails build -s -skipbindings -platform ${{ matrix.platform }} -clean -o ${{ matrix.build_name }} -tags "${{ matrix.wails_tags }}" -ldflags "-s -w -X GoNavi-Wails/internal/app.AppVersion=${{ github.ref_name }}" else diff --git a/tools/generate-driver-agent-revisions.test.sh b/tools/generate-driver-agent-revisions.test.sh new file mode 100644 index 0000000..f74cd92 --- /dev/null +++ b/tools/generate-driver-agent-revisions.test.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$SCRIPT_DIR" + +extract_revision() { + local file="$1" + local driver="$2" + sed -n "s/.*\"${driver}\"[[:space:]]*:[[:space:]]*\"\\([^\"]*\\)\".*/\\1/p" "$file" | head -n 1 +} + +run_case() { + local platform="$1" + local drivers="$2" + local tmpdir + tmpdir="$(mktemp -d "${TMPDIR:-/tmp}/gonavi-generate-driver-revisions.XXXXXX")" + trap 'rm -rf "$tmpdir"' RETURN + + rsync -a --exclude .git ./ "$tmpdir/" >/dev/null + ( + cd "$tmpdir" + GONAVI_DRIVER_REVISION_JOBS=1 bash ./tools/generate-driver-agent-revisions.sh --platform "$platform" --drivers "$drivers" >/dev/null + cat internal/db/driver_agent_revisions_gen.go + ) +} + +darwin_output="$(run_case darwin/arm64 mariadb,duckdb)" +windows_output="$(run_case windows/amd64 mariadb,duckdb)" + +darwin_file="$(mktemp "${TMPDIR:-/tmp}/gonavi-darwin-revisions.XXXXXX")" +windows_file="$(mktemp "${TMPDIR:-/tmp}/gonavi-windows-revisions.XXXXXX")" +cleanup() { + rm -f "$darwin_file" "$windows_file" +} +trap cleanup EXIT + +printf '%s\n' "$darwin_output" >"$darwin_file" +printf '%s\n' "$windows_output" >"$windows_file" + +darwin_mariadb="$(extract_revision "$darwin_file" mariadb)" +windows_mariadb="$(extract_revision "$windows_file" mariadb)" +if [[ -z "$darwin_mariadb" || -z "$windows_mariadb" ]]; then + echo "expected mariadb revision to be generated for both platforms" >&2 + exit 1 +fi +if [[ "$darwin_mariadb" == "$windows_mariadb" ]]; then + echo "expected mariadb revision to differ between darwin/arm64 and windows/amd64, got identical value: $darwin_mariadb" >&2 + exit 1 +fi + +darwin_duckdb="$(extract_revision "$darwin_file" duckdb)" +windows_duckdb="$(extract_revision "$windows_file" duckdb)" +if [[ -z "$darwin_duckdb" || -z "$windows_duckdb" ]]; then + echo "expected duckdb revision to be generated for both platforms" >&2 + exit 1 +fi +if [[ "$darwin_duckdb" == "$windows_duckdb" ]]; then + echo "expected duckdb revision to differ between darwin/arm64 and windows/amd64, got identical value: $darwin_duckdb" >&2 + exit 1 +fi + +echo "generate-driver-agent-revisions platform test passed"