diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e7f992a76b..5d58eaac5ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,19 +9,23 @@ on: jobs: build: - name: ${{ matrix.friendlyName }} + name: ${{ matrix.friendlyName }} ${{ matrix.arch }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - node: [14.x] + node: [14.15.4] os: [macos-10.15, windows-2019] + arch: [x64, arm64] include: - os: macos-10.15 friendlyName: macOS - os: windows-2019 friendlyName: Windows timeout-minutes: 45 + env: + # Needed for macOS arm64 until hosted macos-11.0 runners become available + SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk steps: - uses: actions/checkout@v2 with: @@ -44,8 +48,17 @@ jobs: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} ${{ runner.os }}-yarn- + # This step can be removed as soon as official Windows arm64 builds are published: + # https://github.com/nodejs/build/issues/2450#issuecomment-705853342 + - name: Get NodeJS node-gyp lib for Windows arm64 + if: ${{ matrix.os == 'windows-2019' && matrix.arch == 'arm64' }} + run: .\script\download-nodejs-win-arm64.ps1 ${{ matrix.node }} + - name: Install and build dependencies run: yarn + env: + npm_config_arch: ${{ matrix.arch }} + TARGET_ARCH: ${{ matrix.arch }} - name: Lint run: yarn lint - name: Validate changelog @@ -62,13 +75,19 @@ jobs: APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} DESKTOPBOT_TOKEN: ${{ secrets.DESKTOPBOT_TOKEN }} KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} + npm_config_arch: ${{ matrix.arch }} + TARGET_ARCH: ${{ matrix.arch }} - name: Prepare testing environment + if: matrix.arch == 'x64' run: yarn test:setup - name: Run unit tests + if: matrix.arch == 'x64' run: yarn test:unit:cov - name: Run script tests + if: matrix.arch == 'x64' run: yarn test:script:cov - name: Run integration tests + if: matrix.arch == 'x64' timeout-minutes: 5 run: yarn test:integration - name: Publish production app diff --git a/app/.npmrc b/app/.npmrc index 87e088ab83d..53acb1365b1 100644 --- a/app/.npmrc +++ b/app/.npmrc @@ -1,4 +1,3 @@ runtime = electron disturl = https://atom.io/download/electron target = 11.1.1 -arch = x64 diff --git a/package.json b/package.json index 0f1c12a492f..b146ac077a7 100644 --- a/package.json +++ b/package.json @@ -127,7 +127,7 @@ "@types/codemirror": "0.0.76", "@types/deep-equal": "^1.0.1", "@types/double-ended-queue": "^2.1.0", - "@types/electron-winstaller": "^2.6.0", + "@types/electron-winstaller": "^4.0.0", "@types/event-kit": "^1.2.28", "@types/express": "^4.11.0", "@types/extract-text-webpack-plugin": "^3.0.3", @@ -172,6 +172,6 @@ "electron": "^11.1.1", "electron-builder": "^22.7.0", "electron-packager": "^15.1.0", - "electron-winstaller": "4.0.2" + "electron-winstaller": "^5.0.0" } } diff --git a/script/build.ts b/script/build.ts index 959caf90c3d..d6aef303b9e 100755 --- a/script/build.ts +++ b/script/build.ts @@ -4,6 +4,7 @@ import * as path from 'path' import * as cp from 'child_process' import * as fs from 'fs-extra' +import * as os from 'os' import packager, { OfficialArch, OsxNotarizeOptions, @@ -141,7 +142,7 @@ function packageApp() { const toPackageArch = (targetArch: string | undefined): OfficialArch => { if (targetArch === undefined) { - return 'x64' + targetArch = os.arch() } if (targetArch === 'arm64' || targetArch === 'x64') { @@ -149,7 +150,7 @@ function packageApp() { } throw new Error( - `Building Desktop for architecture '${targetArch}' is not supported` + `Building Desktop for architecture '${targetArch}' is not supported` ) } diff --git a/script/dist-info.ts b/script/dist-info.ts index 1ac6ec8139b..16d9ca75fa6 100644 --- a/script/dist-info.ts +++ b/script/dist-info.ts @@ -1,5 +1,6 @@ import * as Path from 'path' import * as Fs from 'fs' +import * as os from 'os' import { getProductName, getVersion } from '../app/package-info' import { getReleaseBranchName } from './build-platforms' @@ -16,9 +17,17 @@ export function getDistRoot() { } export function getDistPath() { + let arch = os.arch() + + if (process.env.npm_config_arch) { + // If a specific npm_config_arch is set, we use that one instead of the OS arch (to support cross compilation) + console.log('npm_config_arch detected: ' + process.env.npm_config_arch) + arch = process.env.npm_config_arch + } + return Path.join( getDistRoot(), - `${getExecutableName()}-${process.platform}-x64` + `${getExecutableName()}-${process.platform}-${arch}` ) } diff --git a/script/download-nodejs-win-arm64.ps1 b/script/download-nodejs-win-arm64.ps1 new file mode 100644 index 00000000000..15201149d60 --- /dev/null +++ b/script/download-nodejs-win-arm64.ps1 @@ -0,0 +1,22 @@ +# This script can be removed as soon as official Windows arm64 builds are published: +# https://github.com/nodejs/build/issues/2450#issuecomment-705853342 + +$nodeVersion = $args[0] + +If ($null -eq $nodeVersion) { + Write-Error "No NodeJS version given as argument to this file. Run it like download-nodejs-win-arm64.ps1 12.10.1" + exit 1 +} + +$url = "https://unofficial-builds.nodejs.org/download/release/v$nodeVersion/win-arm64/node.lib" +$cacheFolder = "$env:LOCALAPPDATA\node-gyp\Cache\$nodeVersion\arm64" + +If (!(Test-Path $cacheFolder)) { + New-Item -ItemType Directory -Force -Path $cacheFolder +} + +$output = "$cacheFolder\node.lib" +$start_time = Get-Date + +Invoke-WebRequest -Uri $url -OutFile $output +Write-Output "Downloaded arm64 NodeJS lib $nodeVersion in $((Get-Date).Subtract($start_time).Seconds) second(s)" diff --git a/script/test-appveyor.bat b/script/test-appveyor.bat deleted file mode 100644 index b84ad86e5ab..00000000000 --- a/script/test-appveyor.bat +++ /dev/null @@ -1,2 +0,0 @@ -yarn test -set APPVEYOR_TEST_RESULT=%ERRORLEVEL% diff --git a/yarn.lock b/yarn.lock index ccf73360439..efce917faa7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -743,10 +743,12 @@ resolved "https://registry.yarnpkg.com/@types/double-ended-queue/-/double-ended-queue-2.1.0.tgz#adc862d8d53bdf7d1b23a7d85559815ec1fbb92c" integrity sha512-pCS41/Odn6GMQyqnt8aPTSTQFGriAryYQwVONKk1QhUEhulxueLPE1kDNqDOuJqiv34VLVWXxF4I1EKz3+ftzQ== -"@types/electron-winstaller@^2.6.0": - version "2.6.0" - resolved "https://registry.yarnpkg.com/@types/electron-winstaller/-/electron-winstaller-2.6.0.tgz#703073ee2109fefe8a958fdadb746dfc0a827918" - integrity sha512-pQke6avqSYtkNunEec7NF2dTDSFsf2e1Ti9VkaJFzI15UfTEOjwz22lKoImja7nXPLu8nINYSaVaPgw0XHJEkA== +"@types/electron-winstaller@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/electron-winstaller/-/electron-winstaller-4.0.0.tgz#7377b2cdaab361956cbf1fc41419abb77172d8eb" + integrity sha512-IpgXedqMlSjBIq7+mpj7pkxxZHramuVnrQTyYZbV4M6eABRCNVkbLfXnD35F2+kW3lKFOW9qTcCDo5aGKn7rnQ== + dependencies: + electron-winstaller "*" "@types/eslint-visitor-keys@^1.0.0": version "1.0.0" @@ -4128,10 +4130,10 @@ electron-publish@22.7.0: lazy-val "^1.0.4" mime "^2.4.5" -electron-winstaller@4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/electron-winstaller/-/electron-winstaller-4.0.2.tgz#e3aa7e95db8232eeb337b28c11ad80b93dcafe6d" - integrity sha512-tYmzIyi+W0CXd9o/jmR0VT+vwJ+nOaE/dQz8f64IlbQ/J9d2lpwsmmOKxx6veAVKeYiJHYQHR1eYsLzznNzd5g== +electron-winstaller@*, electron-winstaller@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/electron-winstaller/-/electron-winstaller-5.0.0.tgz#0db968f34d498b16c69566a40848f562e70e7bcc" + integrity sha512-V+jFda7aVAm0htCG8Q95buPUpmXZW9ujh1HdhSlWY6y4QnJnw4TfrmxTlQWV4p2ioF/71JMI/1YF+/qbSICogA== dependencies: asar "^2.0.1" debug "^4.1.1"