Skip to content

Commit

Permalink
ci: Fix Windows build (#6826)
Browse files Browse the repository at this point in the history
* ci: specify rust toolchain v1.67.0

* ci: set override rust toolchain

* ci: Use windows-latest and Visual Studio 2022

* ci: Only install Python 2.x on macOS

* ci: Install node-gyp 9.3.1

* fix: Patch neon-sys and node-gyp

* ci: Apply patches during workflow

* ci: Bug fixes

* Debug

* Try fixing bugs

* Patch Cargo.toml on Windows

---------

Co-authored-by: Begoña Alvarez <[email protected]>
  • Loading branch information
rajivshah3 and begonaalvarezd authored May 17, 2023
1 parent ed5db6f commit 271d9e5
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 12 deletions.
48 changes: 36 additions & 12 deletions .github/workflows/build-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
needs: [setup]
strategy:
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
os: [ubuntu-20.04, macos-11, windows-latest]
fail-fast: false
env:
VERSION: ${{ needs.setup.outputs.version }}
Expand All @@ -60,27 +60,51 @@ jobs:
with:
node-version: 14.x

- name: Set up Python 2.x
- name: Set up Python 2.x (macOS)
uses: actions/setup-python@v2
if: matrix.os == 'macos-11'
with:
python-version: '2.x'

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
toolchain: "1.67.0"
profile: minimal
override: true

- name: Install LLVM and Clang (Windows) # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797
uses: KyleMayes/install-llvm-action@32c4866ebb71e0949e8833eb49beeebed48532bd
if: matrix.os == 'windows-2019'
if: matrix.os == 'windows-latest'
with:
version: '11.0'
directory: ${{ runner.temp }}/llvm

- name: Set LIBCLANG_PATH (Windows)
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: matrix.os == 'windows-2019'
if: matrix.os == 'windows-latest'

- name: Update node-gyp to 9.3.1 and apply patch (Windows)
# The node-gyp bundled with Node 14.x does not support VS 2022
# https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md#windows
# We also need to patch this issue https://github.com/nodejs/node-gyp/issues/2673#issuecomment-1239619438
run: |
cd (Get-Item $((gcm node).Path)).DirectoryName
cd node_modules\npm\node_modules\npm-lifecycle
npm install [email protected]
cd node_modules\node-gyp
git apply --ignore-space-change --ignore-whitespace ${{ github.workspace }}\manual-patches\openssl_fips.patch
if: matrix.os == 'windows-latest'

- name: Apply neon-sys patch (Windows)
run: |
cargo install cargo-patch
cp ${{ github.workspace }}\manual-patches\neon_temp_buf.patch .
git apply --ignore-space-change --ignore-whitespace ${{ github.workspace }}\manual-patches\windows_cargo_toml.patch
cat Cargo.toml
cargo patch
working-directory: packages/backend/bindings/node/native
if: matrix.os == 'windows-latest'

- name: Set deployment target (macOS)
run: echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> $GITHUB_ENV
Expand All @@ -96,11 +120,11 @@ jobs:

- name: Enable verbose output for electron-builder (macOS/Linux)
run: echo "DEBUG=electron-builder" >> $GITHUB_ENV
if: matrix.os != 'windows-2019' && github.event.inputs.debugElectronBuilder && github.event.inputs.debugElectronBuilder == 'true'
if: matrix.os != 'windows-latest' && github.event.inputs.debugElectronBuilder && github.event.inputs.debugElectronBuilder == 'true'

- name: Enable verbose output for electron-builder (Windows)
run: echo "DEBUG=electron-builder" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
if: matrix.os == 'windows-2019' && github.event.inputs.debugElectronBuilder && github.event.inputs.debugElectronBuilder == 'true'
if: matrix.os == 'windows-latest' && github.event.inputs.debugElectronBuilder && github.event.inputs.debugElectronBuilder == 'true'

- name: Install dependencies
# Increase network timeout threshold to reduce build failures on Windows
Expand Down Expand Up @@ -141,7 +165,7 @@ jobs:
working-directory: packages/backend/bindings/node/native/target/x86_64-pc-windows-msvc/release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
if: ${{ startsWith(github.ref, 'refs/tags/desktop') && matrix.os == 'windows-2019' }}
if: ${{ startsWith(github.ref, 'refs/tags/desktop') && matrix.os == 'windows-latest' }}

- name: Set productName
run: node scripts/fix-productName.js
Expand Down Expand Up @@ -173,7 +197,7 @@ jobs:
CSC_LINK: ${{ secrets.WIN_CERT_BASE64 }}
CSC_KEY_PASSWORD: ${{ secrets.WIN_CERT_PASSWORD }}
working-directory: packages/desktop
if: matrix.os == 'windows-2019'
if: matrix.os == 'windows-latest'

- name: Build Electron app (Linux)
run: yarn compile:${STAGE}:linux
Expand Down Expand Up @@ -209,7 +233,7 @@ jobs:
- name: Compute checksums (Windows)
run: Get-ChildItem "." -Filter firefly-desktop* | Foreach-Object { $(Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash | Set-Content ($_.FullName + '.sha256') }
working-directory: packages/desktop/out
if: matrix.os == 'windows-2019'
if: matrix.os == 'windows-latest'

- name: Upload artifacts
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -237,7 +261,7 @@ jobs:
- name: Downloading artifacts
uses: actions/download-artifact@v2
with:
name: firefly-desktop-windows-2019
name: firefly-desktop-windows-latest
path: assets

- name: Downloading artifacts
Expand Down
13 changes: 13 additions & 0 deletions manual-patches/neon_temp_buf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/native/src/neon.cc b/native/src/neon.cc
index 7b2981b..164d3cc 100644
--- a/native/src/neon.cc
+++ b/native/src/neon.cc
@@ -227,7 +227,7 @@ extern "C" size_t Neon_ArrayBuffer_Data(v8::Isolate *isolate, void **base_out, v
// the contents.
//
// https://github.com/electron/electron/issues/29893
- #if _MSC_VER && NODE_MODULE_VERSION >= 89
+ #if _MSC_VER && NODE_MODULE_VERSION >= 87
v8::Local<v8::Object> local;
node::Buffer::New(isolate, buffer, 0, buffer->ByteLength()).ToLocal(&local);
return Neon_Buffer_Data(isolate, base_out, local);
13 changes: 13 additions & 0 deletions manual-patches/openssl_fips.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/gyp/pylib/gyp/input.py b/gyp/pylib/gyp/input.py
index d9699a0..e51ee7b 100644
--- a/gyp/pylib/gyp/input.py
+++ b/gyp/pylib/gyp/input.py
@@ -1183,7 +1183,7 @@ def EvalSingleCondition(cond_expr, true_dict, false_dict, phase, variables, buil
else:
ast_code = compile(cond_expr_expanded, "<string>", "eval")
cached_conditions_asts[cond_expr_expanded] = ast_code
- env = {"__builtins__": {}, "v": StrictVersion}
+ env = {"__builtins__": {"openssl_fips": ""}, "v": StrictVersion}
if eval(ast_code, env, variables):
return true_dict
return false_dict
20 changes: 20 additions & 0 deletions manual-patches/windows_cargo_toml.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/packages/backend/bindings/node/native/Cargo.toml b/packages/backend/bindings/node/native/Cargo.toml
index 0292e483b..dfb22776e 100644
--- a/packages/backend/bindings/node/native/Cargo.toml
+++ b/packages/backend/bindings/node/native/Cargo.toml
@@ -22,6 +22,15 @@ tokio = { version = "1.28.0", default-features = false }
once_cell = { version = "1.8.0", default-features = false }
firefly-actor-system = { path = "../../.." }

+[package.metadata.patch.neon-sys]
+version = "0.10.1"
+patches = [
+ { path = "neon_temp_buf.patch", source = "GithubPrDiff" },
+]
+
+[patch.crates-io]
+neon-sys = { path = './target/patch/neon-sys-0.10.1' }
+
[profile.release]
# Build with debug symbols included
debug = true

0 comments on commit 271d9e5

Please sign in to comment.