build: add basic codespaces configuration (#30528)
* build: @jasonetco said that this will make codespaces work * tmp * Codespaces * Update docker-compose.yml * Update docker-compose.yml * tada? * e use * do not use pizza... * point at correct goma file * use ghcr for codespaces * pass --yes to npx * build: use auth.notgoma codespace token auth to auto-auth goma * build: move build-tools set up to Dockerfile * build: provide default extensions list * Fix locale tests * add vnc support * use prebuilt devcontainer image * update docker images * update docker images * update docker images * add docs for codespaces * chore: update docker images * build: do not overwrite modified buildtools configs on container rebuilds * use gn language server * update docker images * update docker images * fill in missing links Co-authored-by: Codespaces <codespaces@github.com>
This commit is contained in:
parent
eaa5d372fb
commit
cd09a54365
7 changed files with 199 additions and 3 deletions
|
@ -45,7 +45,7 @@ executors:
|
||||||
type: enum
|
type: enum
|
||||||
enum: ["medium", "xlarge", "2xlarge+"]
|
enum: ["medium", "xlarge", "2xlarge+"]
|
||||||
docker:
|
docker:
|
||||||
- image: electron.azurecr.io/build:d818f06a9b1540c7fd38f75ad5a2c493dd6843b6
|
- image: ghcr.io/electron/build:27db4a3e3512bfd2e47f58cea69922da0835f1d9
|
||||||
resource_class: << parameters.size >>
|
resource_class: << parameters.size >>
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
|
|
59
.devcontainer/README.md
Normal file
59
.devcontainer/README.md
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
# Electron Dev on Codespaces
|
||||||
|
|
||||||
|
Welcome to the Codespaces Electron Developer Environment.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
Upon creation of your codespace you should have [build tools](https://github.com/electron/build-tools) installed and an initialized gclient checkout of Electron. In order to build electron you'll need to run the following commands.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
e sync -vv
|
||||||
|
e build
|
||||||
|
```
|
||||||
|
|
||||||
|
The initial sync will take approximately ~30 minutes and the build will take ~8 minutes. Incremental syncs and incremental builds are substantially quicker.
|
||||||
|
|
||||||
|
## Directory Structure
|
||||||
|
|
||||||
|
Codespaces doesn't lean very well into gclient based checkouts, the directory structure is slightly strange. There are two locations for the `electron` checkout that both map to the same files under the hood.
|
||||||
|
|
||||||
|
```graphql
|
||||||
|
# Primary gclient checkout container
|
||||||
|
/workspaces/gclient/*
|
||||||
|
└─ src/* - # Chromium checkout
|
||||||
|
└─ electron - # Electron checkout
|
||||||
|
# Symlinked Electron checkout (identical to the above)
|
||||||
|
/workspaces/electron
|
||||||
|
```
|
||||||
|
|
||||||
|
## Goma
|
||||||
|
|
||||||
|
If you are a maintainer [with Goma access](../docs/development/goma.md) it should be automatically configured and authenticated when you spin up a new codespaces instance. You can validate this by checking `e d goma_auth info` or by checking that your build-tools configuration has a goma mode of `cluster`.
|
||||||
|
|
||||||
|
## Running Electron
|
||||||
|
|
||||||
|
You can run Electron in a few ways. If you just want to see if it launches:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Enter an interactive JS prompt headlessly
|
||||||
|
xvfb-run e start -i
|
||||||
|
```
|
||||||
|
|
||||||
|
But if you want to actually see Electron you will need to use the built-in VNC capability. If you click "Ports" in codespaces and then open the `VNC web client` forwarded port you should see a web based VNC portal in your browser. When you are asked for a password use `builduser`.
|
||||||
|
|
||||||
|
Once in the VNC UI you can open `Applications -> System -> XTerm` which will open a VNC based terminal app and then you can run `e start` like normal and Electron will open in your VNC session.
|
||||||
|
|
||||||
|
## Running Tests
|
||||||
|
|
||||||
|
You run tests via build-tools and `xvfb`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run all tests
|
||||||
|
xvfb-run e test
|
||||||
|
|
||||||
|
# Run the main process tests
|
||||||
|
xvfb-run e test --runners=main
|
||||||
|
|
||||||
|
# Run the old remote tests
|
||||||
|
xvfb-run e test --runners=remote
|
||||||
|
```
|
43
.devcontainer/devcontainer.json
Normal file
43
.devcontainer/devcontainer.json
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"dockerComposeFile": "docker-compose.yml",
|
||||||
|
"service": "buildtools",
|
||||||
|
"onCreateCommand": ".devcontainer/on-create-command.sh",
|
||||||
|
"workspaceFolder": "/workspaces/gclient/src/electron",
|
||||||
|
"extensions": [
|
||||||
|
"joeleinbinder.mojom-language",
|
||||||
|
"rafaelmaiolla.diff",
|
||||||
|
"surajbarkale.ninja",
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"mutantdino.resourcemonitor",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"shakram02.bash-beautify",
|
||||||
|
"marshallofsound.gnls-electron"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"[gn]": {
|
||||||
|
"editor.formatOnSave": true
|
||||||
|
},
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"bashBeautify.tabSize": 2
|
||||||
|
},
|
||||||
|
"forwardPorts": [8088, 6080, 5901],
|
||||||
|
"portsAttributes": {
|
||||||
|
"8088": {
|
||||||
|
"label": "Goma Control Panel",
|
||||||
|
"onAutoForward": "silent"
|
||||||
|
},
|
||||||
|
"6080": {
|
||||||
|
"label": "VNC web client (noVNC)",
|
||||||
|
"onAutoForward": "silent"
|
||||||
|
},
|
||||||
|
"5901": {
|
||||||
|
"label": "VNC TCP port",
|
||||||
|
"onAutoForward": "silent"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hostRequirements": {
|
||||||
|
"storage": "32gb",
|
||||||
|
"cpus": 8
|
||||||
|
},
|
||||||
|
"remoteUser": "builduser"
|
||||||
|
}
|
19
.devcontainer/docker-compose.yml
Normal file
19
.devcontainer/docker-compose.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
buildtools:
|
||||||
|
image: ghcr.io/electron/devcontainer:27db4a3e3512bfd2e47f58cea69922da0835f1d9
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- ..:/workspaces/gclient/src/electron:cached
|
||||||
|
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|
||||||
|
command: /bin/sh -c "while sleep 1000; do :; done"
|
||||||
|
|
||||||
|
user: builduser
|
||||||
|
|
||||||
|
cap_add:
|
||||||
|
- SYS_PTRACE
|
||||||
|
security_opt:
|
||||||
|
- seccomp:unconfined
|
75
.devcontainer/on-create-command.sh
Executable file
75
.devcontainer/on-create-command.sh
Executable file
|
@ -0,0 +1,75 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
buildtools=$HOME/.electron_build_tools
|
||||||
|
gclient_root=/workspaces/gclient
|
||||||
|
buildtools_configs=/workspaces/buildtools-configs
|
||||||
|
|
||||||
|
export PATH="$PATH:$buildtools/src"
|
||||||
|
|
||||||
|
# Create the persisted buildtools config folder
|
||||||
|
mkdir -p $buildtools_configs
|
||||||
|
rm -f $buildtools/configs
|
||||||
|
ln -s $buildtools_configs $buildtools/configs
|
||||||
|
|
||||||
|
# Write the gclient config if it does not already exist
|
||||||
|
if [ ! -f $gclient_root/.gclient ]; then
|
||||||
|
echo "
|
||||||
|
solutions = [
|
||||||
|
{ \"name\" : \"src/electron\",
|
||||||
|
\"url\" : \"https://github.com/electron/electron\",
|
||||||
|
\"deps_file\" : \"DEPS\",
|
||||||
|
\"managed\" : False,
|
||||||
|
\"custom_deps\" : {
|
||||||
|
},
|
||||||
|
\"custom_vars\": {},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
" >$gclient_root/.gclient
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Write the default buildtools config file if it does
|
||||||
|
# not already exist
|
||||||
|
if [ ! -f $buildtools/configs/evm.testing.json ]; then
|
||||||
|
write_config() {
|
||||||
|
echo "
|
||||||
|
{
|
||||||
|
\"root\": \"/workspaces/gclient\",
|
||||||
|
\"goma\": \"$1\",
|
||||||
|
\"gen\": {
|
||||||
|
\"args\": [
|
||||||
|
\"import(\\\"//electron/build/args/testing.gn\\\")\",
|
||||||
|
\"import(\\\"/home/builduser/.electron_build_tools/third_party/goma.gn\\\")\"
|
||||||
|
],
|
||||||
|
\"out\": \"Testing\"
|
||||||
|
},
|
||||||
|
\"env\": {
|
||||||
|
\"CHROMIUM_BUILDTOOLS_PATH\": \"/workspaces/gclient/src/buildtools\",
|
||||||
|
\"GIT_CACHE_PATH\": \"/workspaces/gclient/.git-cache\"
|
||||||
|
},
|
||||||
|
\"remotes\": {
|
||||||
|
\"electron\": {
|
||||||
|
\"origin\": \"https://github.com/electron/electron.git\"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
" >$buildtools/configs/evm.testing.json
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start out as cache only
|
||||||
|
write_config cache-only
|
||||||
|
|
||||||
|
e use testing
|
||||||
|
|
||||||
|
# Attempt to auth to the goma service via codespaces tokens
|
||||||
|
# if it works we can use the goma cluster
|
||||||
|
export NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN
|
||||||
|
if e d goma_auth login; then
|
||||||
|
write_config cluster
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Even if the config file existed we still need to re-auth with the goma
|
||||||
|
# cluster
|
||||||
|
NOTGOMA_CODESPACES_TOKEN=$GITHUB_TOKEN e d goma_auth login || true
|
||||||
|
fi
|
|
@ -1,7 +1,7 @@
|
||||||
resources:
|
resources:
|
||||||
containers:
|
containers:
|
||||||
- container: arm32v7-test-container
|
- container: arm32v7-test-container
|
||||||
image: electron.azurecr.io/build:arm32v7-ca93c6a7bc49e7d2a7b8c62ed04e0b870f3dfd1e
|
image: ghcr.io/electron/build:arm32v7-27db4a3e3512bfd2e47f58cea69922da0835f1d9
|
||||||
options: --shm-size 128m
|
options: --shm-size 128m
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
resources:
|
resources:
|
||||||
containers:
|
containers:
|
||||||
- container: arm64v8-test-container
|
- container: arm64v8-test-container
|
||||||
image: electron.azurecr.io/arm64v8-ca93c6a7bc49e7d2a7b8c62ed04e0b870f3dfd1e
|
image: ghcr.io/electron/build:arm64v8-27db4a3e3512bfd2e47f58cea69922da0835f1d9
|
||||||
options: --shm-size 128m
|
options: --shm-size 128m
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
Loading…
Reference in a new issue