Skip to content

Commit

Permalink
chore: build better-sqlite3 with glibc 2.28 (#30390)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschile authored Oct 11, 2024
1 parent 6d25010 commit 1b0ad67
Showing 1 changed file with 74 additions and 9 deletions.
83 changes: 74 additions & 9 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ commands:
only-cache-for-root-user:
type: boolean
default: false
build-better-sqlite3:
type: boolean
default: false
steps:
- install_cache_helpers_dependencies
- run:
Expand All @@ -353,9 +356,18 @@ commands:
- run:
name: Generate platform key
command: node ./scripts/get-platform-key.js > platform_key
- restore_cache:
name: Restore cache state, to check for known modules cache existence
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
- when:
condition: <<parameters.build-better-sqlite3>>
steps:
- restore_cache:
name: Restore cache state, to check for known modules cache existence
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}-better-sqlite3
- unless:
condition: <<parameters.build-better-sqlite3>>
steps:
- restore_cache:
name: Restore cache state, to check for known modules cache existence
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
- run:
name: Bail if cache exists
command: |
Expand All @@ -377,6 +389,10 @@ commands:
PERCY_POSTINSTALL_BROWSER=true \
yarn --prefer-offline --frozen-lockfile --cache-folder ~/.yarn
no_output_timeout: 20m
- when:
condition: <<parameters.build-better-sqlite3>>
steps:
- build-better-sqlite3
- prepare-modules-cache:
dont-move: <<parameters.only-cache-for-root-user>> # we don't move, so we don't hit any issues unpacking symlinks
- when:
Expand All @@ -399,11 +415,22 @@ commands:
paths:
- /tmp/node_modules_cache
- run: touch node_modules_installed
- save_cache:
name: Saving node-modules cache state key
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
paths:
- node_modules_installed
- when:
condition: <<parameters.build-better-sqlite3>>
steps:
- save_cache:
name: Saving node-modules cache state key
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}-better-sqlite3
paths:
- node_modules_installed
- unless:
condition: <<parameters.build-better-sqlite3>>
steps:
- save_cache:
name: Saving node-modules cache state key
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
paths:
- node_modules_installed
- save_cache:
name: Save weekly yarn cache
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
Expand Down Expand Up @@ -486,6 +513,39 @@ commands:
echo "Location of Google Chrome Installation: `which google-chrome-<<parameters.channel>>`"
echo "Google Chrome Version: `google-chrome-<<parameters.channel>> --version`"
# This code builds better-sqlite3 on Debian 10 (Buster). This is necessary because Debian 10 has the oldest glibc version (2.28) that we support.
#
# Since this is running Docker remote (because the job running the command may not be using an executor with the appropriate glibc version), we need to
# copy the project into the container, and copy the built plugin out of the container because the host running docker does not have access to the
# project directory so volume mounts are not possible. The built plugin is copied to the project directory so it can be injected into the final binary.
build-better-sqlite3:
description: Build better-sqlite3 for glibc 2.28
steps:
- setup_remote_docker
- run:
name: Build better-sqlite3 for glibc 2.28
command: |
if [[ ! -f better_sqlite3.node ]]; then
set -x
apt update && apt install -y docker.io
docker run -d --name better-sqlite3-builder cypress/base-internal:20.15.0-buster /bin/bash -c "sleep 1000000000"
docker cp ~/cypress/node_modules/better-sqlite3 better-sqlite3-builder:/better-sqlite3
docker exec -it better-sqlite3-builder /bin/bash -c "cd /better-sqlite3 && source /root/.bashrc && chown -R root:root . && npm install --ignore-scripts && npx --no-install prebuild -r electron -t 27.1.3 --include-regex 'better_sqlite3.node$'"
docker cp better-sqlite3-builder:/better-sqlite3/build/Release/better_sqlite3.node ~/cypress/node_modules/better-sqlite3/build/Release/better_sqlite3.node
docker rm -f better-sqlite3-builder
cp ~/cypress/node_modules/better-sqlite3/build/Release/better_sqlite3.node ~/cypress/better_sqlite3.node
else
cp ~/cypress/better_sqlite3.node ~/cypress/node_modules/better-sqlite3/build/Release/better_sqlite3.node
fi
- save_cache:
key: better-sqlite3-{{ checksum "node_modules/better-sqlite3/package.json" }}-{{ checksum "node_modules/electron/package.json" }}
paths:
- better_sqlite3.node
- run:
name: Clean up top level better-sqlite3 file
command: |
rm ~/cypress/better_sqlite3.node
run-driver-integration-tests:
parameters:
browser:
Expand Down Expand Up @@ -1289,6 +1349,9 @@ jobs:
resource_class:
type: string
default: medium
build-better-sqlite3:
type: boolean
default: false
resource_class: << parameters.resource_class >>
steps:
- update_known_hosts
Expand All @@ -1305,6 +1368,7 @@ jobs:
- ProgramData/nvm # windows
- caching-dependency-installer:
only-cache-for-root-user: <<parameters.only-cache-for-root-user>>
build-better-sqlite3: <<parameters.build-better-sqlite3>>
- store-npm-logs

## restores node_modules from previous step & builds if first step skipped
Expand Down Expand Up @@ -2671,7 +2735,8 @@ jobs:

linux-x64-workflow: &linux-x64-workflow
jobs:
- node_modules_install
- node_modules_install:
build-better-sqlite3: true
- build:
context: test-runner:env-canary
requires:
Expand Down

4 comments on commit 1b0ad67

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1b0ad67 Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.0.0/linux-arm64/release/14.0.0-1b0ad67c27caacc79ba6c39f914acad699bf0a31/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1b0ad67 Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.0.0/darwin-arm64/release/14.0.0-1b0ad67c27caacc79ba6c39f914acad699bf0a31/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1b0ad67 Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.0.0/darwin-x64/release/14.0.0-1b0ad67c27caacc79ba6c39f914acad699bf0a31/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1b0ad67 Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/14.0.0/win32-x64/release/14.0.0-1b0ad67c27caacc79ba6c39f914acad699bf0a31/cypress.tgz

Please sign in to comment.