chore(refactor): explore parallelization of builds #4800
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: | |
master | |
pull_request: | |
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab | |
inputs: | |
rebuild-docker-images: | |
description: 'Rebuild all Docker images' | |
default: false | |
type: 'boolean' | |
workflow_call: # Allow this workflow to be called from other workflows | |
inputs: | |
rebuild-docker-images-call: | |
description: 'Rebuild all Docker images' | |
required: true | |
type: boolean | |
permissions: | |
contents: read | |
env: | |
TEST_IMAGE_NODE_MAJOR_VERSION: 22 | |
jobs: | |
check-if-docker-build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
outputs: | |
force-docker-build: ${{ steps.changes.outputs.docker == 'true' || steps.changes.outputs.workflow == 'true' }} | |
steps: | |
- name: Checkout code repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Determine if Dockerfiles changed | |
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
id: changes | |
with: | |
filters: | | |
docker: | |
- 'docker/**' | |
workflow: | |
- '.github/workflows/docker*' | |
run-docker-build: | |
needs: check-if-docker-build | |
if: | | |
always() && | |
(needs.check-if-docker-build.outputs.force-docker-build == 'true' || | |
inputs.rebuild-docker-images == 'true' || inputs.rebuild-docker-images == true || | |
inputs.rebuild-docker-images-call == 'true' || inputs.rebuild-docker-images-call == true) | |
uses: ./.github/workflows/docker-build.yml | |
test-linux: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 20 | |
needs: [check-if-docker-build, run-docker-build] | |
# Wonky if-conditional to allow this step to run AFTER docker images are rebuilt OR if the build stage skipped and we want to use dockerhub registry for images | |
if: | | |
always() && | |
needs.check-if-docker-build.result == 'success' && | |
(needs.run-docker-build.result == 'success' || needs.run-docker-build.result == 'skipped') | |
strategy: | |
fail-fast: false | |
matrix: | |
testFiles: | |
- ArtifactPublisherTest,BuildTest,ExtraBuildTest,RepoSlugTest,binDownloadTest,configurationValidationTest,filenameUtilTest,filesTest,globTest,ignoreTest,macroExpanderTest,mainEntryTest,urlUtilTest,extraMetadataTest,linuxArchiveTest,linuxPackagerTest,HoistedNodeModuleTest,MemoLazyTest,HoistTest | |
- snapTest,debTest,fpmTest,protonTest | |
- winPackagerTest,winCodeSignTest,webInstallerTest | |
- oneClickInstallerTest,assistedInstallerTest | |
- concurrentBuildsTest | |
steps: | |
- name: Checkout code repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
with: | |
fetch-depth: 2 | |
- name: Setup Tests | |
uses: ./.github/actions/pretest | |
with: | |
cache-path: ~/.cache/electron | |
cache-key: v-23.3.10-linux-electron | |
- name: Download test-runner if exists | |
if: needs.run-docker-build.result == 'success' | |
id: download-test-runner-image | |
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4 | |
with: | |
name: electron-builder-all-${{ env.TEST_IMAGE_NODE_MAJOR_VERSION }} | |
path: ${{ runner.temp }} | |
- name: Load test runner image if needed | |
if: needs.run-docker-build.result == 'success' | |
run: | | |
docker image load --input ${{ runner.temp }}/electron-builder-all-${{ env.TEST_IMAGE_NODE_MAJOR_VERSION }}.tar | |
docker image ls -a | |
- name: Lint | |
run: pnpm pretest | |
- name: Run tests in docker image | |
run: | | |
echo $TEST_RUNNER_IMAGE_TAG | |
pnpm test-linux | |
env: | |
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} | |
TEST_FILES: ${{ matrix.testFiles }} | |
FORCE_COLOR: 1 | |
TEST_RUNNER_IMAGE_TAG: electronuserland/builder:${{ env.TEST_IMAGE_NODE_MAJOR_VERSION }}-wine-mono | |
# Need to separate from other tests because logic is specific to when TOKEN env vars are set | |
test-updater: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 20 | |
needs: [check-if-docker-build, run-docker-build] | |
# Wonky if-conditional to allow this step to run AFTER docker images are rebuilt OR if the build stage skipped and we want to use dockerhub registry for images | |
if: | | |
always() && | |
needs.check-if-docker-build.result == 'success' && | |
(needs.run-docker-build.result == 'success' || needs.run-docker-build.result == 'skipped') | |
steps: | |
- name: Checkout code repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Setup Tests | |
uses: ./.github/actions/pretest | |
with: | |
cache-path: ~/.cache/electron | |
cache-key: v-23.3.10-update-electron | |
- name: Download test-runner if exists | |
if: needs.run-docker-build.result == 'success' | |
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4 | |
with: | |
name: electron-builder-all-${{ env.TEST_IMAGE_NODE_MAJOR_VERSION }} | |
path: ${{ runner.temp }} | |
- name: Load test runner image if needed | |
if: needs.run-docker-build.result == 'success' | |
run: | | |
docker image load --input ${{ runner.temp }}/electron-builder-all-${{ env.TEST_IMAGE_NODE_MAJOR_VERSION }}.tar | |
docker image ls -a | |
- name: Test | |
run: | | |
echo $TEST_RUNNER_IMAGE_TAG | |
pnpm test-linux | |
env: | |
TEST_FILES: nsisUpdaterTest,linuxUpdaterTest,PublishManagerTest,differentialUpdateTest | |
KEYGEN_TOKEN: ${{ secrets.KEYGEN_TOKEN }} | |
BITBUCKET_TOKEN: ${{ secrets.BITBUCKET_TOKEN }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
FORCE_COLOR: 1 | |
TEST_RUNNER_IMAGE_TAG: electronuserland/builder:${{ env.TEST_IMAGE_NODE_MAJOR_VERSION }}-wine-mono | |
- name: Verify Docs Generation | |
run: pnpm generate-all | |
test-windows: | |
runs-on: windows-latest | |
timeout-minutes: 20 | |
strategy: | |
fail-fast: false | |
matrix: | |
testFiles: | |
- winCodeSignTest,differentialUpdateTest,squirrelWindowsTest | |
- appxTest,msiTest,portableTest,assistedInstallerTest,protonTest | |
- BuildTest,oneClickInstallerTest,winPackagerTest,nsisUpdaterTest,webInstallerTest | |
- concurrentBuildsTest | |
steps: | |
- name: Checkout code repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Setup Tests | |
uses: ./.github/actions/pretest | |
with: | |
cache-key: v-23.3.10-windows-electron | |
cache-path: ~\AppData\Local\electron\Cache | |
- name: Test | |
run: pnpm ci:test | |
env: | |
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} | |
TEST_FILES: ${{ matrix.testFiles }} | |
FORCE_COLOR: 1 | |
test-mac: | |
runs-on: macos-latest | |
timeout-minutes: 20 | |
strategy: | |
fail-fast: false | |
matrix: | |
testFiles: | |
- oneClickInstallerTest,assistedInstallerTest | |
- winPackagerTest,winCodeSignTest,webInstallerTest | |
- masTest,dmgTest,filesTest,macPackagerTest,differentialUpdateTest,macArchiveTest | |
- concurrentBuildsTest | |
steps: | |
- name: Checkout code repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Setup Tests | |
uses: ./.github/actions/pretest | |
with: | |
cache-path: ~/Library/Caches/electron | |
cache-key: v-23.3.10-macos-electron | |
- name: Install toolset via brew | |
run: | | |
brew install powershell/tap/powershell | |
brew install --cask wine-stable | |
brew install rpm | |
- name: Test | |
run: pnpm ci:test | |
env: | |
TEST_FILES: ${{ matrix.testFiles }} | |
FORCE_COLOR: 1 |