Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add windows codesign to linux tests for testing in docker image #8023

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ jobs:
strategy:
matrix:
testFiles:
- ArtifactPublisherTest,BuildTest,ExtraBuildTest,RepoSlugTest,binDownloadTest,configurationValidationTest,filenameUtilTest,filesTest,globTest,ignoreTest,macroExpanderTest,mainEntryTest,urlUtilTest,extraMetadataTest,linuxArchiveTest,linuxPackagerTest,HoistedNodeModuleTest
- ArtifactPublisherTest,RepoSlugTest,binDownloadTest,configurationValidationTest,filenameUtilTest,filesTest,globTest,ignoreTest,macroExpanderTest,mainEntryTest,urlUtilTest,extraMetadataTest,linuxArchiveTest,linuxPackagerTest,HoistedNodeModuleTest
- snapTest,debTest,fpmTest,protonTest
- BuildTest,ExtraBuildTest,oneClickInstallerTest,winCodeSignTest,winPackagerTest,webInstallerTest
steps:
- name: Checkout code repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
Expand All @@ -40,6 +41,22 @@ jobs:
- name: Lint
run: pnpm pretest

- run: mkdir -p ~/docker-image-cache

- id: docker-image-cache
uses: actions/cache@v1
with:
path: ~/docker-image-cache
key: docker-image-cache-${{ runner.os }}

- if: steps.docker-image-cache.outputs.cache-hit != 'true'
run: |
docker pull electronuserland/builder:18-wine-mono
docker save -o ~/docker-image-cache/image.tar electronuserland/builder:18-wine-mono

- if: steps.docker-image-cache.outputs.cache-hit == 'true'
run: docker load -i ~/docker-image-cache/image.tar

- name: Determine if Dockerfiles changed
id: changed-files-specific
uses: tj-actions/changed-files@90a06d6ba9543371ab4df8eeca0be07ca6054959 # v42
Expand All @@ -54,6 +71,7 @@ jobs:
run: pnpm test-linux
env:
TEST_FILES: ${{ matrix.testFiles }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
FORCE_COLOR: 1

test-mac:
Expand Down
4 changes: 3 additions & 1 deletion packages/app-builder-lib/src/codeSign/windowsCodeSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export async function sign(options: WindowsSignOptions, packager: WinPackager):
computeSignToolArgs: isWin => computeSignToolArgs(taskConfiguration, isWin),
}
await Promise.resolve(executor(config, packager))
isNest = true
// nested signing is only supported on Windows
// https://github.com/electron-userland/electron-builder/issues/7973
isNest = process.platform === "win32"
if (config.resultOutputPath != null) {
await rename(config.resultOutputPath, options.path)
}
Expand Down
32 changes: 28 additions & 4 deletions test/jestSetup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
"use strict"

const isCi = require("ci-info").isCI
let expect;
try {
expect = require("expect")
} catch (_) {
// for Jest in version 28+
const { expect: expectModule } = require("@jest/globals")
expect = expectModule
}

const isWindows = process.platform === "win32"

Expand All @@ -15,7 +23,7 @@ describe.ifAll = isAllTests ? describe : skipSuite
test.ifAll = isAllTests ? test : skip
skip.ifAll = skip

const execEnv = (envVar) => !!envVar ? test : skip
const execEnv = envVar => (!!envVar ? test : skip)
test.ifEnv = execEnv
skip.ifEnv = execEnv

Expand Down Expand Up @@ -47,8 +55,7 @@ skip.ifLinuxOrDevMac = skip
if (isCi) {
test.ifCi = test
test.ifNotCi = skip
}
else {
} else {
test.ifCi = skip
test.ifNotCi = test
}
Expand All @@ -75,4 +82,21 @@ if (!process.env.SZA_COMPRESSION_LEVEL) {
}

process.env.FORCE_YARN = "true"
process.env.TEST_SET_BABEL_PRESET = "true"
process.env.TEST_SET_BABEL_PRESET = "true"

expect.extend({
toBeOneOf(received, items) {
const pass = items.includes(received)
return {
message: () => `expected ${received} to be one of array [${items}]`,
pass,
}
},
toContainsOneOf(received, items) {
const pass = items.some(item => received.includes(item))
return {
message: () => `expected ${received} to be contained in array [${items}]`,
pass,
}
},
})
2 changes: 1 addition & 1 deletion test/src/windows/winCodeSignTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test.ifNotCiMac(
await outputFile(path.join(projectDir, "assets", "nested", "nested", "file.exe"), "invalid PE file")
},
},
error => expect(error.message).toContain("This file format cannot be signed because it is not recognized.")
error => expect(error.message).toContainsOneOf(["This file format cannot be signed because it is not recognized.", "Unrecognized file type:"])
)
)

Expand Down
10 changes: 10 additions & 0 deletions typings/jest.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { JestMatchers } from 'node_modules/@types/jest/index.d.ts'

declare global {
namespace jest {
interface Expect<R> {
toBeOneOf(items: Array<R>): JestMatchers<R>;
toContainsOneOf(items: Array<R>): JestMatchers<R>;
}
}
}
Loading